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 JUSTIFY

Name:
    STRING JUSTIFY
Type:
    Let Subcommand
Purpose:
    Left, center, or right justify a string.
Description:
    The STRING REMOVE SPACES command can be used to remove leading or trailing spaces from a string. This command allows you to add leading or trailing spaces.

    That is, you specify the desired length of the string. If LEFT justification is requested, trailing spaces will be added to the end of the string so that the string has the desired length. Likewise, if RIGHT justification is requested, leading spaces will be added to the beginning of the string. If CENTER justification is requested, both leading and trailing spaces will be added.

    If the requested string already has a length greater than the requested length, the output string will be set equal to the input string.

    By default, the added leading and trailing characters are spaces. You can specify a different character by entering the command

      SET STRING JUSTIFICATION CHARACTER <char>

    To reset the default of spaces, enter

      SET STRING JUSTIFICATION CHARACTER SPACE
Syntax 1:
    LET <sout> = STRING LEFT JUSTIFY <sorg> <nlen>
    where <sout> is the name of the resulting string;
                <sorg> is the name of the original string;
    and      <nlen> is the desired length of the output string.

    If n1 is the length of the original string and <nlen> is n2, then n2 - n1 spaces will be added to the end of <sorg>. If n1 ≥n2, <sout> will be set equal to <sorg>.

Syntax 2:
    LET <sout> = STRING RIGHT JUSTIFY <sorg> <nlen>
    where <sout> is the name of the resulting string;
                <sorg> is the name of the original string;
    and      <nlen> is the desired length of the output string.

    If n1 is the length of the original string and <nlen> is n2, then n2 - n1 spaces will be added to the beginning of <sorg>. If n1 >= n2, <sout> will be set equal to <sorg>.

Syntax 3:
    LET <sout> = STRING CENTER JUSTIFY <sorg> <nlen>
    where <sout> is the name of the resulting string;
                <sorg> is the name of the original string;
    and      <nlen> is the desired length of the output string.

    If n1 is the length of the original string and <nlen> is n2, then (n2 - n1)/2 spaces will be added to the beginning of <sorg> and (n2 - n1)/2 spaces will be added to the end of <sorg>. If n2 - n1 is odd, the extra space will be added to the beginning of <sorg>. If n1 ≥ n2, <sout> will be set equal to <sorg>.

Examples:
    LET SOUT = STRING LEFT JUSTIFY S1 NLEN
    LET SOUT = STRING RIGHT JUSTIFY S1 20
    LET SOUT = STRING CENTER JUSTIFY S1 NLEN
Note:
    The name of the new string can be the same as the original string. For example,

      LET SORG = STRING RIGHT JUSTIFY SORG NLEN
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 SOUT = STRING RIGHT JUSTIFY "XXXXX" 10

    you need to do

      LET STRING SORG = XXXXX
      LET SOUT = STRING RIGHT JUSTIFY SORG 10

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

      LET SOUT = STRING RIGHT JUSTIFY SORG 10
      LET SOUT = STRING RIGHT JUSTIFY SORG NLEN

    are both allowed but

      LET SOUT = STRING RIGHT JUSTIFY SORG NLEN/2

    is not allowed. You would need to enter this as

      LET NLEN2 = NLEN/2
      LET SOUT = STRING RIGHT JUSTIFY SORG NLEN2
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:
    2019/01
Program:
     
    SKIP 25
    READ BERGER1.DAT Y X
    FIT Y X
    LET CC = CORRELATION Y X
    .
    LET STRING S1 = A0:
    LET STRING S2 = A1:
    LET STRING S3 = CORR:
    LET NLEN = 8
    LET S1 = STRING LEFT JUSTIFY S1 NLEN
    LET S2 = STRING LEFT JUSTIFY S2 NLEN
    LET S3 = STRING LEFT JUSTIFY S3 NLEN
    LET A0 = ROUND(A0,2)
    LET A1 = ROUND(A1,2)
    LET CC = ROUND(CC,2)
    LEGEND 1 ^S1 ^A0
    LEGEND 2 ^S2 ^A1
    LEGEND 3 ^S3 ^CC
    .
    CHARACTER X BLANK
    LINE BLANK SOLID
    .
    PLOT Y PRED VS X
        
    plot generated by sample program

Privacy Policy/Security Notice
Disclaimer | FOIA

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

Date created: 01/31/2019
Last updated: 01/31/2019

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