User Tools

Site Tools


omitted_return_omitted_parameters_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== OMITTED (return omitted parameters) ====== Previous pageReturn to chapter overviewNext page
OMITTED (position)
(name)

blk2blue.jpg

OMITTED Tests for unpassed parameters.
position An integer constant or variable which specifies the ordinal parameter position to test.
name The name of a procedure parameter.

The OMITTED procedure tests whether a parameter of a PROCEDURE was actually passed. The return value is one (true) if the parameter in the specified position was omitted. The return value is zero (false) if the parameter was passed. Any position past the last parameter passed is considered omitted.

For the purpose of the OMITTED procedure, a parameter may only be omitted if its data type is enclosed in angle brackets ( <; > ) in the PROCEDURE prototype . Although parameters prototyped with default values may be omitted from the procedure call, the default value is actually passed, and the OMITTED procedure therefore returns false (0) for those parameters.

All CLASS methods have an implicit first parameter which is always passed–the CLASS name. This means that OMITTED(1) will always return false for a CLASS method. Any actual parameters passed to the method are numbered beginning with two (2). Therefore, to test whether two actual parameters to a CLASS method are passed means you must test positions two (2) and three (3).

The name of a procedure parameter can now be used in the call to the OMITTED() function.The OMITTED function now checks that its parameter is an identifier that matches the name of any procedure parameter it is called from. Otherwise, it treats a passed value as an expression that returns a parameter ordinal number. The identifier passed to OMITTED is taken as is, i.e., if the identifier is an EQUATE that names a label that happens to match the name of some procedure parameter, the compiler does not use the equated label, but uses the EQUATE as the literal procedure parameter.

Return Data Type: LONG

Example:

MAP

SomeProc  PROCEDURE(STRING,<;LONG>,<;STRING>)                      !Procedure prototype

END

MyClass   CLASS

MyMethod   PROCEDURE(STRING Field1,<;LONG Date>,<;STRING Field3>)  !Method prototype

         END

CODE

SomeProc(Field1,,Field3) !For this statement:

                         !OMITTED(1) returns 0, OMITTED(2) returns 1

                         !OMITTED(3) returns 0, OMITTED(4) returns 1

SomeProc PROCEDURE(Field1,Date,Field3)

CODE

IF OMITTED(2)            !If date parameter was omitted

 Date = TODAY()          !substitute the system date

END

MyClass.MyMethod  PROCEDURE(STRING Field1,<;LONG Date>,<;STRING Field3>)  

CODE

IF OMITTED(3)            !If date parameter was omitted

 Date = TODAY()          !substitute the system date

END

*Example of using OMITTED with a Procedure parameter:        PROGRAM        MAP          PP(LONG),LONG,TYPE        END T       CLASS F         PROCEDURE (<;LONG>,<;QUEUE>,<;FILE>,<;KEY>,<;BLOB>,<;T>, |                     <;WINDOW>,<;?>,<;PP>),LONG,PROC        END  CODE  T.F() T.F PROCEDURE (<;LONG L>,<;QUEUE Q>,<;FILE F>,<;KEY K>,<;BLOB B>,<;T TT>, |               <;WINDOW W>,<;? A>,<;PP P>) Res  LONG,AUTO  CODE  Res  = 0  Res += OMITTED (SELF)  Res += OMITTED (L)  Res += OMITTED (Q)  Res += OMITTED (F)  Res += OMITTED (K)  Res += OMITTED (B)  Res += OMITTED (TT)  Res += OMITTED (W)  Res += OMITTED (A)  Res += OMITTED (P)  RETURN Res See Also:**

Prototype Parameter Lists (Passing Arrays)

omitted_return_omitted_parameters_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)