As of version 2.18, DataPower 2 now supports script files, which can be used by external applications to call DataPower functions directly.
The script file is just a plain text file with a special file type or extension:
Acorn: Filetype is DPscript (&C2B)
PC: File extension is ".dps"
Mac: Creator is 'DP20', filetype 'DPS '
The script commands are the same as those used in normal DataPower scripts (ie. those attached to buttons or in the global scripts (File/Edit Scripts on the menu)), plus the following command is used to 'associate' the script with a DataPower database:
Note that this is a compile-time command which tells the script compiler to look in the global scripts of that particular database file for any function or procedure calls. So, if you have a user-defined function in the global scripts for that file, you can call it within the script provided you've put the SetCurrentDB command in first. The filename can be relative to the location of the script file itself, or it can be an absolute path in 'native' format, if you want.
Another new command is used by the script to open and bring to the front a particular database file:
This command is actually quite different from SetCurrentDB, even though it looks similar! SetCurrentWin loads the given file (if it isn't already loaded), and brings the window to the front. Any script that wants to make things happen in the "front-end" (ie. user interface) side of DataPower will need to issue this command to get the relevant database loaded and made current.
Note: SetCurrentDB doesn't take brackets, while SetCurrentWin insists on them. Think of the difference as indicating that the argument to SetCurrentDB is a literal string (compile-time), while the argument to SetCurrentWin is an expression (run-time).
After issuing this command, CurrentDB, CurrentRecset etc. will point to this file, and you can use commands like Layout() to move to a different layout.
As an example, a script that opens a customer address file, goes to the customer details layout and then displays the record for a given customer might look like this:
SetCurrentDB "Cust/dp1" SetCurrentWin("Cust/dp1") Layout("Customer Details") CurrentRecset.Seek("Eric Smith")
The idea is that the external program that wants to show this database record would create the script file itself with the required customer name in it, then run the script using Filer_Run (Acorn) or ShellExecute (PC).
Note that the Seek() command can take multiple arguments: the argument list is used to perform an indexed search on the relevant query or table to locate the required record, so the number of arguments depends on what sort order has been given to the layout.
The sort order can be set either by setting the clustering key of the base table, or by generating a new query with the required sort order (to do this, perform the sort while in Edit Layout mode - this will create a new query as a sorted version of the original table).
Back to DataPower 2 Documentation
Back to DataPower 2 Home Page