ABSOLUTE function

Returns the absolute value of a numeric value.

Syntax

ABSOLUTE ( n )
n
An integer or decimal expression. The return value is the same format as n.

Example

This procedure calculates the number of miles you drive between highway exit ramps.

r-abs.p

DEFINE VARIABLE mark-start  AS DECIMAL NO-UNDO.
DEFINE VARIABLE mark-finish AS DECIMAL NO-UNDO.
DEFINE VARIABLE units       AS LOGICAL NO-UNDO FORMAT "miles/kilometers".

FORM
  mark-start LABEL "Mile marker for highway on-ramp" SKIP
  mark-finish LABEL "Mile marker next to your exit" SKIP(1)
  units LABEL "Measure in <m>iles or <k>ilometers" SKIP(1)
  WITH FRAME question SIDE-LABELS 
  TITLE "This program calculates distance driven.".

UPDATE mark-start mark-finish units WITH FRAME question.

DISPLAY
  "You have driven" ABSOLUTE(mark-start - mark-finish) units
  WITH NO-LABELS FRAME answer.