Run a script file and control the flow

Interactive call

Mask window under menu item Select Input File:


Submenu Select Scriptfile:


Select a script file (*.fsl file) from the Open exist. File or Select ScriptFile


Call with start of FEMAG

Example of call in Linux:

xfemag64 scriptfile.fsl arg1 arg2 arg3

Example of call in Windows:

wfemagw64.exe scriptfile.fsl arg1 arg2 arg3

The additional arguments arg1, arg2, etc. are optional. In the script, these can be accessed as needed through the arg table.

FSL code fragment for accessing arguments:

Narg = table.getn(arg)
printf("Number of arguments %d", NARG)
for i=0,Narg do
 printf("Element %d of table: %s", i,arg[i])

Output of the above example:

Number of arguments 3
Element 0 of table: scriptfile.fsl
Element 1 of table: arg1
Element 2 of table: arg2
Element 3 of table: arg3

An argument of the FEMAG call to the left of the specified script file can be accessed with a negative index if necessary.


i = -1
printf("Element %d of table: %s",i,arg[i])


Element -1 of table: ./path_to_femag_binary/xfemag64

Influencing resource expenditure

Additional arguments can be used when calling FEMAG to suppress the appearance of the mask and graphics windows.

Example: suppress both windows via the -b switch:

xfemag64 -b scriptfile.fsl arg1 arg2 arg3

Example: suppress the mask window via the -g switch:

xfemag64 -g scriptfile.fsl arg1 arg2 arg3

DXF conversion: The -c switch creates a DXF file from the node-chain definitions of an FSL file:

xfemag64 -c scriptfile.fsl

Parameter verbosity

Sets the level of output during script execution in the


0 Keine Rückmeldung
x Mit Wert von x zunehmender Umfang der Rückmeldung


verbosity = 3     -- default level of feedback with additional hints regarding FSL usage
verbosity = 2     -- default level of feedback
verbosity = 1     -- supress informativ feedback except for errors and warnings

Controlling script execution

Parameter exit_on_end

Sets the behaviour after script execution.

true FEMAG will be abandoned after script execution
false FEMAG remains open for further interactive editing

Parameter exit_on_error

Sets the behaviour after an error during script

true FEMAG is abandoned after error
false FEMAG reports errors and remains open

Command: stop()

Stop script execution



stop()           -- End script execution prematurely


Command: error(text)

Cancels script execution with an error message.


Text Description of the error

Command: sleep(t)

Pauses script execution for a specified time t.


t Pause time in seconds



sleep(2)        -- Wait for 2 seconds