Tutorial by Examples

Unlike functions, there's no need to forward declare a procedure. It can be placed anywhere in your code, before or after you call it using RUN. RUN proc. //Procedure starts here PROCEDURE proc: //Procedure ends here END PROCEDURE. The procedure name is folowed by a colon sign telling u...
A procedure can have parameters of different kinds: input, output, input-output (bidirectional) and also some special types like temp-tables and datasets). In the run statement it's optional to declare INPUT (it's considered default) - all other directions must be specifically declared. A procedur...
Recursion is easy - RUN the procedure itself from inside the procedure. However if you recurse too far the stack will run out of space. A procedure calculation the factorial. PROCEDURE factorial: DEFINE INPUT PARAMETER piNum AS INTEGER NO-UNDO. DEFINE OUTPUT PARAMETER piFac AS INTEG...
The procedure has it's own scope. The outside scope will "bleed" into the procedure but not the other way arround. DEFINE VARIABLE i AS INTEGER NO-UNDO INIT 1. DEFINE VARIABLE j AS INTEGER NO-UNDO. PROCEDURE p: MESSAGE i VIEW-AS ALERT-BOX. // 1 MESSAGE j VIEW-AS AL...

Page 1 of 1