MDA related keywords (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:
%mdasession $ Open a replacement session
$ Replace PIM classes with their Win32 counterparts. In this example it is assumed
$ Win32 counterparts having the same name of PIMs plus the Win32 suffix, and
$ <<PSM Concept>> applied
%for %search ("", "Class", "PIM Concept")
%mdabind %c %to %search (%c:Name & "ForWin32", "Class", "PSM Concept")
%endfor
$ Now Win32 counterparts are iterated instead of PIMs
%for %search ("", "Class", "PIM Concept")
%m %red "My name is " & %c:Name $ Prints something like "TThreadForWin32"
%endfor
$ Original PIM classes are iterated as in the first %for above, due to %noreplace
%for %noreplace %search ("", "Class", "PIM Concept")
%m %red "My name is " & %c:Name $ Prints something like "TThread"
%endfor
%endmdasession $ Close the session, active replacements deleted
$ Now original PIM classes are iterated as in the first %for above
%for %search ("", "Class", "PIM Concept")
%m %red "My name is " & %c:Name $ Prints something like "TThread"
%endfor
%mdasession opens an object replacement session. Subsequent %mdabind A %to B statements record the replacement of A with B. Replacement actually happens when an object is about to become the current object, that is, in the context of %for loops.
If the object that is about to become current has a replacement recorded in the current session, the replacing object (the one specified as the second in %mdabind) will become current instead.
The %noreplace optional modifier of the %for statement disables automatic replacement of objects for that iteration.
Closing the session deletes all replacements created within the session.
Sessions can be nested: a nested session inherits all the replacements of the enclosing session and can add its own replacements. Closing the nested session only deletes the replacements defined within the nested session itself.
%openreplace is a synonym of %mdasession.
%closereplace is a synonym of %endmdasession
%replace <object1> %with <object2> is a synonym of %mdabind <object1> %to <object2>
%replace <string1> %with <string2> - that is using %replace with %string expressions instead of %object – records the replacement of string1 with string2 in the session. String replacement happens when a property is returned from an object.
Example:
%openreplace
%replace "Public" %with "Private"
%for %search ("", "Attribute")
$ The following line never prints "Public", because "Public" is replaced with "Private"
%m %blue "Returned Access is " & %c:Access
%endfor
%closereplace
String replacements belong to the session exactly like object replacements. String replacements also happen at substring level, that is, %replace "blic" %with "vate" would return object properties like "Puvate".
String replacements are case insensitive.