Page 1 of 1

Accessing local variable in C Icon

Posted: Thu Nov 03, 2022 6:20 am
by p.erasmus
Hi all,

I know that accessing a global variable or a flowcode macro in a C icon the prefix FCV or FCM is used however searching the wiki I found no reference to acessing a local variable such as ".myvariable"

Is this in anyway possible Thanks for helping out :)

Re: Accessing local variable in C Icon

Posted: Thu Nov 03, 2022 7:07 am
by mnfisher
FCL_VARIABLENAME

It's also possible to use macros - FCM_MacroName (params..); - Note that the macro's name isn't capitalised whereas variable names are.

Martin

Re: Accessing local variable in C Icon

Posted: Thu Nov 03, 2022 7:25 am
by p.erasmus
Thanks Martin
apprecaite your help !
another questiuon is there away to make alocal variable static in FC i.a.w that it retains its value when going out of the macro and when retuning to it ?

Re: Accessing local variable in C Icon

Posted: Thu Nov 03, 2022 7:48 am
by mnfisher
Probably that would require a cheat....

Declare the variable in a C block and then assign to a local - and at the end of the macro 're-assign to the 'static'

Start of macro:

Code: Select all

static int x = 1;
FCL_VAR = x;
Then end of macro:

Code: Select all

x = FCL_VAR:
Martin

Re: Accessing local variable in C Icon

Posted: Thu Nov 03, 2022 7:52 am
by p.erasmus
Thanks Martin

no so elegant :)