Page 1 of 1

Function pointers issues

Posted: September 9th, 2021, 6:21 am
by htuser
Dear CSPro developpement Team,
Months ago, Greg help me with a workaround to bypass the multi-pass issue of the CSPro logic compiler by using function pointers.
However, today, the first time that i'm trying them, there's an issue.
a) I have three pff objects functions to add, modify and verify cases using a menu.
Function choixQuestionnaire(function EntryPffIpb_add(),function EntryPffIpb_modification(),function EntryPffIpb_verify())
   
if choixPrincipal()=1 then
        numeric
opQuestionnaire=choixMenuQuest.show("SVP, veuillez choisir");
       
if opQuestionnaire=1 then
           
codeAcceuil();
            EntryPffIpb_add();
       
endif;
       
if opQuestionnaire=2 then
           
codeAcceuil();
            EntryPffIpb_modification();
       
endif;
       
if opQuestionnaire=2 then
           
codeAcceuil();
            EntryPffIpb_verify();
       
endif;
   
endif;
end;
It display no errors.

b) However, when i call this in a proc:
if $<>"" then
choixPrincipal();
choixQuestionnaire(EntryPffIpb_add(),EntryPffIpb_modification(), EntryPffIpb_verify());
endif
It display errors: ERROR(57):
Functions called recursively or via function references can only contain local variables of type: numeric, string, and list
Please, how to solve this?
Thanks in advance!

Re: Function pointers issues

Posted: September 9th, 2021, 11:52 am
by Gregory Martin
The error tells you the limitation with CSPro: "function references can only contain local variables of type: numeric, string, and list."

Based on your code, I assume that you are creating a local PFF object within those functions. You will have to make them global objects. Instead of:
function EntryPffIpb_add()

   
pff entry_pff;
Do:
pff entryAddPff;

function EntryPffIpb_add()
Best programming standards are to not use global variables unless necessary, but you will have to if you want to get around this limitation.

Re: Function pointers issues

Posted: September 9th, 2021, 2:41 pm
by htuser
Thanks Greg for your incredible help and support.
I already send to application to the developer team with others issues. Hope a day, CSPro will have a multiple pass compiler and support user created class and object. This will solve theses issues.

Best,