API Strings - Krystian-L-Lis/Stage GitHub Wiki
#API #Strings
Type: Alias
Description:
Alias for STRING(1)
values.
Type: Alias
Description:
Alias for STRING(255)
values.
Type: Program
Description:
Keeps various formatting functions under one program to avoid namespace pollution.
Type: Method
Description:
Formats a string using Tc2_Utilities.FB_FormatString
with a single argument. This supports various number formatting options.
Signature:
METHOD Fmt : Str
VAR_INPUT
sFormat: Str; // Format string (see Beckhoff Infosys for spec)
tcArg: Tc2_Utilities.T_Arg;
END_VAR
Type: Method
Description:
Adds padding to an input string. Supports specifying padding length on both sides and a custom fill character.
Signature:
METHOD Padding : Str
VAR_INPUT
sValue: Str; // Original string
nLeftPadding: USINT := 0; // Padding on the left
nRightPadding: USINT := 0; // Padding on the right
sFillChar: Ch := ' '; // Character to use for padding
END_VAR
Type: Method
Description:
Formats a time value into a human-readable string using the format 000d 00h 00m 00s 000ms
. The user can define minimum and maximum units. The maximum is flexible—higher units will be included automatically if needed.
Signature:
METHOD SimpleTime : Str
VAR_INPUT
tValue : TIME; // Time value to format
sMinUnit : Str := 'MS'; // Minimum unit to show (e.g., MS, S, M, H, D)
sMaxUnit : Str := 'S'; // Maximum unit to show
END_VAR
Type: Function Block
Description:
A string builder utility that allows manipulation of a string up to 255 characters. Implements the I_Strb
interface for method chaining.
Type: Method
Description:
Appends a string to the current value. Truncates if total length exceeds 255 characters.
Signature:
METHOD Append : I_Strb
VAR_INPUT
sToAdd: Str;
END_VAR
Type: Method
Description:
Finds the first occurrence of a substring after a specified position.
Signature:
METHOD FindFirstAfter : I_Strb
VAR_INPUT
sToFind : Str;
nPosition : INT := 1;
END_VAR
VAR_OUTPUT
nStart: INT;
nEnd: INT;
END_VAR
Type: Method
Description:
Finds the last occurrence of a substring before a specified position.
Signature:
METHOD FindLastBefore : I_Strb
VAR_INPUT
sToFind : Str;
nPosition : INT := 256;
END_VAR
VAR_OUTPUT
nStart: INT;
nEnd: INT;
END_VAR
Type: Method
Description:
Checks if a substring exists after a specified position.
Signature:
METHOD HasAfter : BOOL
VAR_INPUT
sToFind : Str;
nPosition : INT := 0;
END_VAR
VAR_OUTPUT
nStart: INT;
nEnd: INT;
END_VAR
Type: Method
Description:
Checks if a substring exists before a specified position.
Signature:
METHOD HasBefore : BOOL
VAR_INPUT
sToFind : Str;
nPosition : INT := 256;
END_VAR
VAR_OUTPUT
nStart: INT;
nEnd: INT;
END_VAR
Type: Method
Description:
Inserts a substring at a specified position. Truncates if resulting length exceeds 255 characters.
Signature:
METHOD Inject : I_Strb
VAR_INPUT
nPosition: INT;
sToInject: Str;
END_VAR
Type: Method
Description:
Checks if the current string is empty.
Signature: METHOD IsEmpty : BOOL
Type: Method
Description:
Returns the length of the current string.
Signature: METHOD Length : INT
Type: Method
Description:
Prepends a string to the current value. Truncates if total length exceeds 255 characters.
Signature:
METHOD Prepend : I_Strb
VAR_INPUT
sToAdd : Str;
END_VAR
Type: Method
Description:
Returns the current string.
Signature: METHOD Read : Str
Type: Method
Description:
Removes a substring of specified length starting at a given position.
Signature:
METHOD Remove : I_Strb
VAR_INPUT
nLength: INT;
nPosition: INT;
END_VAR
Type: Method
Description:
Sets the current string to the given literal.
Signature:
METHOD Set : I_Strb
VAR_INPUT
sString: Str;
END_VAR
Type: Method
Description:
Extracts a substring from a given position and length.
Signature:
METHOD Slice : I_Strb
VAR_INPUT
nPosition: INT;
nLength: INT;
END_VAR
VAR_OUTPUT
sSlice: Strb;
END_VAR
Type: Method
Description:
Splits the current string into two parts at the specified position.
Signature:
METHOD Split : I_Strb
VAR_INPUT
nPosition: INT;
END_VAR
VAR_OUTPUT
sLeft: Strb;
sRight: Strb;
END_VAR