Sysmemset, memory set

List

This page is part of the IEC 61131-3 Programming Manual. Go to the index.

The function fills the memory area defined by the parameter Buf with the data defined in the parameter Ch. The parameter Size defines the size of the area to be filled. The function returns the address of the memory area to be filled.

information circle

Function

CODESYS: eCDSXUnified12Lib

LogicLab: eLLabXUnified12Lib

Description

Buf (@BYTE) Address of the memory area in which to transfer the data.
Ch (INT) Data to be transferred.
Size (UDINT) Size of the memory area to be occupied

The function returns a variable (@BYTE) with the address of the memory area where it transferred the data. In case of error it is returned eNULL.

Sysmemset function image

Examples

How to use the examples.
By activating the variable from debuf CSet the function Sysmemset reset the buffer Message, when the execution is finished Result it will be set with the buffer address.

LogicLab (Ptp116)
PROGRAM ST_Sysmemset
VAR
    CSet : BOOL; (* Set command *)
    Result : UDINT; (* Function result *)
    Message: STRING[ 32 ]; (* Memory buffer *)
END_VAR

// *****************************************************************************
// PROGRAM "ST_Sysmemset"
// *****************************************************************************
// By setting the "Set" command the memory zeroed.
// -----------------------------------------------------------------------------

    IF (CSet) THEN
        CSet:=FALSE; //Set command
        Result:=Sysmemset(ADR(Message), 0, SIZEOF(Message));
    END_IF;

// [End of file]
CODESYS (Ptp161)
PROGRAM ST_Sysmemset
VAR
    CSet : BOOL; //Set command
    Result : UDINT; //Function result
    Message: STRING[ 32 ]; //Memory buffer
END_VAR

// *****************************************************************************
// PROGRAM "ST_Sysmemset"
// *****************************************************************************
// By setting the "Set" command the memory zeroed.
// -----------------------------------------------------------------------------

    IF (CSet) THEN
        CSet:=FALSE; //Set command
        Result:=Sysmemset(ADR(Message), 0, SIZEOF(Message));
    END_IF;

// [End of file]
Was this article helpful?