Procedure as Type, parameters

Hello,

Does anybody knows hot to get multiple parameters of function when it is TYPE.

What I mean, example:

ProcType    PROCEDURE(LONG p1, LONG p2, LONG p3),TYPE
Proc        PROCEDURE(ProcType)

How do I get parameters in Proc?

Proc PROCEDURE(ProcType __p1)
CODE
   ! What do type to get value of p1, p2 and p3???
   RETURN

In help there is example, but it is only when it is one parameter, and I think it is not correct. Since it is missing &=. Help example:

ToString     CLASS,TYPE
FilterProc     PROCEDURE (UNSIGNED idx),TYPE
Filter         PROCEDURE (FilterProc)
             END
...
ToString.Filter  PROCEDURE (FilterProc CurFilter)
 i        UNSIGNED,AUTO
CODE
 LOOP i = RECORDS (SELF.LQ) TO 1 BY -1
      SELF.CurFilter (i)
 END
      RETURN

Thank you for any help or suggestions.

You’re passed the procedure,
so you can call it
It hasn’t been called yet.
It’s up to you to call it with the necessary parameters

Proc PROCEDURE(ProcType __p1)
  CODE
 ! maybe a loop over something...
  __p1(  SharedScope:P1,   SharedScope:P2,  SharedScope:P3 )

Note: IIRC my tests show that inside of the ProcType implementation
you cannot use any side-effected data (that is stack based)
even if it seems like you should be able to
so you must pass in everything you need

If that’s more than a parameter or two then you should probably create a GROUP,TYPE
and pass it into the ProcType, or more generically a LONG xUserData
which could anything, including the address of a GROUP,TYPE

2 Likes

So, line SELF.CurFilter (i) is actually SELF.CurFilter(i), without space. It is calling a procedure.

Thank you, now it is much clearer.

Clarion allows you to add white space in a number of places
all of the following are treated identically by the compiler

SELF.CurFilter(i)
SELF.CurFilter( i )
SELF.CurFilter  (i)
CurrFilter( SELF, i )

Tests show that these do NOT compile
SELF .CurrFilter(i)
SELF. CurrFilter(i)

However if you have something like
SELF.NestedClass.MethodInNestedClass(i)
there you can write
SELF.NestedClass .MethodInNestedClass(i)
but not
SELF.NestedClass. MethodInNestedClass(i)
SELF.NestedClass . MethodInNestedClass(i)

1 Like