PreviousNextIndex

r-stop2.p
DEFINE VARIABLE ans  AS LOGICAL NO-UNDO. 
FOR EACH Customer ON STOP UNDO, RETRY: 
  DISPLAY Customer.CustNum Customer.Name. 
  UPDATE Customer.CreditLimit. 
  ans = FALSE. 
  MESSAGE "Stopping now undoes changes to this record." 
    "Do you want to stop now?"  
    VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE ans. 
  IF ans THEN STOP. 
END. 

STRING function

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

Syntax

STRING ( source [ , format ] ) 

source
format
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 PostalCode 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 NO-LOCK: 
  DISPLAY Customer.Name + "  --" +  
    STRING(Customer.CustNum, ">>>9") FORMAT "x(30)" AT 1 
    Customer.Address AT 33 
    Customer.City + ", " + Customer.State + " " + Customer.PostalCode  
      FORMAT "x(22)" AT 33 SKIP(1) 
    WITH NO-BOX NO-LABELS CENTERED. 
END. 

When you concatenate character fields, the AVM 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 the AVM allows only 8 spaces for displaying the concatenation of the City, State, and PostalCode fields. The FORMAT x(22) option overrides that default x(8) format, telling the AVM to set aside 22 spaces for displaying the concatenation of the City, State, and PostalCode fields.

Notes
See also

DECIMAL function, INTEGER function, ToString( ) method


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex