pTAL Conversion Guide

Procedures, Subprocedures, and Procedure
Pointers
pTAL Conversion Guide527302-002
16-12
Declaring PROCPTRs in Structures
prev-identifier
is the identifier of a field at the same level as procptr in the same structure.
You use an index to reference elements of array s1 in Example 16-3 on page 16-12:
CALL s1[3].f(3.0e1);
Example 16-5 on page 16-12 uses the template structure s2 in Example 16-4 on
page 16-12. pTAL allocates space for PROCPTR f. pTAL does not allocate space for
PROCPTRs g or h because they redefine PROCPTR f. PROCPTRs f, g, and h are
the same except for the type of the parameter passed to the procedure.
Example 16-3. Array of PROCPTRs
STRUCT s1 [0:9];
BEGIN
REAL PROCPTR f(x);
REAL x;
END PROCPTR;
END;
Example 16-4. Template Structure With PROCPTR Fields
STRUCT s2 (*);
BEGIN
REAL PROCPTR f(x);
REAL x;
END PROCPTR;
REAL PROCPTR g(x);
INT x;
END PROCPTR = f;
REAL PROCPTR h(x);
FIXED x;
END PROCPTR = g;
END;
Example 16-5. Structure That Uses Template Structure in Example 16-4
LITERAL type_real, type_int, type_fixed;
STRUCT s(s2);
REAL my_real;
INT my_index := type_int;
CASE my_index OF
BEGIN
type_real -> my_real := s.f(3.0E1);
type_int -> my_real := s.g(3);
type_fixed -> my_real := s.h(3F);
END;