Remove this ad

Lead

Jun 5 17 1:19 PM

Tags : :

It appears that NL5 schematic variables are not available for use in the init() method of C-Code blocks.  My guess is because init() functions are executed before the variables are set as globals?
Quote    Reply   
Remove this ad
Remove this ad
avatar

nl5

Posts: 196 Site Admin

#1 [url]

Jun 5 17 1:40 PM

Schematic variables, as well as component parameters, are accessable in init() and main() functions of C-component as READ-ONLY. You cannot change them in the C-code.
You can read and change them in the script code only.

Quote    Reply   

#2 [url]

Jun 6 17 11:54 AM

Alexei,

I did a little more investigating, and I believe this is indeed a bug, but one that only occurs with C-Code in sub-circuits.

I created a very simply NL5 schematic consisting of a single variable and a single C-Code block with 1-output that is assigned to the variable in both the init() and main() functions.  This scehmatic simulates fine.

However, when I use this schematic as a sub-circuit in a schematic one level up, I get an error

X1.X1: Unknown name 'Var1'
X1.X1.Code, line 2: y1 = Var1;

 

Quote    Reply   
avatar

nl5

Posts: 196 Site Admin

#3 [url]

Jun 6 17 12:34 PM

I think (I did not test this though, but pretty sure), that C-code in the subcircuit will look at subcircuit schematic variable, not a "top" circuit.
If so, I'll put it into "to-do" list. But then there should be a way for C-code to have access to the subcirucit variables, to its parents, and so on, up to the "top" circuit...

Just tested it: yes, C-code sees a schematic variables of the circuit where it is located. In your case: the subciruit. 

Last Edited By: nl5 Jun 6 17 12:45 PM. Edited 2 times.

Quote    Reply   
Remove this ad

#6 [url]

Jun 7 17 9:48 AM

Bug fix confirmed.  Thanks!

Quote    Reply   
Remove this ad
Add Reply

Quick Reply

bbcode help