Why local variable “has no definition” when it is already defined in actions?
-
-
November 20, 2024 at 2:27 amfdtsaidSubscriber
In
scade language reference
, there is an example as following :
node StateMachine_1(bI1: bool)
returns (bO1: bool default = true; iO2: int16 default = 0; bO3: bool default = false)
let
automaton SM1
initial state ST1
unless if bI1 resume ST2;
sig sig1;
var iV1: int16;
let
iV1 = 10;
emit 'sig1;
bO1 = 'sig1;
iO2 = iV1 -> pre iO2 + 2;
telstate ST2
sig sig1;
var bV1: bool; // err: V1 has no definition
until if true do
let
emit 'sig1;
bV1 = 'sig1;
bO3 = bV1;
tel
restart ST1;
returns ..;
telWhen compile the program using kcg, error "V1 has no definition" occurs. But
V1
will be always defined in transition action every time entering stateST2
. How to understand this error? -
November 20, 2024 at 10:36 amBenjamin DescorpsAnsys Employee
Hello,
Indeed, definition of state2 is incorrect. The until clause is not put at the right place. Is here the correct piece of code:
state ST2sig sig1;var bV1: bool;letbV1 = 'sig1;bO3 = bV1;teluntil if true do emit 'sig1;restart ST1;We will fix the example in the Reference Manual in the next SCADE version.
Benjamin
-
- You must be logged in to reply to this topic.
-
1241
-
543
-
523
-
225
-
209
© 2024 Copyright ANSYS, Inc. All rights reserved.