- Print
- PDF
When you write or modify Lasernet scripting code, remember the following advice.
Supply Parameter Values as the Expected Data Type
The Lasernet 11 script engine expects method calls to pass parameters as the expected data type.
For example, job.setJobInfo expects two String parameters. To set the value of a JobInfo called Name to 42:
Suitable:
job.setJobInfo("name", "42")Not suitable:
job.setJobInfo("name", 42)
Perform concatenation only with data of the correct type:
Suitable:
job.setJobInfo("name", job.getJobInfo("anotherName") + "42")Not suitable:
job.setJobInfo("name", job.getJobInfo("anotherName") + 42)
In some situations, you might need to manipulate values as one particular data type, but you must ultimately use the right data type for each parameter when you make the method call. The following example adds two numbers but ultimately supplies the resulting value as a String (as the method expects).
job.setJobInfo("name", (parseInt(job.getJobInfo("anotherName")) + 42).toString())
If you want to set a JobInfo with a ByteArray value, use the .setJobInfoBinary method.
Do Not Pass Parameter Values to Convert.toString()
If you need to convert a value to a String, do not use Convert.toString() with a parameter.
Instead, use the following methods:
Convert.numberToString(value: Number, format: string [optional])Convert.dateToString(value: Date, format: string [optional])