Tutorial by Examples

/* This function returns TRUE if input is the letter "b" and false otherwise */ FUNCTION isTheLetterB RETURNS LOGICAL (INPUT pcString AS CHARACTER): IF pcString = "B" THEN RETURN TRUE. ELSE RETURN FALSE. END FUNCTION. /* Calling the function with "b&qu...
A function can be forward declared, this is similar to specifications in a C header file. That way the compiler knows that a function will be made available later on. Without forward declarations the function MUST be declared before it's called in the code. The forward declaration consists of the...
/* This will popup a message-box saying "HELLO WORLD" */ FUNCTION cat RETURNS CHARACTER ( c AS CHARACTER, d AS CHARACTER): RETURN c + " " + d. END. MESSAGE cat("HELLO", "WORLD") VIEW-AS ALERT-BOX.
A function can have multiple return statements and they can be placed in different parts of the actual function. They all need to return the same data type though. FUNCTION returning DATE ( dat AS DATE): IF dat < TODAY THEN DO: DISPLAY "<". RETURN dat - 200. ...
A function can only return a single value but there's one way around that: the parameters are not limited to input parameters. You can declare INPUT, OUTPUT and INPUT-OUTPUT parameters. Unlike INPUT parameters you must specify OUTPUT or INPUT-OUTPUT before the parameters. Some coding conventions m...
See recursion A function can call itself and thereby recurse. FUNCTION factorial INTEGER (num AS INTEGER). IF num = 1 THEN RETURN 1. ELSE RETURN num * factorial(num - 1). END FUNCTION. DISPLAY factorial(5). With standard settings (startup parameter) the Pro...
Using DYNAMIC-FUNCTION or the CALL-object you can dynamically call functions. DEFINE VARIABLE posY AS INTEGER NO-UNDO. DEFINE VARIABLE posX AS INTEGER NO-UNDO. DEFINE VARIABLE OKkeys AS CHARACTER NO-UNDO INIT "QLDRUS". DEFINE VARIABLE Step AS INTEGER NO-...

Page 1 of 1