startup script
Submitted by robin_a on Tue, 02/28/2012 - 15:16
I've tried using a startup script but can't access the variables defined in the c file. I assume that i'm missing something from the syntax, as i can get vissim to throw an error if i miss the semicolon. I've tried float double or no type, but whatever i do the variable block in the vissim model returns 0. please can someone explain what i'm doing wrong,
Thanks
Robin.
I tried to upload my simple case but restrictive we b policy means i cant. Basically i have a file called var.c stored in the root of c: with the following contents:
float var1 = 10;
The vissim model references this (with the whole path) then i have a variable block which references var1. when i run vissim i get no error but the variable just returns 0.
Answers
-
Submitted by Anders89 on Tue, 02/28/2012 - 23:53.
Hi Robin,
Your problem is that you are using a VisSim variable block to reference a C variable. The VisSim variable block only defines and references other VisSim variables, not variables from the C namespace. You must use a block that uses the C interpreter like a const block or expression block to access the C name space. The const block will evaluate a C expression once at sim start, the expression block will be evaluated at each time step.0 -
Submitted by robin_a on Thu, 03/08/2012 - 20:03.
thanks for your help, I now have the script file working ....sort of. It only works with 1 constant definition. I had hoped to define a script file with all constants in the model. e.g.
const1 = 1; const2 = 2; const3 = 3; etc.
When i try this, only const1 is valid. Is this multiple definition possible, i can't imagine that i can only define 1 constant in a script file. Have I got the syntax wrong?
Thanks for you help
Robin
0 -
Submitted by Anders89 on Thu, 03/08/2012 - 22:13.
You need to use a data type to declare your variables like so:
int const1=1; double const2 = 2.2; float const3 = 2*pi;0