SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

STRING COMPARE

Name:
    STRING COMPARE
Type:
    Let Subcommand
Purpose:
    Compare two strings and return a 1 if they are identical and return a 0 if they are not.
Syntax 1:
    LET <ival> = STRING COMPARE <s1> <s2>
    where <ival> is a parameter containing a 1 if the strings are identical and 0 if they are not;
                <s1> is the name of the first string;
    and     <s2> is the name of the second string.

    With this syntax, the comparison is case sensitive and the full strings are compared (if the strings are of unequal length a 0 will be returned even if the strings match up to length of the shorter string).

Syntax 2:
    LET <ival> = STRING COMPARE NOCASE <s1> <s2>
    where <ival> is a parameter containing a 1 if the strings are identical and 0 if they are not;
                <s1> is the name of the first string;
    and     <s2> is the name of the second string.

    With this syntax, the comparison is not case sensitive and the full strings are compared (if the strings are of unequal length a 0 will be returned even if the strings match up to length of the shorter string).

Syntax 3:
    LET <ival> = STRING COMPARE <s1> <s2> <len>
    where <ival> is a parameter containing a 1 if the strings are identical and 0 if they are not;
                <s1> is the name of the first string;
                <s2> is the name of the second string;
    and     <len> is a number or a parameter that specifies the number of characters in the strings to compare.

    With this syntax, the comparison is case sensitive, but only the first <len> characters in <s1> and <s2> are compared.

Syntax 4:
    LET <ival> = STRING COMPARE NOCASE <s1> <s2> <len>
    where <ival> is a parameter containing a 1 if the strings are identical and 0 if they are not;
                <s1> is the name of the first string;
                <s2> is the name of the second string;
    and     <len> is a number or a parameter that specifies the number of characters in the strings to compare.

    With this syntax, the comparison is not case sensitive, but only the first <len> characters in <s1> and <s2> are compared.

Examples:
    LET IVAL = STRING COMPARE S1 S2
    LET IVAL = STRING COMPARE NOCASE S1 S2
    LET IVAL = STRING COMPARE S1 S2 NCHAR
    LET IVAL = STRING COMPARE NOCASE S1 S2 NCHAR
Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Data Management
Implementation Date:
    2011/01
    2021/08: Support for NOCASE option
    2021/08: Support for limiting the comparison to a specified number of characters at the start of the strings
Program:
     
    LET STRING S1 = file23.dat
    LET STRING S2 = file13.dat
    LET STRING S3 = file23.dat
    LET IVAL1 = STRING COMPARE S1 S2
    LET IVAL2 = STRING COMPARE S1 S3
        
    The resulting values of IVAL1 and IVAL2 are 0 and 1, respectively.

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 01/06/2011
Last updated: 08/09/2021
Please email comments on this WWW page to alan.heckert@nist.gov.