Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » setting a static variable in structured text
setting a static variable in structured text [message #1729287] Tue, 12 April 2016 15:16 Go to next message
Wolfgang Trischnigg is currently offline Wolfgang TrischniggFriend
Messages: 24
Registered: April 2016
Junior Member
Hello to all,

how can I define a static variable in ST like in c++:

for examle in c++ I have:
static int state=0;


Where can I define this in 4DIAC?

Best,
Wolfgang
Re: setting a static variable in structured text [message #1729288 is a reply to message #1729287] Tue, 12 April 2016 15:18 Go to previous messageGo to next message
Martin Melik-Merkumians is currently offline Martin Melik-MerkumiansFriend
Messages: 33
Registered: March 2016
Member
That question is quite ambgious, as the static keyword has several different effects in C/C++, depending on where the static keyword is used, e.g. in the file scope, class scope, or function/method scope.

Which behaviour do you want to emulate?

Regards,
Martin
Re: setting a static variable in structured text [message #1729293 is a reply to message #1729288] Tue, 12 April 2016 15:36 Go to previous messageGo to next message
Wolfgang Trischnigg is currently offline Wolfgang TrischniggFriend
Messages: 24
Registered: April 2016
Junior Member
I will only set an initial value.

This value must be hold until a function changes it.

For example:
static int initialvalue=0;

then
IF x>0 THEN
OUTPUT:=TRUE;
initialvalue:=1;
END_IF;


Re: setting a static variable in structured text [message #1729296 is a reply to message #1729293] Tue, 12 April 2016 16:39 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 523
Registered: January 2014
Senior Member
I have to agree with martin. For which scope you needed. On FB level or on Global scope. Do you need a static variable for all FBs? This will be not achievable in IEC 61499 as FBs may be located in different devices.
If this initial value is per FB instance you can use an internal variable for it. You can even give internal veriable initial values.
Previous Topic:Handling Hardware Interrupts
Next Topic:Running and Debugging single BFB
Goto Forum:
  


Current Time: Thu May 24 21:24:31 GMT 2018

Powered by FUDForum. Page generated in 0.02103 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top