Is there a way to work around the error that happens when trying to set a reference to 0 after it isn't needed or is invalid? Trying to do this in codesys >= V3.5.15 results in an error. See example below. Now I could great a GVL with a bunch of unset references, but I'd end up with a large amount of null types.
METHODFB_init : BOOLVAR_INPUTbInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start / cold start)bInCopyCode : BOOL; // if TRUE, the instance afterwards gets moved into the copy code (online change)refLamp : REFERENCETOFB_Lamp;byNewLevel : BYTE;END_VARIF(__ISVALIDREF(refLamp))THENTHIS^.refLampREF=refLamp;ELSETHIS^.refLampREF=0;END_IFTHIS^.byNewLevel :=byNewLevel;
ok, so I was playing around with some tests today and the code I was looking at I didn't actually try and build/run because I was missing libraries for it.
Turns out you can build and run
THIS^.refLampREF=0;
it is just the precomplier that complains about it. Is this a bug then in the precompiler?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to work around the error that happens when trying to set a reference to 0 after it isn't needed or is invalid? Trying to do this in codesys >= V3.5.15 results in an error. See example below. Now I could great a GVL with a bunch of unset references, but I'd end up with a large amount of null types.
ok, so I was playing around with some tests today and the code I was looking at I didn't actually try and build/run because I was missing libraries for it.
Turns out you can build and run
it is just the precomplier that complains about it. Is this a bug then in the precompiler?
Did you find out if this work?
yes, it works