sosStringCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.00.00


sosStringCreate will create a new string 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).

 

str : STRING

The value for the object.

 

max_len : INT(1..16384) default 254

The maximum allowed length for the object.

 

Returns: INT

0

- The object is created.

-1

- Generic error.

-2

- Invalid parameter.

 

 

Declaration:

FUNCTION sosStringCreate : INT;
VAR_INPUT
  key     : STRING;
  desc    : STRING;
  str     : STRING;
  max_len : INT := 254;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc   : INT;
  name : STRING;
END_VAR;
BEGIN
  ...
  // Create string object
  rc := sosStringCreate(key := "config.name", str:="Test configuration", desc := "Name of the configuration", max_len := 50);
  DebugFmt(message:="sosStringCreate=\1", v1:=rc);
  // Update string object
  rc:= sosStringSet(key:="config.name", str:="New name");
  DebugFmt(message:="sosStringSet=\1", v1:=rc);
 
  // Read string object
  rc:= sosStringGet(key:="config.name", str:=name);
  DebugFmt(message:="sosStringGet=\1 => " + name, v1:=rc);
  ...
END;
 
END_PROGRAM;