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 WORD

Name:
    STRING WORD
Type:
    Let Subcommand
Purpose:
    Extract a specified word from a string.
Description:
    There may be times when it is useful to extract the individual words in a string.

    Dataplot delineates words in a string by spaces. It will treat non-printing characters in the string as spaces. That is, any character in the string with an ASCII collating index less than or equal to 32 or greater than 127 will be treated as a space. In particular, tabs will be treated as spaces. However, hyphens and other special characters such as "&" will not be treated as word boundaries.

Syntax:
    LET <sout> = STRING WORD <sorg> <nword>
    where <sout> is the name of the resulting string;
                <sorg> is the name of the original string;
    and <nword> is the index of the word to extract.
Examples:
    LET SOUT = STRING WORD S1 NWORD
    LET SOUT = STRING WORD S1 5
Note:
    The name of the new string can be the same as the original string. For example,

      LET FNAME = STRING WORD FNAME NWORD

    In this case, FNAME will now contain the extracted word 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 = STRING WORD "a b c d" 2

    you need to do

      LET STRING SORG = a b c d
      LET FNAME = STRING WORD SORG 2

    The word index position can be either a parameter or a numeric value. However, it cannot be a numeric expression. So

      LET FNAME = STRING WORD SORG 5
      LET FNAME = STRING WORD SORG NWORD

    are both allowed but

      LET FNAME = STRING WORD SORG NWORD/2

    is not allowed. You would need to enter this as

      LET NWORD = NWORD/2
      LET FNAME = STRING WORD FNAME NWORD

    The name on the left hand side of the equal sign may be a previously existing string. However, if it is a previously existing parameter, variable, or matrix name, an error will be reported and the requested string will not be created.

Note:
    If the requested word is less than one or is greater than the number of words in the string, an error is reported and the requested string will not be created.
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:
    10/2010
Program:
    let string s = funnel ramp cone square
    .
    feedback off
    print "String s = ^s"
    let nword = number of words s
    loop for k = 1 1 nword
        let s^k = string word s k
        print "String ^k = ^s^k"
    end of loop
    feedback on
        

Privacy Policy/Security Notice
Disclaimer | FOIA

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

Date created: 10/05/2010
Last updated: 02/10/2015

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