MATRIXx

cancel
Showing results for 
Search instead for 
Did you mean: 

Is ther any way to prevent implicit data typing in the block scriptd

System build /autocode  implicitly define the type of variables that are not defined by the user in a block scripts based on  the value assigned to them.
 
As an example, if there is no type definition for the variable A in a block script,  depending which of the following lines appears first in the block script the type of variable will be defined differently in the autocoded model:
 
A = 1; -> RT_INTEGER A;
A = 1.0;-> RT_FLOAT A;
 
This behavior can cause undesirable result in certain situations.
 
Is there any way to flag the variables in the block scripts with no type definition during analyze  / autocode? or alternatively, disable the implicit type definition such that any variable without explicit type definition in the block scripts will result to an error during analyze  / autocode.
 
Thanks
0 Kudos
Message 1 of 2
(7,321 Views)
Hi Farshid,

It is the default behavior to pick up the type from the first assignment. However one can explicitly type variables as seen in the BlockScript user guide page 2-7. For instance, one can declare

Inputs: U;
Outputs: Y;
Parameters: (UBrk, YBrk);
Float U, Y(:);
Float UBrk(:), YBrk(Y.size,:);

This forces all the parameters and local variables to Float.
Let me know if this helps, there is not a way to turn off implicit typing, just a way to explicitly type.

Richard

Richard

Field Sales Engineer, New Jersey
National Instruments
0 Kudos
Message 2 of 2
(7,304 Views)