VAR_INST and FB_Init #241
-
Hey there,
This keeps the scope for all the variables clean and small. Works great! Until I try to pass one variable into another during instantiation, like so
While this form works fine in the main body of a function block, as well as VAR_INPUT, VAR_OUTPUT, VAR and VAR_STAT in a method, it doesn't work with VAR_INST. The compiler complains that "Identifier 'fbFoo' not defined". I have two theories. Either the instantiation order of VAR_INST is strange, or the renaming the variables get by the compiler isn't respected by the compiler in this particular layout. But I don't know if there is anything I can do about it. One thing I have found does work is putting tl;dr |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Same problem here, not sure why the compiler has this behaviour. |
Beta Was this translation helpful? Give feedback.
-
Pretty much all of my tests are multi-cycle, ya. My hope is to keep the definitions of the objects in VAR_INST, so that its easy to read. My declaration area currently looks something like this most of the time
So each step of the test has inputs and expected outputs and a name, stuff like that. Makes defining tests very straightforward and easy to write/alter/read. Once all these things end up in the main block its clunkier. Obviously all of my complaints are style-related more than anything. I'll try this in 4026 and see what happens |
Beta Was this translation helpful? Give feedback.
-
Well, it doesn't work in 4026 either, but has a dedicated compiler error now |
Beta Was this translation helpful? Give feedback.
-
So in summary, unless someone pops up with a secret angle, you cannot instantiate variables in VAR_INST using local variables in the same header. This works everywhere else, but not in a method's VAR_INST. Work arounds that I know of (that largely don't meet my
|
Beta Was this translation helpful? Give feedback.
-
Thanks @ColonelPanic-Dev for the great summary! Thanks! |
Beta Was this translation helpful? Give feedback.
So in summary, unless someone pops up with a secret angle, you cannot instantiate variables in VAR_INST using local variables in the same header. This works everywhere else, but not in a method's VAR_INST.
Work arounds that I know of (that largely don't meet my
needswants in 4024):