Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

MemFill

edmond
2018-09-27
2018-09-27
  • edmond - 2018-09-27

    hi,
    how to use MemFill Function?

    sText:='HELLO';
    mem.MemFill(ADR(stext),2,7);
    

    Result is '$07$07LLO' , first 2 bytes change.

    after that i try 0 instead of 7,

    sText:='HELLO';
    mem.MemFill(ADR(stext),2,0);
    

    Result of sText is '', nothing left.
    Why?

     
  • Anonymous - 2018-09-27

    Originally created by: Viacheslav Mezentsev

    Try this.

    program PLC_PRG
    var
    Β  Β  b: bool := true;
    Β  Β  sz: uint;
    Β  Β  sText: string := 'HELLO';
    end_var
    if b then
    Β  Β  sz := len( sText );
    Β  Β  Mem.MemFill( adr( stext ), sz, 16#31 ); // 0x31 = '1'
    Β  Β  b := false;
    Β  Β  
    end_if
    

    sText is ASCIIZ string. So 0x00 is the mark of the end of string.

     

Log in to post a comment.