CVAR

Global C-script variable
Inputs(0)
Parameters(1) p1
Default p1=0,
Text1 Variable
Text2
Select from Components/Blocks/Cscript&Expression
Function In the CVAR block you define a global variable which is declared in all C-scripts defined by all the CSCRIPT blocks. In the C-Script block you can define C code to create your own blocks. The C code is interpreted, so no external compiler is required.
Inside the C-script block local variables are declared. Global variables are defined in the block CVAR.
Special Example of a simple adder:

In a CVAR block the global variable iGlobal is defined at text1. Its initial value is defined as parameter p1
The value defined in the block CVAR is declared global in the entire scope of each C-script.
Defined in the CVAR block: (int iGlobal=42;)Text1 = iGlobal
p1 = 42


Defined in the Cscript block:
int iCount;
int y;

main()
  {
  iCount=1;
  //the value of the global value is added to y
  y=a+iCount+iGlobal;
  //the value of the local varaiable iCount is passed to the global variable iGlobal
  iGlobal=iCount;
  return(y);
  }


The value of the local variable iCount is finally passed into the global variable iGlobal fro mthe CVAR block. The output of the CVAR block is equal to the value of the global variable.
Since ANSI C is case-sensitive, lowercase variables and uppercase variables are not equal, so a<>A and iCount<>icount.

See the tutorial on the C-Script for more details on the syntax of the C-script.
© 2018 CASPOC, All rights reserved. Home   |   Terms and Conditions   |   Legal   |   Export Compliance   |   Privacy Policy   |   Site Map