Bill
Bill

Reputation: 97

Why does this OpenEdge 10.2B Code work, and not generate a run-time error?

Shouldn't this simple program generate a run-time error? When I run it, the value of 4 is displayed on the screen.

RUN pTest ( 2 + 2 ).

PROCEDURE pTest:

  DEF INPUT PARAM cData AS CHAR NO-UNDO.

  DISPLAY cData.

END.

Upvotes: 0

Views: 186

Answers (1)

Tom Bascom
Tom Bascom

Reputation: 14020

Because 2 + 2 gets cast to a character.

The documentation of DEFINE PARAMETER says:

"In addition, the parameter types (INPUT, OUTPUT, INPUT-OUTPUT, RETURN, TABLE, TABLE-HANDLE, DATASET, DATASET-HANDLE, and BUFFER) specified in the DEFINE and RUN statements must agree. The corresponding data types and run-time values must also be compatible enough to allow the AVM to perform any necessary conversions."

Upvotes: 2

Related Questions