|
|
Configuration manager
Data translate functions
In the Functions section of your configuration
manager you can define and write functions to run between retrieving data and
writing it to its destination. See Source
tables and mapping.
The code of functions is writting in Java scripting
or Visual Basic scripting and run using the standard Microsoft script
support. Script support is standard available on Windows 2000, Windows
98/2 and Me. If you don't have scripting available on your machine you
can download it for free from the Microsoft site http://msdn.microsoft.com/scripting/default.htm?/scripting/
scriptcontrol/default.htm.
Script files are created in the configuration
manager of PRODBX and stored in the dispatcher
directory. At startup of a connection
client, the scripts needed on that client are distributed to that client.
Go to the Functions section in the navigation
tree-view to create or edit functions. As an example you will get the next
screen.
- Translate function id: The name
(limited to 50 characters) you give this function. This id will populate the
translate function listbox in the source
tables and mapping section.
- Function description: Short
description (max 255 characters) of the function.
- Parameter 1 required: enable this
when your function uses parameter 1 (string parameter). Parameters are
populated in the source
tables and mapping section. Enabling parameters over here only influence
the behaviour of populating the parameters in source table and mappings.
During execution parameters are always read from the configuration and
passed to the function script, whether you've enabled it over here or not.
This might become important if you want to pass a NULL string (empty string)
to a parameter.
- Parameter 2 required: as parameter 1
- Parameter 3 required: as parameter 1
but numeric parameter
- Parameter 4 required: as parameter 1
but numeric parameter
- Function uses stack as input:
enabling this, PRODBX will pass the contents of the STACK to the second
input variable of the script. This requires an additional parameter in the
function header (see later). Remember: values are passed to the STACK by
using the reserved word STACK in the destination field name of the source
tables and mapping section, and by controlling the field handling
sequence.
- Reject function: When using a reject
function PRODBX will stop building the destination record belonging to the
record id currently in interpretation, whenever the function returns the
literal 'True'. If the function does not return 'True' you still can pass a
value to be written to the destination record. You may use as many reject
functions as needed, the first one that returns True will reject the
destination record. Rejecting a destination record, means that no SQL
statement will be passed to the connection
client handling the destination connection.
Scripting
When creating a new script follow the input in
the sequence outlined below. The system will default you a function template.
|
Function <Function
name in script>(InputValue,Parameter1,Parameter2,Parameter3,Parameter4) |
|
|
|
your
script |
|
|
|
<Function
name in script> = <output value> |
|
|
End function |
|
|
function <Function
name in script>(InputValue,Parameter1,Parameter2,Parameter3,Parameter4) |
|
|
|
{ |
|
|
|
your
script |
|
|
|
return
<output value> |
|
|
|
} |
|
|
Function <Function
name in script>(InputValue,Stack,Parameter1,Parameter2,Parameter3,Parameter4) |
|
|
|
your
script |
|
|
|
<Function
name in script> = <output value> |
|
|
End function |
|
|
function <Function
name in script>(InputValue,Stack,Parameter1,Parameter2,Parameter3,Parameter4) |
|
|
|
{ |
|
|
|
your
script |
|
|
|
return
<output value> |
|
|
|
} |
|
Testing your script
Use the test script area in the function screen
to test your script.
- Input Value: Value passed to the
first input variable
- Stack Value: in case your script
supports the stack, this is the value passed to the second input variable
- Parameter 1...4: the corresponding
values for the parameters
Press the 'test script' button to run the
script with the values entered. The result of the script will be shown through a
popup message.
Example: with our TRANSLATE_EXCEL function we
use a excel sheet that cross-references numeric wine classes to the
corresponding wine description.
Entering the following information in the test
area:
Results in a popup message:
Remark: when your script is using registered
objects, make sure you have those objects also registered on the machine where
the connection client is running on.
|
|