sosIntegerCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.00.00


sosIntegerCreate will create a new integer 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 : DINT default 0

The initial value for the object. The value is not validated, making it possible to use it to e.g. determine unmodified values.

 

min_val : DINT default -2147483648

The minimum allowed value for the object. If both min_val and max_val are 0, there will be no limit.

 

max_val : DINT default 2147483647

The maximum allowed value for the object. If both min_val and max_val are 0, there will be no limit.

 

Returns: INT

0

- The object is created.

-1

- Generic error.

-2

- Invalid parameter.

 

 

Declaration:

FUNCTION sosIntegerCreate : INT;
VAR_INPUT
  key     : STRING;
  desc    : STRING;
  value   : DINT := 0;
  min_val : DINT := -2_147_483_648;
  max_val : DINT := 2_147_483_647;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc      : INT;
  timeout : INT;
END_VAR;
BEGIN
  ...
  // Create integer object
  rc := sosIntegerCreate(key := "config.timeout", value:=600, desc := "Timeout for the connection");
  DebugFmt(message:="sosIntegerCreate=\1", v1:=rc);
  // Update integer object
  rc:= sosIntegerSet(key:="config.timeout", value:=6000);
  DebugFmt(message:="sosIntegerSet=\1", v1:=rc);
 
  // Read integer object
  rc:= sosIntegerGetInt(key:="config.timeout", value:=timeout);
  DebugFmt(message:="sosIntegerGetInt=\1 => \2", v1:=rc, v2:=timeout);
  ...
END;
 
END_PROGRAM;