sosBoolCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.00.00


sosBoolCreate will create a new boolean object.

If the object already exists, it will be replaced.

 

Input:

key : STRING

The key for the object to create. May only contain a-z,A-Z,0-9, "." and "_" (maximum of 250 characters).

 

desc : STRING

The description for the object, to show in the IDE (maximum of 80 characters).

 

value : BOOL default FALSE

The value for the object.

 

Returns: INT

0

- The object is created.

-1

- Generic error.

-2

- Invalid parameter.

 

 

Declaration:

FUNCTION sosBoolCreate : INT;
VAR_INPUT
  key   : STRING;
  desc  : STRING;
  value : BOOL := FALSE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc  : INT;
  ena : BOOL;
END_VAR;
BEGIN
  ...
  // Create boolean object
  rc := sosBoolCreate(key := "config.enable", value:=ON, desc := "Enable the configuration");
  DebugFmt(message:="sosBoolCreate=\1", v1:=rc);
  // Update boolean object
  rc:= sosBoolSet(key:="config.enable", value:=OFF);
  DebugFmt(message:="sosBoolSet=\1", v1:=rc);
 
  // Read boolean object
  rc:= sosBoolGet(key:="config.enable", value:=ena);
  DebugFmt(message:="sosBoolGet=\1 => \2", v1:=rc, v2:=ena);
  ...
END;
 
END_PROGRAM;