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 > %object data type, %current and %null keywords (SDL script)
  
%object data type, %current and %null keywords (SDL script)
That is, a %list of zero or one elements only, and %current keyword
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:
%object A
%localobject B
A = %current
A = %c $ %c is a shortcut for %current
B = A
%m %red %t (A) $ %t (object) returns a readable string describing the object
%m %red %ct $ %ct is equivalent to %t (%c)
In TDK it is possible to define %object and %localobject variables. A %object variable is like a %list, but it can contain only zero or one element. In turn, %object variables introduce the ability to capture and use object pointers for calling methods and setting or getting attributes. For more information, see Class concept (SDL script).
The current element being visited by the generator is identified with the keyword %current, that is, a read-only variable of type %object. %c is a synonym of %current. The operator %t (<object expr>) returns a user readable string expression describing the object argument. %ct is like %t (%c). These instructions are useful while debugging for printing information about an object.
Objects, lists and %null
Objects are just lists limited to zero or one element, so it is possible to include an object in a list as follows:
%list TheList
%object O
O = %current
TheList = TheList + O $ includes O in the list if not already there
Objects are a list of zero or one element. So the following code prints the Name attribute of the current object two times, separated by a blank:
%object O
O = %current
%for O $ this loop will be iterated once
%message O.Name & " " & %custom "Name" $ just the same twice: O is the current object
%endfor
For testing if an object is set or emptying an object, the %null constant has been defined. It corresponds to an empty object:
%object O
O = %null
%for O
%message "Never executed"
%endfor
%if O == %null %then
%message "This is always executed"
%endif