Initialize variables in GLOBAL PROC

Other discussions about CSPro
Forum rules
New release: CSPro 8.0
Post Reply
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Initialize variables in GLOBAL PROC

Post by htuser »

Dear CSPro Developer Team,
This is a long ago issue and it seem to be a compiler limitation...
string usern=Maketext ("%s",getusername());
string usern=getusername();
In CSPro Logic it's impossible to initialize variables with the result of functions...

Please, do you have some workaround?

Thanks in advance for your response.
G.VOLNY, a CSProuser from Haiti, since 2004
Gregory Martin
Posts: 1774
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Initialize variables in GLOBAL PROC

Post by Gregory Martin »

In the future we might support this, as it would be useful at times. The problem is we need to think through some of the challenges; for example:
function Func1()
    exit tonumber(invoke("Func2"));
end;

numeric v1 = Func1();

function Func2()
    exit v1;
end;
What would v1 be?

The rules for how stuff like this is evaluated would need to be thought through. For now, assigning initial values in the application preproc is a fairly simple process, though perhaps not as explicit/clear as what you are trying to do.
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Initialize variables in GLOBAL PROC

Post by htuser »

Hi Greg,
Thanks for your support.
What would v1 be?
This problem have been solved in several programming languages using technical such as forward declaration, among others.
https://www.geeksforgeeks.org/recursive-functions/
https://en.wikipedia.org/wiki/Forward_declaration
I rather think as you already mentioned it, this problem is regarding the one pass compiler limitation of CSPro Logic...

I need this because of, as you know, i'm thinking about ready to use packages, so i need more ways to do things dynamically.
For example, define dynamic paths global variables able to be used in syncs user defined functions etc.
Rather than having
string dataFolder = "..\main_application\data\";
i would use path namespace object to get it dynamically in the GLOBAL PROC.


Best,
G.VOLNY, a CSProuser from Haiti, since 2004
Post Reply