Table of Contents

Parsing (JavaScript)

You can write a parser in JavaScript that will be used to parse a file and to fill automatically the form of a process

here is an example of javascript program for the machine Sentech SI500


here is an nextralFluor1JS of javascript program for the machine Nextral Fluor 1

How to script

Your javascript code will be loaded as a function. This function has access to several parameters :

Your parser function is expected to return an object which looks like the following :

{
	key : value,
	key : value,
	...
	key : value,
	
	"operation-samples": [
		{
			key : value,
			key : value,
			...
			key : value
		},
		{...},
		...
	]
}

Where each key is the name in the database of the value (as defined in the template), and its value is the value parsed from the file.

You can add the attribute operation-samples if you want to set sample related parameters. operation-samples must be an array, and that array must contain objects following the previous key : value rules. each object in the array will create a new sample tab in the form, allowing the user to select which sample was used.

If the parser encounter something that isn't right (wrong file supplied, wrong type of operation, etc), you can throw an error. That error will then be displayed to the user in a red alert box (if your parser itself contains errors, these will also be displayed in that box, allowing you to debug it).

if (operationType!="process")
	{
		throw new Error("operationType must be process");
	}

To interact with the user you can also use the confirm, alert, and the prompt functions.

var test = prompt (" Test de valeur " );

var yn = confirm (" Voulez vous continuer ?");