ActiveX Script - Javascript thows errors

Support for DataSlave

Moderators: Tom, ian

ActiveX Script - Javascript thows errors

Postby UncleZ3n » Tue Aug 03, 2010 12:54 pm

Im evaluating v2.2.2 (on WinXPSP3)
One of our requirements is to clean up data, such as phone numbers (e.g. remove non-integers, check for leading zeros etc)
I dont see an easy way to do this using the objects supplied, but I could easily achieve it using a script.
Im not particularly familiar with VB Script, but I am with Javascript.
If I select Javascript from the ActiveX Script listbox, the example code shown is not javascript.
E.g. Shown is:
' Comments
Function Transform(Input1, Input2, Output1)

' TODO: add transformation code here
Transform = True

End Function

Whereas if it was Javascript you would see:

// Comments
function Transform(Input1, Input2) {

...some code here...

return Output1;

or similar.
So I set about changing it and whatever I do I cant make it work.
e.g. here is my simple test code:
function MyFunction(Input){
var Output=0;
return Output;

When I click "Test" I get "Error whilst executing script: (line 0, column 0)

So I set about writing some similar code in VB Script:
Function Transform(Input1, Output1)
Dim Output1
End Function

This also thows an error.

My conclusion is that this feature doesnt work.
Posts: 1
Joined: Mon Aug 02, 2010 8:03 am

Re: ActiveX Script - Javascript thows errors

Postby ian » Wed Aug 04, 2010 7:01 am

Before going to the use of script you may want to consider the use of the following Transform functions:

Trim, Left Trim and Right Trim: Removing spaces, tabs and the like from stirngs
Remove: Removing all instances of one or more characters from a string
Left, Left Delete, Right, Right Delete , Mid and Delete: removing characters from strings

Please feel free to send us some sample data and a description of what you need to do.

The Script objects do work and we have many customers who have used this facility. I am sorry that you are having difficulty. Perhaps you could send us a copy of your data and your map and we will have a look. You can also download samples of .NET scripts from the our web site:

I hope these will help.
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Re: ActiveX Script - Javascript thows errors

Postby ian » Fri Aug 27, 2010 2:52 pm

Please find a sample map attached that show both a very simple Validation JavaScript and Transform script. Place the map in the sample folder:


The application will automatically add Inputs and Outputs to the functions as necessary (for example you drag a new input to the function), but this only seems to work after the initial script function has been defined. If adding your own JavaScrip please change the script language to JavaScript and then cut and paste the relevant function from below. Then add your logic. The comments describe the usage.

Code: Select all
// Validate Script Function
// Used to validate one or more input values.
// Return True if values are valid, otherwise False.
function Validate(value)
   // TODO: add validation code here
   return true;

Code: Select all
// Transform Script Function
// Used to create new output values from input values.
// Inputs and Outputs are ScriptVariable objects, use
// syntax: Output1.Value = Input1.Value etc.
// Return true if function executes correctly, otherwise false.
function Transform(Input1, Output1)
   // TODO: add transformation code here
   return true;
JavaScript samples
(4.77 KiB) Downloaded 1153 times
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests