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 name in script: The name you give the function in the script. This will also be the variable set on the output when using VB scripting.
  • Script filename (without path): the name you give to the script file saved in the dispatcher's directory. VB scripts usually have extension .vbs and java scripts .js. This is not mandatory, but it gives you the correct icons at file level.
  • Script type: VBscript (Visual Basic) or Jscript (Java). After selecting the type, and the script window is still empty, the script window will default you a function template.
  • Script window: in here you write the actual script. If you are more familiar with editors and want to use these, press ok in this function screen, save the configuration and exit the configuration manager. Go to the dispatcher's directory where you can edit your script using your text editor.

    The function header is very strict. You must supply the correct number of input variables and use the correct function structure:

    • No stack VB:
Function <Function name in script>(InputValue,Parameter1,Parameter2,Parameter3,Parameter4)
your script
<Function name in script> = <output value>
End function
  • No stack Java:
function <Function name in script>(InputValue,Parameter1,Parameter2,Parameter3,Parameter4)
{
your script
return <output value>
}
  • Stack VB:
Function <Function name in script>(InputValue,Stack,Parameter1,Parameter2,Parameter3,Parameter4)
your script
<Function name in script> = <output value>
End function
  • Stack Java:
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.