Home AMX User Forum NetLinx Studio

RFI Keyword COMPARE_STRINGS

Good Afternoon,

The first time I searched the Forum, TechNotes, P1&2 Manual, and NetLinxControllers.WebConsole-ProgrammingGuide; and aside from it being listed in the P1&2 (very outdated) Manual as the Keyword "COMPARE_STRINGS" I could not find what it does or how it's used...

However, part of the reason for that is that the keyword is apparently COMPARE_STRING (with no S at the end) as listed in the P1&2 (very outdated) Manual.

After discovering that (and a renewed forum search, thanks bano (and probably others)) I discovered the following TechNote:

Wildcards in Netlinx vs. Axcess
http://www.amx.com/techsupport/techNote.asp?id=555
(ironically, you still cannot find this technote by searching for COMPARE_STRING)

Which does describe the use of the wildcard ? with respect to COMPARE_STRING(..) ... in addition COMPARE_STRING is now recognized as a keyword in NLS, so a handy F1 brings additional details.

JL

PS Hopefully this will help someone else. :-)

Comments

  • viningvining Posts: 4,368
    They do have this in the NS3 help file > keywords > STRING Keywords > COMPARE_STRING:
    COMPARE_STRING
    This keyword compares two character strings. 
    
    If either string contains a ‘?’ character, the matching character in the other string is not compared. The ‘?’ is equivalent to a wildcard. 
    
    Example:
    
    DEFINE_LIBRARY_FUNCTION LONG COMPARE_STRING(CHAR A[], CHAR B[])
    
    Here is some useful debugging code:
    
    tstStr = 'ALEXERICRYAN'
    
    ulError = COMPARE_STRING ( tstStr, 'ALEX' )
    
    if( ulError == 0 )
    
    SEND_STRING DvDEBUG, 'ALEXERICRYAN != ALEX'
    
    else
    
     SEND_STRING DvDEBUG, 'ALEXERICRYAN == ALEX... BAD!'
    
     
    
    tstStr = 'ALEXERICRYAN'
    
    ulError = COMPARE_STRING ( tstStr, 'ALEXERICRYAN' )
    
    if ( ulError == 0 )
    
     SEND_STRING DvDEBUG, 'ALEXERICRYAN != ALEXERICRYAN...BAD!'
    
    else
    
     SEND_STRING DvDEBUG, 'ALEXERICRYAN == ALEXERICRYAN'
    
     
    
    tstStr = 'ALEXERICRYAN'
    
    ulError = COMPARE_STRING ( tstStr, 'ALEX????RYAN' )
    
    if ( ulError == 0 )
    
     SEND_STRING DvDEBUG, 'ALEXERICRYAN != ALEX????RYAN...BAD!'
    
    else
    
     SEND_STRING DvDEBUG, 'ALEXERICRYAN == ALEX????RYAN'
    
    Another example of a use for this feature is if you want an event to occur every hour. You would enter a time string that would contain a ‘??;00 ;00’ (hours/minute/sec) for the recurring event that in this case would occur every hour.
    
    Result: The returned result can only be True (1) or False (0).
    
    0 = the strings don’t match 
    
    1 = the strings are the same
    
    Personally I've never come across a need to use it. Haven't needed the wildcard either but then again I still don't use "FORMAT" which probaly means I'm just backwards. :)
Sign In or Register to comment.