Why do old CDK tools fail to work on newer TD versions
You have to use the command line parameter "-MTX" with apps using CDK.
Gupta introduced this with TD 2005 PTF1, TD 2005.1 and TD 3.1 PTF4.
Place the -MTX parameter behind all other parameters in the user tool settings :
"$Outline $MainWindow $File -MTX"
How to merge an application using CDK
The following sample shows how to merge an application and save it back to disk.
First include cdk.apl.
The next function performs the task, it merges Test.apt and saves it as Test_merged.apt:
Function: MergeAndSaveApplication Local variables cdkApplication: uApplication Actions If uApplication.InitFromFile( "c:\\Test.apt" ) Call SalOutlineMergeIncludes( uApplication.GetOutline( ) ) Call uApplication.SaveOutlineAsText( "c:\\Test_merged.apt", FALSE ) Call uApplication.CloseApp( )
Here you can download a sample:
ISSUE WITH TD 6.0 up to TD 6.2 >>
When the merged file is saved and it contains items in section External Assemblies (Symbol Imports)
you will get errors during loading of the merged file.
To fix this, you will have to remove the symbol imports after merging and before saving back to disk.
A sample how to do this is also part of the archive which can be downloaded above.
How to get object attributes at runtime
You can query the attributes of GUI objects like datafields, forms, pictures etc at runtime.
Everything you can set at design time using the attribute inspector can be queried programatically.
(even when running as executable).
All elements in your sources have an equivalent in the CDK, represented as a outline item or type ID.
For instance, a datafield is represented as the CDK constant CDK_IT_DataField having a value of 0x0004.
A datafield has a Justification attribute (left, center, right) represented as CDK_IT_Justify with value 0x008E.
Have a look in the library CDK.apl (which is installed in your TD installation folder when you have specified CDK during installation).
All possible objects, types, variables, attributes etc etc can be found as represented constants in the Constants/System section.
Using some undocumented functions, you can query attributes of GUI objects at runtime using the CDK constant values.
You don't need to include CDK.apl in your project, you may just use the constant values of the wanted CDK items.
For instance, to get the type of a dialog (Modal, System Modal or Modeless) do the following :
Set nCurrentOutline = SalOutlineCurrent( ) Set nFormItemHandle = SalOutlineItemOfWindow( hWndForm ) If nFormItemHandle > 0 ! You can use 0x0044 instead of the CDK_IT_DialogType constant Call SalOutlineItemTypeText( nCurrentOutline, nFormItemHandle, CDK_IT_DialogType, FALSE, sAttributeValue ) ! ! sAttributeValue equals "Modal", "System Modal" or "Modeless"
Another example to get the justification of a datafield (Left, Center or Right):
Set nCurrentOutline = SalOutlineCurrent( ) Set nDatafieldItemHandle = SalOutlineItemOfWindow( dfCustomer ) If nDatafieldItemHandle > 0 ! You can use 0x008E instead of the CDK_IT_Justify constant Call SalOutlineItemTypeText( nCurrentOutline, nDatafieldItemHandle, CDK_IT_Justify, FALSE, sAttributeValue ) ! ! sAttributeValue equals "Left", "Center" or "Right"
Here you can download a sample:
How to generate a GUID
The CDK has a standard function to generate GUID strings.
A GUID is a Globally Unique Identifier, used in applications for references using a unique number.
(MS Com system uses it for identifying ActiveX/COM objects).
For example :
Include the library CDK.apl, there you will find this external function:
sGUID = CDKRegenerateGUID( )
Here you can download a sample:
List of features CDK does not offer
The following list contains features which CDK does NOT supply.
This could save you some time in searching wanted functionality which is known not to be present.
- Compiling applications
- Suppressing the load information window (when opening a TD source from CDK)
TODO: add more items to this list. When others know other not supported features, please add this to the list.
[TD 6.0] Support for External Assemblies section in CDK
A new outline section was introduced in TD6.0 : External Assemblies.
There Symbol Imports are located.
Unfortunately up to TD 6.0 SP5 this new section is not yet supported by the CDK for default.
To be able to enumerate/find/get/delete items in this new section a custom CDK library is created.
It adds some new methods to the cdkApplication object.
When TD supports the section out-of-the-box, this custom CDK library is obsolete.
You can download the custom CDK library for TD6 here:
[TD 6.3] Extended CDK library with missing items
With TD 6.3 come new GUI objects and the new language feature "constructors/destructors".
Unfortunately, the RTM release of TD 6.3 has no changes to CDK, so all these new items can not be accessed using CDK applications out-of-the-box.
For this reason an extended library has been created which will contain the missing CDK constants and classes.
Hopefully Gupta will add these functionalities in the next service packs for TD 6.3.
For now, only the functionality for constructors/destructors is present in the extended library.
Also the missing CDK constants for ribbon.
You can download the extended CDK library for TD 6.3 here:
Using CDK to set an UDV (class) as return type
When looking at the CDK features, there seems not to be a function to set a return type for functions other than the basic datatypes (number, boolean etc).
So how to programatically set an UDV (class) return type?
For instance, have a look at this function which should be created using the CDK:
Function: TestFunction Description: Returns cfcBase: Parameters Static Variables Local variables cfcBase: uBaseObject Actions Set uBaseObject.sivName = 'John' Return uBaseObject
The function returns an object of type cfcBase.
The complete CDK code would be this:
! Add the function Call uApplication.AddFunction( "TestFunction", uFunction ) ! ! Set the return type to return objects of type cfcBase. Do this in two steps. Call uFunction.AddObjectTo( CDK_IT_Returns, CDK_IT_ClassObject, "", uVariable ) Call uVariable.SetObjectClass( "cfcBase" ) ! ! Next lines add an object to the variables section, sets the UDV attribute value and returns the object. Call uFunction.AddLocalClassVariable( "cfcBase", "uBaseObject" ) Call uFunction.GetActions( uActionBlock ) Call uActionBlock.Indent( ) Call uActionBlock.InsertAfter( "Set uBaseObject.sivName = 'John'" ) Call uActionBlock.InsertAfter( "Return uBaseObject" )
The above sample can be downloaded here: