Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > SDL script for generating code > SDL script extensions for TDK > Variable assignment and use within an expression (SDL script)
  
Variable assignment and use within an expression (SDL script)
This topic applies to TDK SDL script extensions. For more information, see Overview of SDL script extensions for TDK (SDL script).
SDL Script Extensions for TDK:
%localstring DestVar
%localstring SourceVar = "a string"
DestVar = SourceVar & " another string"
%extern AnotherVar $ Reference to a global defined elsewhere (e.g. another module)
$ Prevents Tdk from triggering a warning (no –w) or an error (-w)
In TDK it is easier to define, set and get variable values. As explained in the following example, %setlocalvar and %getlocalvar are no more needed. For assigning variable B to a variable A, just do as follows:
A = B
Similarly for expressions on the right side:
A = B + 1
NOTE: %setvar, %setlocalvar, %getvar and %getlocalvar can still be used.
Declaring variables can be with or without surrounding quotes:
%localstring MyVar $ Without quotes
%localstring "Another" $ With quotes
Expressions can be used for assigning a variable directly on declaration:
%string A = "a string"
Global variables declared in module X can be referenced from within module Y by specifying them as %extern:
Module X:
%string VarOne
Module Y:
%extern VarOne
VarOne = "my value"
Declaring extern variables as %extern is optional when the TDK translator is invoked without the -w option (= warnings as errors). In this case TDK prints a warning. When the –w option is specified, declaring extern variables as %extern is mandatory, otherwise TDK generates an error and the build process is stopped.