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

Codesys 2.3.9.44 ; Function : STRING_COMPARE

Anonymous
2015-05-18
2015-05-18
  • Anonymous - 2015-05-18

    Originally created by: xj750rj

    Hello Everyone,

    I am having trouble making the Function "STRING_COMAPRE" from the Standard library work. Gut-Feeling says its simple but be darned if I can see what I am doing incorrectly. Looks like this:
    VAR
    T_Input_Word:STRING(5):='10123';
    T_Req_Word:STRING(5):='10122';
    STRING_COMPARE1:BOOL;
    END_VAR

    Code:
    STRING_COMPARE1:=STRING_COMPARE (T_Input_Word, T_Req_Word) ;

    Code is 16bit, but is presently running under simulation only. I tried the string function "LEN" under simulation and it works fine returning the lengths of both strings when programmed.
    Anybody see what I am doing incorrectly?

    Thanks,
    Wally

     
  • shooter - 2015-05-18

    i can not find a string_compare in standard,
    in :
    The Library SysLibStr.lib
    Please regard: It depends on the target system, which system libraries can be used in the application program. Please see the document SysLibs_Overview.pdf.

    This library provides functions for string operations. If the target system is supporting the functionality, the following functions can be used to compare or copy strings or to retrieve the length of a string. The execution is synchronous.

    SysStrCmp

    SysStrCmpI

    SysStrCmpN

    SysStrCmpNI

    SysStrCpy

    SysStrLen

    So you can do it with this library
    or you can also use oscat.lib it has loads of functions.

     

Log in to post a comment.