Progress
Language Reference


STRING Function

Interfaces
OS
SpeedScript
All
All
Yes

Converts a value of any data type into a character value.

SYNTAX

STRING ( source [ , format ] ) 

source

An expression of any data type that you want to convert to a character value.

format

The format you want to use for the new character value. This format must be appropriate to the data type of source. If you do not use this argument, Progress uses EXPORT format. This is useful if you want to produce left-justified numbers. See the Progress Programming Handbook for information on data formats.

EXAMPLE

In the example procedure, the TIME function returns the number of seconds since midnight. The first DISPLAY statement in this procedure uses the STRING function to convert that value into hours and minutes. TIME is the value and “HH:MM AM” is the format used to display the result of the STRING function.

The second DISPLAY statement displays some customer information. It uses the concatenation (+) operator to join together the values of the city, state, and postal-code fields. If these fields were not joined together, the spacing would be different for each customer address depending on the length of the city name.

r-string.p
DISPLAY SKIP(2) "The time is now" STRING(TIME,"HH:MM AM") SKIP(2)
        WITH NO-BOX NO-LABELS CENTERED.

FOR EACH customer:
  DISPLAY name + "  --" + STRING(cust-num, ">>>9") FORMAT "x(30)" AT 1
    address AT 33
    city + ", " + state + " " + postal-code FORMAT "x(22)" AT 33
    SKIP(1)
    WITH NO-BOX NO-LABELS CENTERED.
END. 

When you concatenate character fields, Progress creates a new character field, at least for the duration of the procedure. The default display format for character expressions such as that resulting from the concatenation is x(8). This means that Progress allows only 8 spaces for displaying the concatenation of the city, state, and postal-code fields. The FORMAT x(22) option overrides that default x(8) format, telling Progress to set aside 22 spaces for displaying the concatenation of the city, state, and postal-code fields.

NOTES

SEE ALSO

DECIMAL Function, INTEGER Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095