Skip to main content

getStringCopy

Short summary

this methods copy a string and returns the start address of new string

:return: start address of the string copy

  • Return type: POINTER TO BYTE

Parameters

NameTypeCommentKind
stringAddressPOINTER TO BYTEstring to copyinput
stringLengthUDINTlength of the stringinput

Code

Declaration

METHOD PROTECTED getStringCopy :POINTER TO BYTE
VAR_INPUT
(* string to copy *)
stringAddress :POINTER TO BYTE;
(* length of the string *)
stringLength :UDINT;
END_VAR

Implementation

getStringCopy := __NEW(BYTE, stringLength);
IF (getStringCopy <> 0) THEN
Tc2_System.MEMCPY(
destAddr := getStringCopy,
srcAddr := stringAddress,
n := stringLength
);
END_IF