This is part of 3.33.0latest release.

STRING_TO_BUFFER

1.4.0
since lib: v2.27.0  

Ea consequat pariatur est culpa excepteur veniam laboris id ea incididunt. Aute adipisicing velit consequat minim laboris aute eiusmod officia ex esse ad nulla labore magna.

Ea consequat pariatur est culpa excepteur veniam laboris id ea incididunt. Aute adipisicing velit consequat minim laboris aute eiusmod officia ex esse ad nulla labore magna.

Esse consequat culpa anim eiusmod quis laborum nulla Lorem. Labore ad officia irure ad sunt. Dolor nulla nostrud irure duis Lorem aute minim consequat sit enim occaecat mollit. Amet pariatur amet dolor sint nisi sunt in occaecat aute sit qui ea enim.

Examples:

_STRING_TO_BUFFER(STR, POS, ADR(bigarray), SIZEOF(bigarray))

Version history

1.4.0

  hm

Changes

Changed:
  • return the position after the input string when finished
show full history

1.3.0

  hm

Changes

Changed:
  • limit end to size - 1

1.2.0

  hm

Changes

Changed:
  • type of pointer to array[1..32767]
  • size of string to STRING_LENGTH

1.1.0

  hm

Changes

Changed:
  • type of input size to UINT

1.0.0

  hm

Changes

Added:
  • original version

Overview

kindnametypedefaultcomment
inputSTRSTRING(STRING_LENGTH)string to be copied
inputPOSINTposition from which the string is copied into the buffer
inputPTPOINTER TO ARRAY[0..32767] OF BYTEaddress of the buffer
inputSIZEUINTsize of the buffer

Details

STR

STRING(STRING_LENGTH)

String to be copied.

POS

INT

Position from which the string is copied into the buffer.

PT

POINTER TO ARRAY[0..32767] OF BYTE

Address of the buffer.

SIZE

UINT

Size of the buffer.

Source code

Declarations

(*Converts a Real to a fixed length String*)
FUNCTION index : INT

(*
 * -----------------------------------------------------------------------------
 * Name               : index
 * Version            : 1.4.0
 * Date               : 2012-01-02
 * Author             : hm
 * 
 * -----------------------------------------------------------------------------
 * Converts a Real to a fixed length String
 * -----------------------------------------------------------------------------
 *)

VAR_INPUT
  STR : STRING(STRING_LENGTH); (*string to be copied*)
  POS : INT; (*position from which the string is copied into the buffer*)
  PT : POINTER TO ARRAY[0..32767] OF BYTE; (*address of the buffer*)
  SIZE : UINT; (*size of the buffer*)
END_VAR

VAR
  ps : POINTER TO BYTE;
  i : INT;
  end : INT;
END_VAR

Logic

ps := ADR(str);
end := MIN(pos + LEN(str), UINT_TO_INT(size));
IF end > 0 THEN end := end -1; END_IF;
FOR i := pos TO end DO
	pt^[i] := ps^;
	ps := ps + 1;
END_FOR;

_STRING_TO_BUFFER := i;

Implementation

Snippet of the function call:
dummy := STRING_TO_BUFFER(
           STR := ,
           POS := ,
           PT := ,
           SIZE := );