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

SUBSTRING

Name:
    SUBSTRING
Type:
    Let Subcommand
Purpose:
    Extract a substring of a previously defined string. specified position.
Syntax:
    LET <sout> = SUBSTRING <sorg> <nstart> <nstop>
    where <sout> is the name of the resulting string;
                <sorg> is the name of the original string;
                <nstart> is the start position in <sorg>;
    and <nstop> is the stop position in <sorg>.
Examples:
    LET SOUT = SUBSTRING S1 NSTART NSTOP
    LET SOUT = SUBSTRING S1 3 8
Note:
    The name of the new string can be the same as the original string. For example,

      LET FNAME = SUBSTRING FNAME NSTART NSTOP

    In this case, FNAME will now contain the substring rather than the original string.

Note:
    The string on the right hand side of the equal sign must be a previously existing string. That is, expressions are not allowed. For example, instead of

      LET FNAME = SUBSTRING "file99.dat" 5 6

    you need to do

      LET STRING SORG = file99.dat
      LET FNAME = SUBSTRING SORG 5 6

    The start and stop position can be either a parameter or a numeric value. However, it cannot be a numeric expression. So

      LET FNAME = SUBSTRING SORG 5 6
      LET FNAME = SUBSTRING SORG NSTART NSTOP

    are both allowed but

      LET FNAME = SUBSTRING SORG NSTART NLEN/2

    is not allowed. You would need to enter this as

      LET NSTOP = NLEN/2
      LET FNAME = SUBSTRING FNAME NSTART NSTOP
Note:
    The total number of characters that DATAPLOT can use for storing functions and strings is set when DATAPLOT is built. The current default (11/2008) is 50,000 characters. Previous versions may set this limit at 1,000 or 10,000 characters. This limit applies to the combined number of characters for all functions and strings.
Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Data Management
Implementation Date:
    11/2008
Program:
     
    LET STRING S1 = file23.dat
    LET NSTOP = STRING LENGTH S1
    LET NSTART = STRING INDEX S1 SPERIOD
    LET SEXT = SUBSTRING S1 NSTART NSTOP
    LET NSTOP = NSTART - 1
    LET NSTART = 1
    LET SBASE = SUBSTRING S1 NSTART NSTOP
        
    The resulting strings SEXT and SBASE will contain

      .dat
      file23

Date created: 12/4/2008
Last updated: 12/4/2008
Please email comments on this WWW page to alan.heckert@nist.gov.