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

IS NUMBER

Name:
    IS NUMBER
Type:
    Let Subcommand
Purpose:
    Determine whether a previously defined string defines a valid numerical value.
Description:
    There are times where it may be useful to determine if a previously defined string defines a valid numeric value or not. The primary motivation for this command is to distinguish if a string is a parameter name or a number (e.g., when using command line arguments).

    Dataplot determines this by attempting an internal Fortran read. That is (where STR is the string being tested),

      READ(STR,*,IOSTAT=IE)AVAL

    If IOSTAT does not indicate an error, then STR is assumed to be a number. If IOSTAT does indicate an error, then STR is assumed to not be a number.

    Note that there are some strings that are ambiguous in that they can be interpreted as either a valid number or a parameter name. For example, 1D0 will be read successfully as a number, but it is also a valid parameter name in Dataplot. Determining whether this should be considered a number or a parameter will be dependent on the specific application. The basic rule for this command is that if it can be successfully read as a number it will be considered a number.

Syntax:
    LET <ival> = IS NUMBER <sorg>
    where <sorg> is a previously defined string;
    and <ival> is a parameter.

    The <ival> will be set to 1 if <sorg> is determined to be a number and set to 0 if <sorg> is determined to not be a number.

Examples:
    LET STRING S1 = PARNAME
    LET IFLAG = IS NUMBER S1
    LET STRING S2 = 34.56
    LET IFLAG = IS NUMBER S2
Note:
    The string on the right hand side of the equal sign must be a previously defined string. String expressions are not allowed. So

      LET IFLAG = IS NUMBER "45.6"

    should be coded as

      LET STRING S1 = 45.6
      LET IFLAG = IS NUMBER S1
Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Data Management
Implementation Date:
    2020/11
Program:
     
    CALL MACRO.DP  K=3.56
        
    where MACRO.DP contains
     
    LET STRING SORG = $k
    LET IFLAG = IS NUMBER SORG
    IF IFLAG = 1; . ARGUMENT IS A NUMBER
       LET AVAL = ^SORG
    ELSE IF IFLAG = 0; . ARGUMENT IS A STRING
       IF SORG EXISTS
          LET AVAL = ^SORG
       ELSE
          LET AVAL = -9999
       END OF IF
    END OF IF
        

Privacy Policy/Security Notice
Disclaimer | FOIA

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

Date created: 11/10/2020
Last updated: 11/10/2020

Please email comments on this WWW page to alan.heckert@nist.gov.