Migrating from IBM Informix 4gl to Genero BDL / 4GL programming topics |
IBM® Informix® 4GL (I4GL) is not very strict regarding function signature. With I4GL, you can, for example, define a function in module A that returns three values, and call that function in module B with a returning clause specifying two variables:
FUNCTION func() RETURN "abc", "def", "ghi" END FUNCTION
MAIN DEFINE v1, v2 VARCHAR(100) CALL func() RETURNING v1, v2 END MAIN
Program stopped at "main.4gl", line number 3. FORMS statement error number -1320. A function has not returned the correct number of values expected by the calling function.
$ fgllink -o prog.42x main.42m module_a.42m ERROR(-6200): Module 'main': The function module_a.func(0,3) will be called as func(0,2).
Similarly, I4GL does not detect an invalid number of parameters passed to a function defined in a different module:
FUNCTION func( p ) DEFINE p INTEGER DISPLAY p END FUNCTION
MAIN CALL func(1,2) END MAIN
Program stopped at "main.4gl", line number 2. FORMS statement error number -1318. A parameter count mismatch has occurred between the calling function and the called function.
$ fgllink -o prog.42x main.42m module_a.42m ERROR(-6200): Module 'main': The function module_a.func(1,0) will be called as func(2,0).
MAIN DEFINE v1, v2 VARCHAR(100) CALL func(1) RETURNING v1 DISPLAY v1 CALL func(2) RETURNING v1, v2 DISPLAY v1, v2 END MAIN FUNCTION func( n ) DEFINE n INTEGER IF n == 1 THEN RETURN "abc" ELSE RETURN "abc", "def" END IF END FUNCTION
However, this type of programming is not recommended.