[Stackoverflow] [Progress OpenEdge ABL] Return Default Value When No Match Found

Status
Not open for further replies.
J

Jake Geers

Guest
I have a function GetQuantity that returns a decimal. In some cases I want to return nothing i.e. and empty string so that ' ' is displayed.

Actual Behavior:

  1. GetQuantity(1) -> 1.0
  2. GetQuantity(2) -> 2.0
  3. GetQuantity(3) -> 3.3

Desired Behavior:

  1. GetQuantity(1) -> 1.0
  2. GetQuantity(2) -> 2.0
  3. GetQuantity(3) -> ' '

In case 3 I can obviously return -1.0 or something but that is not what I need.

FUNCTION GetQuantity RETURNS DECIMAL(INPUT num AS INTEGER):
DEFINE VARIABLE quantity AS DECIMAL NO-UNDO FORMAT "->,>>>,>>9.9<<<<<<<<".

quantity = 3.3. //initialization is neccessary as IRL my value is initialized

IF num = 1 THEN DO:
RETURN 1.0.
END.

ELSE IF num = 2 THEN DO:
RETURN 2.0.
END.

RETURN quantity. //base case return ' '
END.

DISPLAY GetQuantity(3)

Continue reading...
 
Status
Not open for further replies.
Top