Accessing local variable in C Icon

For general Flowcode discussion that does not belong in the other sections.
Post Reply
User avatar
p.erasmus
Posts: 434
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Accessing local variable in C Icon

Post 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 :)
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 988
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 106 times
Been thanked: 517 times

Re: Accessing local variable in C Icon

Post 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

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: Accessing local variable in C Icon

Post 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 ?
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 988
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 106 times
Been thanked: 517 times

Re: Accessing local variable in C Icon

Post 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

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: Accessing local variable in C Icon

Post by p.erasmus »

Thanks Martin

no so elegant :)
Regards Peter - QME Electronics

Post Reply