You are on page 1of 135

Advanced Scripting Guide SpeedMark V3.

4 (Beta)

TROTEC VERTRIEBS UND


PRODUKTIONS GmbH
Linzer Strae 156
A 4600 Wels
AUSTRIA
Tel.: ++43/7242/239-0
Fax: ++43/7242/239-7380
E-mail: trotec@troteclaser.com
www.troteclaser.com

TROTEC accepts no liability for any direct or indirect damage arising from the application or use of
the products, circuits or software described herein. The operating instructions must be read
carefully and observed before the equipment is commissioned.
TROTEC reserves the right to amend any product described herein without prior notice.

This document and all diagrams remain the intellectual property of


Trotec Produktions- u. Vertriebs GmbH.
The entire document has been provided to the user for personal use only. This document may not
be reproduced or passed to a third party without our written approval. Any infringement will be
prosecuted under criminal law.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

2 / 135

Contents

1 Contents .......................................................................................................................................................... 3
2 Introduction..................................................................................................................................................... 7
2.1 Intended users of advanced scripting....................................................................................................... 7
2.2 Licensing ...................................................................................................................................................... 7
2.3 Disclaimer..................................................................................................................................................... 7
3 General architecture....................................................................................................................................... 8
3.1 Scripting element integration and execution flow ................................................................................. 10
3.2 Scripted RunScreen integration and execution flow ............................................................................. 11
4 First script tutorials ...................................................................................................................................... 12
4.1 Hello world tutorial .................................................................................................................................... 13
4.2 Script form tutorial .................................................................................................................................... 14
4.3 Script creator ............................................................................................................................................. 16
4.4 Script wizard .............................................................................................................................................. 17
4.5 Scripted RunScreen .................................................................................................................................. 19
5 Integrated Development Environment ....................................................................................................... 22
5.1 Explanations of terms or abbreviations.................................................................................................. 23
5.2 Menu and toolbar functions ..................................................................................................................... 23
5.2.1 Scripting menu...................................................................................................................................... 23
5.2.2 Edit menu.............................................................................................................................................. 23
5.2.3 View menu ............................................................................................................................................ 24
5.2.4 Start menu ............................................................................................................................................ 24
5.2.5 Tools menu ........................................................................................................................................... 24
5.3 Units to organize scripts........................................................................................................................... 25
5.4 Code view ................................................................................................................................................... 26
5.4.1 Script code tool ..................................................................................................................................... 27
5.5 Design view ................................................................................................................................................ 28
5.5.1 Design controls bars ............................................................................................................................. 29
5.5.2 Properties and events window.............................................................................................................. 29
5.5.3 Designer tools....................................................................................................................................... 30
5.5.4 Designer options................................................................................................................................... 31
5.6 Special IDE features for Scripting elements........................................................................................... 32
5.6.1 General element options ...................................................................................................................... 32
5.7 Special IDE features for Scripted RunScreen......................................................................................... 32
6 VBScript Language features ....................................................................................................................... 33
6.1 VBScript Syntax......................................................................................................................................... 33
6.1.1 Basic syntax.......................................................................................................................................... 33
6.1.2 Unit script structure............................................................................................................................... 33
6.1.3 Comments ............................................................................................................................................ 33
6.1.4 Naming of identifiers ............................................................................................................................. 34
6.1.5 Assign statements ................................................................................................................................ 34
6.1.6 Variables............................................................................................................................................... 34

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

3 / 135

6.1.7 Variable data types ............................................................................................................................... 35


6.1.8 Character strings .................................................................................................................................. 35
6.1.9 Indexes and arrays ............................................................................................................................... 35
6.1.10 New statement.................................................................................................................................... 36
6.1.11 If statements ....................................................................................................................................... 36
6.1.12 While statements ................................................................................................................................ 36
6.1.13 Loop statements ................................................................................................................................. 37
6.1.14 For statements.................................................................................................................................... 37
6.1.15 Select case statements ...................................................................................................................... 38
6.1.16 Function and sub declaration ............................................................................................................. 38
6.1.17 Try catch finally................................................................................................................................... 40
6.1.18 Variant arrays ..................................................................................................................................... 40
6.2 Calling dll functions .................................................................................................................................. 41
6.2.1 General ................................................................................................................................................. 41
6.2.2 Syntax................................................................................................................................................... 41
6.2.3 Supported types.................................................................................................................................... 41
6.3 Using COM-Objects................................................................................................................................... 42
6.4 Advanced language features.................................................................................................................... 43
6.4.1 Using forms in scripts ........................................................................................................................... 43
6.4.2 Declaring classes ................................................................................................................................. 44
7 SpeedMark scripting object model ............................................................................................................. 45
7.1 Object model .............................................................................................................................................. 45
7.2 Class hierarchy .......................................................................................................................................... 46
7.2.1 Explanations of terms or abbreviations ................................................................................................ 46
7.2.2 Application object and associated properties ....................................................................................... 46
7.2.3 Application object components............................................................................................................. 47
7.2.4 Laser system component collections.................................................................................................... 48
7.2.5 Component collections and associated component classes ................................................................ 49
7.2.6 Program classes ................................................................................................................................... 50
7.3 Class Reference......................................................................................................................................... 51
7.3.1 SpeedMark application class................................................................................................................ 51
7.3.2 TScProject ............................................................................................................................................ 52
7.3.3 TScProgram.......................................................................................................................................... 53
7.3.4 TScGraphicElements............................................................................................................................ 55
7.3.5 TScGraphicElement ............................................................................................................................. 55
7.3.6 TScRect2D ........................................................................................................................................... 56
7.3.7 TScTextGraphicElement ...................................................................................................................... 56
7.3.8 TScFileGraphicElement........................................................................................................................ 57
7.3.9 TScProgramVariables .......................................................................................................................... 57
7.3.10 TScLogging......................................................................................................................................... 58
7.3.11 TScErrorHandler................................................................................................................................. 60
7.3.12 TScExecutionErrors............................................................................................................................ 60
7.3.13 TScSystemErrors ............................................................................................................................... 60
7.3.14 TScConfiguration ................................................................................................................................ 60
7.3.15 TScDataStore ..................................................................................................................................... 61
7.3.16 TDataStoreList.................................................................................................................................... 62
7.3.17 TScRunScreen ................................................................................................................................... 63
7.3.18 TScLaserSystem ................................................................................................................................ 64
7.3.19 TScBorderMarking.............................................................................................................................. 64
7.3.20 Components collections ..................................................................................................................... 65
7.3.21 TScCustomComponent ...................................................................................................................... 65
7.3.22 TScIOControllerComponent ............................................................................................................... 66
7.3.23 TScLaserControllerComponent .......................................................................................................... 66
7.3.24 TScAxisControllerComponent ............................................................................................................ 67
7.3.25 TScSerialPortComponent................................................................................................................... 67

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

4 / 135

7.3.26 TScTCPComponent ........................................................................................................................... 68


7.3.27 TScCustomVirtualComponent ............................................................................................................ 68
7.3.28 TScVirtualInputIOComponent............................................................................................................. 68
7.3.29 TScVirtualOutputIOComponent.......................................................................................................... 68
7.3.30 TScExhaustComponent...................................................................................................................... 69
8 Scripted run screen tutorial......................................................................................................................... 70
8.1 Scope of this tutorial ................................................................................................................................. 70
8.2 Building the marking project.................................................................................................................... 71
8.2.1 Main program........................................................................................................................................ 71
8.2.2 Layout 1 ................................................................................................................................................ 72
8.2.3 Layout 2 ................................................................................................................................................ 73
8.2.4 Layout 3 ................................................................................................................................................ 73
8.2.5 Layout IDs............................................................................................................................................ 74
8.3 Building the scripted run screen ............................................................................................................. 75
8.3.1 File data structure ................................................................................................................................. 75
8.3.2 Choosing a template............................................................................................................................. 75
8.3.3 Changing the main form ....................................................................................................................... 76
8.3.4 Creating a folder structure unit ............................................................................................................. 76
8.3.5 Creating a data reading class unit ........................................................................................................ 77
8.3.6 Creating a layout updating unit............................................................................................................. 79
8.3.7 Combining the data unit with the main form ......................................................................................... 80
8.3.8 Implementing key input handling .......................................................................................................... 81
8.3.9 Updating the preview............................................................................................................................ 82
8.4 Automating the startup ............................................................................................................................. 83
9 Debugging of scripts.................................................................................................................................... 84
9.1 Debugging in general ................................................................................................................................ 84
9.1.1 Setting breakpoints on code lines......................................................................................................... 84
9.1.2 Creating variable watches .................................................................................................................... 84
9.1.3 Debugging shortcuts............................................................................................................................. 84
10 Class and function reference .................................................................................................................... 85
10.1 Explanations of terms or abbreviations................................................................................................ 85
10.2 Default base class ................................................................................................................................... 85
10.3 Default function and classes.................................................................................................................. 86
10.3.1 Default system functions .................................................................................................................... 86
10.3.2 Default Visual Basic related functions ................................................................................................ 89
10.4 Functions and classes by units ............................................................................................................. 92
10.4.1 Unit: Classes....................................................................................................................................... 92
10.4.2 Unit: Clipbrd ........................................................................................................................................ 96
10.4.3 Unit: DateUtils..................................................................................................................................... 97
10.4.4 Unit: IniFiles ...................................................................................................................................... 104
10.4.5 Unit: Math ......................................................................................................................................... 106
10.4.6 Unit: Registry .................................................................................................................................... 110
10.4.7 Unit: StrUtils...................................................................................................................................... 113
10.4.8 Unit: SysUtils .................................................................................................................................... 115
10.4.9 Unit: TextFileList ............................................................................................................................... 125
10.4.10 Unit: Unicode .................................................................................................................................. 126
10.4.11 Unit: Variants .................................................................................................................................. 128
11 Appendix ................................................................................................................................................... 131
11.1 Function Comparison Simple vs. Advanced Scripting ..................................................................... 131
11.1.1 General functions ............................................................................................................................. 131

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

5 / 135

11.1.2 Mathematic functions........................................................................................................................ 131


11.1.3 Type conversion functions................................................................................................................ 132
11.1.4 Text functions ................................................................................................................................... 132
11.1.5 Time and Date Functions ................................................................................................................. 132
11.1.6 File Handling Functions .................................................................................................................... 133
11.1.7 Execution Error Functions ................................................................................................................ 133
11.1.8 Graphic manipulation........................................................................................................................ 133
11.1.9 DataStore.......................................................................................................................................... 134
11.1.10 Laser statements (LaserController) ................................................................................................ 134
11.1.11 Galvo control statements (LaserController).................................................................................... 134
11.1.12 Extended IOs (LaserController) ..................................................................................................... 135

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

6 / 135

Introduction

Advanced scripting is the extension of existing SpeedMark scripting with the possibility to fully customize and
automate laser work routine based on the successful SpeedMark software package.
The main advantages are:

Building custom forms and dialogs


Accessing windows DLLs (Dynamic Link Libraries)
Integration of available COM objects (e.g. Microsoft Excel COM objects)
Simple and well known VBScript programming language
Integrated within SpeedMark, no additional software necessary

Advanced scripting supports scripting inside of a SpeedMark project as well as building Scripted RunScreen
to fully automate and customize SpeedMark appearance.

2.1 Intended users of advanced scripting


To use advanced scripting properly, users need to have knowledge in the usage of SpeedMark
1
software as well as programming knowledge in VBScript, Visual Basic or any other higher
scripting/programming language.

2.2 Licensing
Trotec SpeedMark Advanced Scripting will be delivered with a license key for usage. If you have not received
the appropriate key please contact the dealer of your laser system. The license code can be registered after
starting SpeedMark via menu point Help  Software registration.

2.3 Disclaimer
Unless this part of the software is beta, some changes may arise in the next version which requires
the adoption of existing scripts.
Trotec is not responsible for any possible damage done due to the use of advanced scripting.

The marking process may only be conducted using fault-free machines (please also refer to the user
manual for the TROTEC laser system you have purchased).
Any other application of the equipment is considered contrary to intended use. The manufacturer
accepts no liability for any personal injury and/or material damage arising as a result of this.
The equipment may only be operated, serviced and commissioned by individuals familiar with the
intended use and potential risks of the machine!
Failing to observe the operating, service and maintenance regulations provided by the manufacturer
in this user manual exempts the manufacture from any liability in the event of a fault.

For further information see documents SpeedMark User Guide and SpeedMark Scripting Reference shipped
with SpeedMark setup.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

7 / 135

General architecture

Advanced scripting supports two general concepts of customizing and automating SpeedMark:

Scripting elements
these are scripts which are directly placed in the flow chart of SpeedMark marking programs.
Scripted RunScreen
these are scripts which run upon SpeedMark with the ability to control certain functions of SpeedMark
like executing projects.

Both concepts work with Visual Basic Script language support.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

8 / 135

Comparing scripting elements and scripted run screen

Scripting Element

13/02/2013

Scripted RunScreen

A scripting element is directly placed in a SpeedMark marking program


A Scripted RunScreen is created on its own
A scripting element is executed by SpeedMark
A Scripted RunScreen executes SpeedMark functions

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

9 / 135

3.1 Scripting element integration and execution flow

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

10 / 135

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

Dynamic Link Libraries

COM objects (e.g.Microsoft Excel)

COM objects (e.g.Microsoft Excel)

Windows Operating System

Serial Port Controller

Axis-Controller

Laser-Controller

3.2 Scripted RunScreen integration and execution flow

11 / 135

First script tutorials


2

This tutorial chapter states some easy to create scripts to show the basic scripting concepts in practice . The
shown scripting elements are placed on the advanced scripting toolbar. Within default SpeedMark
installations this toolbar is on the left side, the last toolbar.

To run these tutorials, a valid installation of SpeedMark 3.4 (or above) and a valid advanced scripting
license key is necessary.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

12 / 135

4.1 Hello world tutorial


Tutorial step
Create a new scripting
element

Description

Place the element in the


flow chart

Open the properties window


by double clicking the new
scripting element

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

13 / 135

Add the codeline


MsgBox(Hello world!)
Close the property window
by with button OK.

Execute the SpeedMark


project with the created
script by clicking execute or
pressing F12

4.2 Script form tutorial


Tutorial step
Create a new scripting form
element

Description

Place the element in the


flow chart

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

14 / 135

Open the properties window


by double clicking the new
scripting element
Switch from unit MainUnit
to FormMain.
Place an edit field and a
button by drag and drop on
the form.

Your scripting window


should look now like this.
Close the property window
by with button OK.

Execute the SpeedMark


project with the created
script by clicking execute or
pressing F12

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

15 / 135

4.3 Script creator


Tutorial step
Create a new script creator
element

Description

Place the element in the


flow chart and select the
second creator ComboBox
selection dialog

Close the dialog by clicking


the button Finish

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

16 / 135

Your flow chart should look


now like this.

Execute the SpeedMark


project with the created
script by clicking execute or
pressing F12
You can view the created
script code by double
clicking the element.

4.4 Script wizard


Tutorial step
Create a new template
wizard element

Description

Place the element in the


flow chart and select the
Hello World template by
clicking Create script

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

17 / 135

The properties window


opens automatically.
Switch from unit MainUnit
to FormMain.
Close the property window
by with button OK.

Your flow chart should look


now like this.

Execute the SpeedMark


project with the created
script by clicking execute or
pressing F12

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

18 / 135

4.5 Scripted RunScreen


Tutorial step
Create a new RunScreen by
using an existing template.

Description

Select the Classic


RunScreen implementation
v2 template by clicking
Create script

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

19 / 135

The Scripted RunScreen


window opens
automatically.
Switch from unit MainUnit
to FormMain.
Close the window by
clicking the cross right
upper side of the window.

When the save as dialogs


opens, select an
appropriate folder and
filename to store the
Scripted RunScreen.
Save the created script by
clicking the save button.

To start the script manually,


go to menu point Tools 
Scripted RunScreen 
Execute

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

20 / 135

Select the newly created file


and click the open button

The Scripted RunScreen


executes and can be used
now.
Close the window by
clicking the cross right
upper side of the window.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

21 / 135

Integrated Development Environment

SpeedMark contains a ready to use IDE for writing scripts and designing forms as well as for scripting
elements and scripted run screen scripts.
The chapter general will explain how to use the IDE. The chapters scripting elements and scripted run screen
will point out some small differences between these two scripting types.
The IDE basically consists of the following areas:

Main menu
Toolbars
3
Page control with all the different units in the script
Window for editing the drawing and programming elements (Code, Design)
Window for editing control properties

Units are a tool to split a script into several areas. See also 5.3 Units to organize scripts on page 25.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

22 / 135

5.1 Explanations of terms or abbreviations


Definition
IDE
Unit

Description
Integrated development environment
4
A unit is the smallest entity of scripting . A unit can be a code unit which
contains only code lines in text format. A unit can also be a form unit which
contains of a code view with code line in text format and a design view which
contains all drawing information of the form.
A script is a package of different units
Are controls like buttons, edit fields, which are used to draw forms in
design view.

Script
Design control

5.2 Menu and toolbar functions


The main menu is displayed at the top of the IDE.

The most often used functions can be accessed via the toolbars using the mouse .

5.2.1 Scripting menu


Menu item
Add new unit
Add new form
Apply changes
Save (incl. SpeedMark
project)
Change unit name
Remove unit
Print

Symbol

Description
Adds a new scripting unit to the script
Adds a new form unit to the script
Apply changes
Saves this script together with the SpeedMark project
Changes the unit name to a new name
Removes the unit from this script
Prints the unit code

5.2.2 Edit menu


Menu item
Undo
Redo
Cut
Copy
Paste
Select all
Delete
Find
Replace
Increase indent
Decrease indent
4
5

Symbol

Shortcut
Ctrl+Z
Ctrl+Y
Ctrl+X
Ctrl+C
Ctrl+V
Ctrl+A
Del
Ctrl+F
Ctrl+R

Description
Undoes the last operation
Redoes the last undoed operation
Cuts text or designcontrols to clipboard
Copies text or design controls to clipboard
Pastes text or controls from clipboard
Selects all (text or design controls
Deletes text or design control
Finds a text within the selected unit
Replaces text within the selected unit
Increases the indent of a selected text
Decreases the indent of a selected text

See also 5.3 Units to organize scripts on page 25.


Further information on script code can be found in chapter 5.4.1 Script code tool on page 27.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

23 / 135

Align to grid
Bring to front
Send to back
Align elements
Adjust size
Tab order

These menu points are to position and size various controls on


6
the drawing pane .

5.2.3 View menu


Menu item
View watch
SpeedMark variables

Symbol

Scripting toolbar
Edit toolbar
Debug toolbar
Script code toolbar

Description
7
Shows or hides the watch window
8
Editing SpeedMark variables
Toggles scripting toolbar
Toggles edit toolbar
Toggles debug toolbar
Toggles script code toolbar

5.2.4 Start menu


Menu item
Compile

Symbol

Execute
Reset
Pause
Show execution
point
Step over
Trace into
Execute until
return
Run to line
Toggle breakpoint
Add watch

Shortcut

Description
Compiles the current script

F9

Executes the current script


Resets the current script execution
Pauses the current script execution
Shows the current execution point of the running script

Shift+F9

F8
F7
Shift+F11

Executes and steps over the current code line


Traces into the current code line if possible
Executes all code lines until the next return statement

F4
F5
Ctrl+F5

Executes all code lines until the line of the cursor


Toggles breakpoints on code lines
Adds a new entry to the watch list

5.2.5 Tools menu


Menu item
Export script unit
Export all script units
Export packed script
Import script unit
Import all script units
Import packed script
Create script code template
Designer options

Description
Exports the current unit to text file(s)
Exports all script units to text files(s)
Exports all script units to a packed script file
Imports a script unit into this script
Imports all script units
Imports a packed script
9
Creates a script code template
10
Opens the designer options dialog

For further information see 5.5.3 Designer tools on page 30.


For further information see 9.1.2 Creating variable watches on page 84
8
This menu point is not available in scripted run screen
9
See also 5.4.1 Script code tool on page 27
10
See also 5.5.4 Designer options on page 31
7

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

24 / 135

5.3 Units to organize scripts


A Script contains one or more units. These units can either be
simple code units or form units.

Script

You can select the different units from a script by clicking the tabs
in the unit bar.

Unit 2 (Form)

Within the scripting IDE it is possible to select, create, rename,


delete, export and import units.

Unit1 (Code)

Units are used to organize the code within one script. This helps
to get a better overview or to reuse certain units in other units.

To create, rename and delete units, use the following menu points:
Create a code unit
Create a form unit
Rename a unit
Delete a unit
Export a unit
Import a unit

13/02/2013

Scripting  Add new unit


Scripting  Add new form
Scripting  Change unit name
Scripting  Remove unit
Tools  Export script unit
Tools  Import script unit

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

25 / 135

5.4 Code view


11

Within the code view of a unit you can write VBScript code .

Code view feature


Code completion with Ctrl+Space

Description
When pressing
Ctrl+Space a window
opens which shows
available functions,
procedures, constants,

Code completion by pressing .


after a variable

When
pressing .
after a class
variable a
window opens
which shows
available
methods and
properties of this class.

11

Find a complete reference on VBScript in chapter 6 VBScript Language features on page 33

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

26 / 135

Context menu

The context menu offers functions


like undo, redo, copy, cut, paste
and select all.

Find
Replace
Increase indent
Decrease indent
Print

: Ctrl+F or Edit  Find


: Ctrl+R or Edit  Replace
: Toolbar or Edit  Increase indent (of selected text)
: Toolbar or Edit  Decrease indent (of selected text)
: Prints the unit code

5.4.1 Script code tool


With the script code tool in the toolbar it is possible to quickly insert
often used code fragments. Just position the cursor on the place to
insert and then select a code fragment from the combo box.
The following code fragments are currently shipped within the setup:

13/02/2013

Number
01
02
03
04
05
06
07
08
09
10
11

Name
If then else (single line)
If then else
If elseif else
For
While
Do loop until
Do until loop
Select case
Sub
Sub param
Function

12
13
14
15
16
17
18

Function param
Sub public
Sub private
Try finally
Try catch
Try catch finally
Variable types

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

27 / 135

5.5 Design view


Within the design view of a unit you can draw forms. Design controls are placed by drag and drop on the
form.

Design view feature


Design control drag and drop
Design control double click
Context menu

Designer tools

12

Designer options

12
13

13

Description
Places controls on the form
Creates a main event for this control and switches to the code view of
this unit
By default the design view doesnt
offer any context menu, but some
controls have special options
which are accessed via context
menu.

Supports features like bring to front, send to back, align elements, adjust
size and setting tab order.
Tools  Designer options

Further information can be found in 5.5.3 Designer tools on page 30.


See also 5.5.4 Designer options on page 31.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

28 / 135

5.5.1 Design controls bars


The design controls bars offer various controls to be placed on a form.
Standard controls like buttons and
edit fields.
Additional controls like BitButton
and images.
Win32 controls like the page
control.
Dialog controls like open file dialog.

Unicode controls for handling


unicode texts

5.5.2 Properties and events window


The properties and events window
allows editing the various settings of
the different design control types.
This includes properties like the
height of the control as well as
defining an OnClick event.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

29 / 135

5.5.3 Designer tools


To help building forms the following designer tools are supported by
the IDE:

Align to grid
This option aligns all selected design controls to the grid.

Bring to front
This option redefines the order of controls which are lying on each
other and brings the selected control to front.

Send to back
This option redefines the order of controls which are lying on each
other and brings the selected control to the back.

Align elements
The option align elements opens a window which offers several
methods to align multiple controls with each other.

Adjust size
With the adjust size dialog it is possible to
equal the size of multiple selected design
controls.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

30 / 135

Tab order
The tab order dialog allows controlling and changing the current
14
tab order of the various controls in a simple way .

5.5.4 Designer options


The designer options are settings to control the behaviour of the design
view drawing pane.

This includes features like:


Color settings
Grid settings
Grab settings
Hint info settings

14

It is also possible to set the tab order via the specific tab order property in the properties window.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

31 / 135

5.6 Special IDE features for Scripting elements


Menu item
Apply changes

Symbol

Save (incl. SpeedMark


project)
Export packed script

Description
Apply changes, to the scripting element (nothing is saved to hard
disk, only in memory)
Saves this script together with the whole SpeedMark project (in
this case everything is saved to hard disk)
Exports the whole script as a packed file

SpeedMark variables

Editing SpeedMark variables

5.6.1 General element options


For scripted elements it is additionally possible to set
the general settings as for all other SpeedMark
elements.
This includes caption, note/comment as well as
breakpoint and activity.

5.7 Special IDE features for Scripted RunScreen


Menu item
Save
Save as

13/02/2013

Symbol

Description
Saves changes to hard disk
Asks the user for a new file name and saves this new file to hard
disk

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

32 / 135

VBScript Language features

6.1 VBScript Syntax


6.1.1 Basic syntax
Current Basic syntax supports:
sub .. end and function .. end declarations
byref and dim directives
if .. then .. else .. end constructor
for .. to .. step .. next constructor
do .. while .. loop and do .. loop .. while constructors
do .. until .. loop and do .. loop .. until constructors
^ , * , / , and , + , - , or , <> , >=, <= , = , > , < , div , mod , xor , shl , shr operators
try .. catch .. end and try .. finally .blocks
select case .. end select constructor
array constructors (x:=[ 1, 2, 3 ];)
exit and return statement
access to object properties and methods ( ObjectName.SubObject.Property )

6.1.2 Unit script structure


Script structure is made of two major blocks:
function and sub declarations
main block
Both are optional, but at least one should be present in the unit script code.
SUB DoSomething
CallSomething
END SUB
CallSomethingElse

Example Script 1
FUNCTION MyFunction1
MyFunction = "Ok!"
END FUNCTION
FUNCTION MyFunction2
return "Ok!"
END FUNCTION

Example Script 2
Like in normal basic, statements in a single line can be separated by ":" character.

6.1.3 Comments
Comments can be inserted inside script. You can use ' chars or REM. Comment will finish at the end of line.
' This is a comment before ShowMessage
ShowMessage("Ok")
REM This is another comment
ShowMessage("More ok!")
' And this is a comment
' with two lines
ShowMessage("End of okays")

Comment examples

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

33 / 135

6.1.4 Naming of identifiers


Identifier names in script (variable names, function and procedure names, etc.) follow the most common rules
in basic:

Identifiers should begin with a character (a..z or A..Z), or '_', and


can be followed by alphanumeric chars or '_' char.
Cannot contain any other character or spaces

VarName
_Some
V1A2

Valid identifiers
2Var
My Name
Some-more
This,is,not,valid

Some invalid identifiers

6.1.5 Assign statements


Assign statements (assign a value or expression result to a variable or object property) are built using "=".
MyVar = 2
Button.Caption = "This " + "is ok."

Assignment examples

6.1.6 Variables
There is no need to declare variable types in script. Thus, you declare variable just using DIM directive and its
name.
SUB Msg
DIM S
S = "Hello world!"
ShowMessage(S)
END SUB

Example 1
DIM A
A = 0
A = A+1
ShowMessage(A)

Example 2
You can also declare global variables as private or public using the following syntax:
PRIVATE A
PUBLIC B
B = 0
A = B + 1
ShowMessage(A)

Example 3
Variable declared with DIM statement are public by default. Private variables are not accessible from other
script units. Variables can be default initialized with the following syntax
DIM A = "Hello world"
DIM B As Integer = 5

Example 4

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

34 / 135

6.1.7 Variable data types


Integer
Char
String
PChar
Class
PWideChar
Currency
Interface
Longint
Longword
Byte
Word
Double
DateTime

Boolean
Extended
Pointer
Object
WideChar
AnsiString
Variant
WideString
Cardinal
Single
Shortint
Smallint
Real
TObject (means all kind of classes)

6.1.8 Character strings


Strings (sequence of characters) are declared in basic using double quote (") character.
A = "This is a text"
Str = "Text "+"concat"
Str = "Text " & 1 & "concat"

String example

6.1.9 Indexes and arrays


Strings, arrays and array properties can be indexed using "[" and "]" chars. For example, if Str is a string
variable, the expression Str[3] returns the third character in the string denoted by Str, while Str[I + 1] returns
the character immediately after the one indexed by I.
MyChar = MyStr[2]
MyStr[1] = "A"
MyArray[1,2] = 1530
Lines.Strings[2] = "Some text"

Index examples
VBScript supports array constructors and variant arrays. To construct an array, use
"[" and "]" chars. You can construct multi-index array nesting array constructors. You can then access arrays
using indexes.
If the array is a multi-index array, then separate the indexes by using ",".
If the variable is a variant array, VBScript automatically support indexing of that variable. A variable is a
variant array if it was assigned using an array constructor, or if it is a direct reference to a SpeedMark system
variable which is a variant array or if it was created by using the VarArrayCreate procedure.
Arrays in unit scripts are 0-based.
NewArray = [ 2,4,6,8 ]
Num = NewArray[1] //Num receives "4"
MultiArray = [ ["green","red","blue"] , ["apple","orange","lemon"] ]
Str = MultiArray[0,2] //Str receives 'blue'
MultiArray[1,1] = "new orange"

Array examples

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

35 / 135

6.1.10 New statement


Scripting provides the "new" statement for creating class objects.
MyLabel = new TLabel(Form1)
MyFont = new TFont

New examples
If the constructor receives parameters, you can pass the parameters in parenthesis, like the TLabel example
above.

6.1.11 If statements
There are two forms of if statement:

if...then..end if
if...then...else..end if

Like normal basic, if the if expression is true, the statements are executed. If there is else part and expression
is false, statements after else are executed.
IF J <> 0 THEN Result = I/J END IF
IF J = 0 THEN Exit ELSE Result = I/J END IF
IF J <> 0 THEN
Result = I/J
Count = Count + 1
ELSE
Done = True
END IF

If examples
If the IF statement is in a single line, you don't need to finish it with END IF:
IF J <> 0 THEN Result = I/J
IF J = 0 THEN Exit ELSE Result = I/J

Single line if examples


Scripting also supports subsequent if statements by using elseif
if J < 0
return
ELSEIF J
return
ELSE
return
END IF

then
-1
= 0 then
0
1

Elseif example

6.1.12 While statements


A while statement is used to repeat statements, while a control condition (expression) is evaluated as true.
The control condition is evaluated before the statements. Hence, if the control condition is false at the first
iteration, the statement sequence is never executed. The while statement executes its constituent statement
repeatedly, testing expression before each iteration. As long as expression returns True, execution continues.
WHILE (Data[I] <> X) I = I + 1 END WHILE

Example 1

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

36 / 135

WHILE (I > 0)
IF Odd(I) THEN Z = Z * X END IF
X = Sqr(X)
END WHILE

Example 2
WHILE (not Eof(InputFile))
Readln(InputFile, Line)
Process(Line)
END WHILE

Example 3

6.1.13 Loop statements


Scripting supports loop statements. The syntax is:
DO
DO
DO
DO

WHILE expr statements LOOP


UNTIL expr statements LOOP
statements LOOP WHILE expr
statement LOOP UNTIL expr

Statements will be executed WHILE expr is true, or UNTIL expr is true. if expr is before statements, then the
control condition will be tested before iteration. Otherwise, control condition will be tested after iteration.
Examples:
DO
K = I mod J
I = J
J = K
LOOP UNTIL J = 0

Example 1
DO UNTIL I >= 0
Write("Enter a value (0..9): ")
Readln(I)
LOOP

Example 2
DO
K = I mod J
I = J
J = K
LOOP WHILE J <> 0

Example 3
DO WHILE I < 0
Write("Enter a value (0..9): ")
Readln(I)
LOOP

Example 4

6.1.14 For statements


Scripting supports for statements with the following syntax:
FOR counter = initialValue TO finalValue STEP stepValue statements NEXT.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

37 / 135

For statement set counter to initialValue, repeats execution of statement until "next" and increment value of
counter by stepValue, until counter reaches finalValue.
Step part is optional, and if omitted stepValue is considered 1. Examples:
FOR c = 1 TO 10 STEP 2
a = a + c
NEXT
FOR I = a TO b
j = i ^ 2
sum = sum + j
NEXT

For examples

6.1.15 Select case statements


Scripting supports select case statements with following syntax:
SELECT CASE selectorExpression
CASE caseexpr1
Statement(1)

CASE caseexprn
Statement(n)
CASE ELSE
elsestatement
END SELECT

If selectorExpression matches the result of one of caseexpr(n) expressions, the respective statements will be
execute. Otherwise, elsestatement will be executed. Else part of case statement is optional.
SELECT CASE uppercase(Fruit)
CASE "lime" ShowMessage("green")
CASE "orange"
ShowMessage("orange")
CASE "apple" ShowMessage("red")
CASE ELSE
ShowMessage("black")
END SELECT

Select example

6.1.16 Function and sub declaration


Declaration of functions and subs are similar to basic. In functions to return function values, use implicited
declared variable which has the same name of the function, or use Return statement. Parameters by
reference can also be used, using BYREF directive.
SUB HelloWord
ShowMessage(Hello world!)
END SUB

Sub example
SUB UpcaseMessage(Msg)
ShowMessage(Uppercase(Msg))
END SUB

Sub example

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

38 / 135

FUNCTION TodayAsString
TodayAsString = DateToStr(Date)
END FUNCTION

Function example
FUNCTION Max(A,B)
IF A>B THEN
MAX = A
ELSE
MAX = B
END IF
END FUNCTION

Function example
SUB SwapValues(BYREF A, B)
DIM TEMP
TEMP = A
A = B
B = TEMP
END SUB

Byref example
You can also declare subs and functions as private or public using the following syntax:
PRIVATE SUB Hello
END SUB
PUBLIC FUNCTION Hello
END FUNCTION

Private example
Subs and functions are public by default. Private subs and functions are not acessible from other script units.
You can use Return statement to exit subs and functions. For functions, you can also return a valid value.
SUB UpcaseMessage(Msg)
ShowMessage(Uppercase(Msg))
Return
'This line will be never reached
ShowMessage("never displayed")
END SUB
FUNCTION TodayAsString
Return DateToStr(Date)
END FUNCTION

Return example

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

39 / 135

6.1.17 Try catch finally


With try, catch and finally it is possible to implement a basic exception handling within scripting. Currently it is
not possible to use nested try catch or try finally blocks (e.g. try try finally end finally end).
try
...
' statements
...
finally
' finally statements
...
end

try finally example


try
...
' statements
raise("My Exception")
catch
' catch possible execptions
MsgBox("TestTryCatch-Exception: " + LastExceptionMessage)
end

try catch example


try
try
...
' statements
raise("My Exception")
catch
MsgBox("TestTryCatchFinally-Exception: " + LastExceptionMessage)
end
finally
' finally statements
...
end

try catch finally example

6.1.18 Variant arrays


Dim A = VarArrayCreate([0,5], varVariant)
A[0] = 1
A[1] = 1234.5678
A[2] = "Hello world"
A[3] = True
A[4] = VarArrayCreate([0, 4], varVariant)
A[4][2] = 100
MsgBox(A[2])
' Hello world
MsgBox(A[4][2]) ' 100

Variant array example

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

40 / 135

6.2 Calling dll functions


6.2.1 General
Scripting allows importing and calling external DLL functions, by inserting special directives declaration on top
of script unit routines, indicating library name and, optionally, the calling convention, beyond the function
signature.
External libraries are loaded by scripting on demand, before function calls, if not loaded yet (dynamically or
statically). To load and unload libraries explicitly, functions LoadLibary and FreeLibrary from unit Windows
can be used.

6.2.2 Syntax
function lib 'libName.dll' [alias ExternalFunctionName] [callingConvention]
functionName(arguments) as resultType;

For example, the following declaration:


function lib "CustomLib.dll" MyFunction(arg as integer) as integer

imports a function called MyFunction from CustomLib.dll. Default calling convention, if not specified, is stdcall.
Scripting also allows to declare a different calling convention (stdcall, register, pascal, cdecl or safecall) and to
use a different name for DLL function, like the following declaration:
function MessageBox lib "User32.dll" alias "MessageBoxA" stdcall (hwnd as pointer, text as string,
caption as string, msgtype as integer) as integer

That imports 'MessageBoxA' function from User32.dll (Windows API library), named 'MessageBox' to be used
in the script unit.
Declaration above can be used to functions and as well to subs (routines without result value).

6.2.3 Supported types


Scripting support following basic data types on arguments and result of external functions (DLLs):
Integer
Char
String
PChar
Class
PWideChar
Currency
Interface
Longint
Longword
Byte
Word
Double
DateTime

13/02/2013

Boolean
Extended
Pointer
Object
WideChar
AnsiString
Variant
WideString
Cardinal
Single
Shortint
Smallint
Real

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

41 / 135

6.3 Using COM-Objects


With Scripting you have the possibility to access available COM objects on the computer. To create a new
COM object, use the following statement
CreateObject(Name of the COM object)

The following example shows how to access a database using ADO COM object:
' Open a database connection
Dim ObjConnection = CreateObject("ADODB.Connection")
Dim myDatabase = "countries.mdb"
Dim OdbcTextConnStr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" + myDatabase
ObjConnection.Open(OdbcTextConnStr) ' Use either OLE or ODBC connection string
' Open a recordset
Dim ObjRecordSet = CreateObject("ADODB.RecordSet")
Dim mySQL = "SELECT * FROM countries"
ObjRecordSet.ActiveConnection = ObjConnection
ObjRecordSet.Open(mySQL)
try
' Query the recordset
Dim i = 0
do while (ObjRecordSet.Eof = False)
' get the field
Dim RowData = ""
Dim ObjField = nothing
ObjField = ObjRecordSet.Fields.Item("ID")
RowData = RowData & ObjField.Value & Chr(0x09)
ObjField = ObjRecordSet.Fields.Item("COUNTRY")
RowData = RowData & ObjField.Value & Chr(0x09)
ObjField = ObjRecordSet.Fields.Item("CODE")
RowData = RowData & ObjField.Value
ListBoxCountries.AddItem(RowData, nothing)
ObjRecordSet.MoveNext
i = i + 1
loop
finally
' close recordset and connection
ObjRecordSet.Close
ObjConnection.Close
end

COM ADO object example


Limitations
Unless scripting currently does not evaluate COM objects type libraries no information for code completion is
available. Therefore it is necessary to check all available functions and properties from the COM object
15
vendors API reference .

15

From implementation point of view it can be helpful to test such implementations in other Visual Basic IDEs
like Visual Basic for Excel.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

42 / 135

6.4 Advanced language features


6.4.1 Using forms in scripts
A powerful feature in scripting is the ability to declare forms.
This can be either done directly from SpeedMark by creating a
form script element
Or within the IDE through menu point
Scripting  Add new form..
To use the newly created form unit from another script (e.g. Main unit), use the following statements:
uses Classes, Forms, FormMain
DIM MainForm AS TFormMain
' Create instances of the form
MainForm = new TFormMain(Application)
try
' set a form variable
MainForm.MyFormGlobalVar = "my instance"
' call a form "method".
MainForm.ChangeButtonCaption("Another click")
' accessing form properties and components
MainForm.Edit1.Text = "Default text"
' show the form in modal way
MainForm.ShowModal
finally
MainForm.Free
MainForm = nothing
end

Main unit code


#FORM TFormMain, FormMain.sfm
uses Classes, Graphics, Controls, Forms, Dialogs, StdCtrls
Dim MyFormGlobalVar as string
SUB Button1Click(Sender AS TObject)
MsgBox("The text typed in Edit1 is " + Edit1.Text + "! And the value of global var is " +
MyFormGlobalVar)
END SUB
SUB ChangeButtonCaption(ANewCaption as string)
Button1.Caption = ANewCaption
END SUB

Form unit code


The sample units above show how to declare forms, create instances, and use their "methods" and variables.
The $FORM directive is the main piece of code in the form script. This directive tells the compiler that the
current script should be treated as a form class that can be instantiated, and all its variables and procedures
16
should be treated as form methods and properties .
16

The values of the #FORM declaration are internally handled by Scripting and should not be changed.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

43 / 135

6.4.2 Declaring classes


It is possible to declare classes in a script. With this feature you can declare a class to use it in other units.
You can create an instance of the class and reuse it.
Declaring the class
Each class must be declared in a separated unit. You turn the script into a "class script" by adding the
#CLASS directive at the beginning of the unit, followed by the class name:
{$CLASS TSomeClass}

Methods and properties


Each global variable declared in a class unit actually becomes a property of the class. Each
procedure/function in the unit becomes a class method. Statements at the end of the unit are always
executed when a new instance of the class is created, so it can be used as a class initializer and you can set
some properties to default value and do some proper class initialization.
uses MyClass
DIM MyClass as TMyClass
' code starts here
MyClass = new TMyClass
MsgBox(MyClass.MyProperty)
MyClass.MyProperty = "test"
MyClass.SomeMethod
MsgBox(MyClass.MyProperty)

Main unit code


'My class script
#CLASS TMyClass
uses Dialogs
Dim MyProperty as string
SUB SomeMethod
MsgBox("Hello, world!")
END SUB
'class initializer
MyProperty = "Default Value"

Class unit code


Limitations
Inheritance is not supported.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

44 / 135

SpeedMark scripting object model

7.1 Object model


SpeedMark

CurrentProject
MainProgram
SubPrograms

TScProgram

CurrentProgram

Variables

Logging

Graphics

Errors
System
Execution

BorderMarking
Components

RunScreen (only Scripted)


IOControllerComponents
Configuration
LaserControllerComponents
DataStore
AxisControllerComponents
System
SerialPortComponents
LaserController
TCPComponents
MarkStart
VirtualInputIOs
MarkBusy
VirtualOutputIOs
AutomaticMode
Exhausts
EmergencyStop
XAxis
YAxis
ZAxis
AAxis
BAxis
Exhaust

Class definition
Common objects
Scripting Element objects
RunScreen objects

MsgBox(SpeedMark.CurrentProject.MainProgram.Name)

Object model example

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

45 / 135

7.2 Class hierarchy


7.2.1 Explanations of terms or abbreviations
Definition
Components
Objects

Description
Are SpeedMark components like LaserController, Axis and so on
Are instances of classes which are already created by SpeedMark

7.2.2 Application object and associated properties


Objects

TScCustomErrors

Classes
Application Object

TScExecutionErrors

TScSystemErrors

Execution

System

TScLogging

TScErrorHandler

TScConfiguration

TScDataStore

TScRunScreen

Logging

Errors

Configuration

DataStore

RunScreen

SpeedMark Application Object


Components
LaserController
MarkStart
MarkBusy
AutomaticMode
EmergencyStop
XAxis
YAxis
ZAxis
AAxis
BAxis
Exhaust

TScCustomApp

TScRunScreenApp

TScProjectApp

SpeedMark

TScLaserSystem

TScProject

System

CurrentProject

TScProgram
CurrentProgram

The application object SpeedMark is either of type TScRunScreenApp (when using scripted run screen) or of
17
type TScProjectApp (when using scripting elements). The difference is only one property .
You will find the class diagrams for TScLaserSystem, TScProgram TscProject and the components in the
subsequent chapters of this document.

17

See also 7.3.1 SpeedMark application class on page 51.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

46 / 135

7.2.3 Application object components

All components defined in the laser configuration of SpeedMark (tab system configuration) can be directly
18
accessed via the application object SpeedMark. This includes the following components :

LaserController
MarkBusy
MarkStart
AutomaticMode
EmergencyStop
Exhaust
XAxis
Yaxis
Zaxis
Baxis

SpeedMark.Xaxis.MoveAbs(100)

Xaxis example
SpeedMark.MarkBusy.OutputIO = True

MarkBusy example
if (SpeedMark.LaserController.IsLaserReady) then
MsgBox(Laser is ready!)
else
MsgBox(Laser is not ready!)
end if

LaserController example
18

If a component is not configured within SpeedMark laser configuration the object is null.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

47 / 135

7.2.4 Laser system component collections

The object System (TScLaserSystem) within the application object SpeedMark allows accessing all
configured components and system relevant actions like border marking. From here it is possible to access
also components which are not defined in laser configuration tab system configuration, like serial ports and so
on.
All collection classes dispose the components in form of properties. That means when you define a serial port
with name Serial1 in SpeedMark, the collection SerialPortComponents gets a new property called Serial1.
The advantage of this system is that you will get compile errors when the laser system is not correctly
19
configured .
text = SpeedMark.System.SerialPortComponents.Serial1.Read
text = text + "Hello"
SpeedMark.System.SerialPortComponents.Serial1.Write(text)

Example with a configured serial port with name Serial1


Border marking can be accessed by setting the graphics first and the starting the bordermarking.
...
SpeedMark.System.BorderMarking.UpdateSelection(SpeedMark.CurrentProject.MainProgram, bmmGraphics)
SpeedMark.System.BorderMarking.Start
...
if SpeedMark.System.BorderMarking.IsRunning then
SpeedMark.System.BorderMarking.Stop
end if
...

Border marking example

19

All the other component collections work the same way as SerialPortComponents does.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

48 / 135

7.2.5 Component collections and associated component classes

Every component collection class supports zero or more components which can be directly accessed via the
name of the component defined within SpeedMark laser configuration. The picture above shows which
component class type is associated with which collection class type.
The knowledge of this structure allows direct assignment of components to variables of the designated type.
Dim varSerial1 as TScSerialPortComponent
varSerial1 = SpeedMark.System.SerialPortComponents.Serial1
if Assigned(varSerial1) then
test = varSerial1.Read
text = text + "Hello"
varSerial1.Write(text)
end if

Component assignment example


Assignment of component objects to variables can be helpful to get abetter structure of the script code.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

49 / 135

7.2.6 Program classes


Objects

TScProject

SpeedMark

Classes

CurrentProject

Application Object

SubPrograms

MainProgram

TScProgram
CurrentProgram

TScElements

TScGraphicElements

TScProgramVariables

Graphics

Variables

TScGraphicElement

TScTextGraphicElement

TScElement

TScFileGraphicElement

The program classes allow direct access to a loaded SpeedMark project, main program and sub programs as
well as SpeedMark program variables.
It is only possible to access programs and graphic elements already created within SpeedMark.
Currently it is not supported to create programs and graphic elements by scripting.
But it is possible to manipulate existing graphic elements in various ways like positioning, resizing
updating of data.

20

and

Dim TextGraphic as TSmScTextGraphicElement


Dim BarcodeGraphic as TsmScTextGraphicElement
update an outline text graphic
TextGraphic = SpeedMark.CurrentProgram.Graphics.GraphicByName[Outline text]
TextGraphic.Text = Hallo set a valid text
update a barcode graphic
BarcodeGraphic = SpeedMark.CurrentProgram.Graphics.GraphicByGUID[{393CF92C-174C-47FA-9665-96BD5C18B001}]
BarcodeGraphic.Text = 123456789012812 set a valid barcode (e.g. for EAN 13 + 2 Digits)

Text graphic update example


To access program variables defined in a SpeedMark program just use the variables object of TScProgram:
SpeedMark.CurrentProgram.Variables.Layout = "Layout 1"

Variables example
20

For further information on how to work with GraphicElements see 7.3.5 TScGraphicElement on page 55.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

50 / 135

7.3 Class Reference


So that SpeedMark and scripting is internally based on Delphi programming language we took over
the class naming convention which states that all classes start with an uppercase T (for Type) before
the class name.
To make a clear difference between external classes and SpeedMark scripting classes, all
SpeedMark scripting classes start with TSc (for Type Scripting). This helps programmers to clearly
distinguish when using internal and external classes.

7.3.1 SpeedMark application class


The application object SpeedMark is the main entrance
point for scripts to access various SpeedMark
functions. It can be either class of TScRunScreenApp
or TScProjectApp which both inherit from
TScCustomApp. This depends on the type
(ScriptingElement or scripted run screen)
Unless the application object SpeedMark is available
from everywhere in scripts you dont need to take care
about the underlying class.

SpeedMark Application Object

TScCustomApp

TScRunScreenApp

TScProjectApp

SpeedMark

Property name

Returns

Description

ApplicationVersion

WideString

Read-only. Returns the version of SpeedMark.

ApplicationHandle

HWND

ReadOnly. Returns the current windows handle of

Logging

TScLogging

ReadOnly. Returns the logging object

Errors

TScErrorHandler

ReadOnly. Returns the errors object

RunScreen

TScRunScreen

ReadOnly. Returns the run screen object. Beware that


this object only relates to a running scripted run screen

DataStore

TScDataStore

ReadOnly. Returns the data store object

System

TScLaserSystem

ReadOnly. Returns the laser system object

LaserController

TScLaserControllerComponent

ReadOnly. Returns the laser controller component

MarkStart

TScVirtualInputIOComponent

ReadOnly. Returns the mark start object

MarkBusy

TScVirtualOutputIOComponent

ReadOnly. Returns the mark busy object

AutomaticMode

TScVirtualInputIOComponent

ReadOnly. Returns the automatic mode object

EmergencyStop

TScVirtualInputIOComponent

ReadOnly. Returns the emergency stop object

XAxis

TScAxisControllerComponent

ReadOnly. Returns the x axis object

YAxis

TScAxisControllerComponent

ReadOnly. Returns the y axis object

ZAxis

TScAxisControllerComponent

ReadOnly. Returns the z axis object

AAxis

TScAxisControllerComponent

ReadOnly. Returns the a axis object

BAxis

TScAxisControllerComponent

ReadOnly. Returns the b axis object

Exhaust

TScExhaustComponent

ReadOnly. Returns the exhaust object

CurrentProject

TScProject

ReadOnly. Returns the current project object

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

51 / 135

Property name

Returns

Description

CurrentProgram
(only scripting elements)

TScProgram

ReadOnly. Returns the current program.

Configuration
(only scripted run screen)

TScConfiguration

ReadOnly. Returns the configuration object

MainForm
(only scripted run screen)

TForm

ReadOnly. Returns the current SpeedMark main form.


This can be used to set the parent property of own
forms to this value

Method name

Returns

Parameters

Description

AbortExecution

Stops the execution of a SpeedMark


project at once

LoadProject
(only scripted run screen)

FileName as String

Loads a project file into SpeedMark

ExecuteProject
(only scripted run screen)

ParentWindowHandle as
HWND, [WindowPos as TRect
= Center]

Executes a project file already loaded.

SimulateProject
(only scripted run screen)

ParentWindowHandle as
HWND, [WindowPos as TRect
= Center]

Simulates a project file already loaded.

Event name

Parameters

Description

OnProgramStart
(only scripted run screen)

Program as TScProgram,
IsMainProgram as Boolean

Triggered when a program execution starts. The


executed program and the program type is passed into
the event

OnProgramEnd
(only scripted run screen)

Program as TScProgram,
IsMainProgram as Boolean

Triggered when a program execution stops. The


executed program and the program type is passed into
the event

To use the application object SpeedMark, just type SpeedMark. with a point and the code completion will
present all available properties, methods and events.
MsgBox(SpeedMark.ApplicationVersion)

7.3.2 TScProject
The TScProject class represents objects of SpeedMark projects. Instances of this class cannot be created via
scripting but must be read from application object SpeedMark property CurrentProject.
Property name

Returns

Description

FileName

String

Read-only. Returns the filename of the currently loaded


project

MainProgram

TScProgram

Read-only. Returns the main program object

SubProgramCount

Integer

Read-only. Returns the count of sub programs

SubPrograms

TScProgram [ ]

Parameter: Index as Integer (e.g. [0])


Read-only. Returns a sub program object

SubProgramByName

TScProgram [ ]

Parameter: Name as Integer (e.g. [Sub1])


Read-only. Returns a sub program object

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

52 / 135

Method name

Returns

Parameters

Description

CreatePreviewBitmap

Bitmap as TBitmap, BitmapWidth as


Integer, BitmapHeight as Integer,
[Zoom as Double = 1, ShowFieldRect
as Boolean=True, ShowGrid as
Boolean=False, ShowAxis as
Boolean=False, ShowAxisLabels as
Boolean=False, ShowFieldShadow as
Boolean=False,
ShowInvisibleElements as
Boolean=False, ShowGraphicInfo as
Boolean=False, Margin as
Integer=10]

Creates a preview bitmap of the graphic


elements of all programs. This includes
the main program and all sub programs

CreatePreviewStream

BitmapStream as TStream,
BitmapWidth as Integer, BitmapHeight
as Integer, [Zoom as Double = 1,
ShowFieldRect as Boolean=True,
ShowGrid as Boolean=False,
ShowAxis as Boolean=False,
ShowAxisLabels as Boolean=False,
ShowFieldShadow as Boolean=False,
ShowInvisibleElements as
Boolean=False, ShowGraphicInfo as
Boolean=False, Margin as
Integer=10]

Creates a preview stream of the graphic


elements of all programs. This includes
the main program and all sub programs

The project object is mainly the container for all SpeedMark programs. The examples below show how to
create a preview of all available programs within this project.
SUB ButtonPreviewAllClick(Sender AS TObject)
Dim Bitmap as TBitmap
Bitmap = new TBitmap
try
SpeedMark.CurrentProject.CreatePreviewBitmap(Bitmap, 1200, 1200, 1)
Self.Canvas.Draw(0,0, Bitmap)
finally
Bitmap.Free
Bitmap = nothing
end
END SUB

SUB ButtonPreviewSaveClick(Sender AS TObject)


Dim FileName as String
Dim BitmapStream as TFileStream
FileName = "C:\Preview.bmp"
BitmapStream =new TFileStream(FileName, fmCreate)
try
SpeedMark.CurrentProject.CreatePreviewStream(BitmapStream, 1200, 1200, 1)
finally
BitmapStream.Free
BitmapStream = nothing
end
end if
END SUB

7.3.3 TScProgram
The TScProgram class represents objects of SpeedMark programs. Instances of this class cannot be created
via scripting but must be read from a project object or SpeedMark property CurrentProgram.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

53 / 135

Property name

Returns

Description

Owner

TScProject

Read-only. Returns the owner project of this program

Name

String

Read-only. Returns the name of the program

Modified

Boolean

Set/Get if the program is modified or not

Variables

TScProgramVariables

Read-only. Returns the variables object

Graphics

TScGraphicElements

Read-only. Returns the graphics object

Method name

Returns

Parameters

Description

CreatePreviewBitmap

Bitmap as TBitmap, BitmapWidth as


Integer, BitmapHeight as Integer,
[Zoom as Double = 1, ShowFieldRect
as Boolean=True, ShowGrid as
Boolean=False, ShowAxis as
Boolean=False, ShowAxisLabels as
Boolean=False, ShowFieldShadow as
Boolean=False,
ShowInvisibleElements as
Boolean=False, ShowGraphicInfo as
Boolean=False, Margin as
Integer=10]

Creates a preview bitmap of the graphic


elements of this program

CreatePreviewStream

BitmapStream as TStream,
BitmapWidth as Integer, BitmapHeight
as Integer, [Zoom as Double = 1,
ShowFieldRect as Boolean=True,
ShowGrid as Boolean=False,
ShowAxis as Boolean=False,
ShowAxisLabels as Boolean=False,
ShowFieldShadow as Boolean=False,
ShowInvisibleElements as
Boolean=False, ShowGraphicInfo as
Boolean=False, Margin as
Integer=10]

Creates a preview stream of the graphic


elements of this program

The program object is mainly the container for the graphic elements. The examples below show how to create
a preview of the graphics within this program.
SUB ButtonPreviewAllClick(Sender AS TObject)
Dim Bitmap as TBitmap
Bitmap = new TBitmap
try
SpeedMark.CurrentProject.MainProgram.CreatePreviewBitmap(Bitmap, 1200, 1200, 1)
Self.Canvas.Draw(0,0, Bitmap)
finally
Bitmap.Free
Bitmap = nothing
end
END SUB

SUB ButtonPreviewSaveClick(Sender AS TObject)


Dim FileName as String
Dim BitmapStream as TFileStream
FileName = "C:\Preview.bmp"
BitmapStream =new TFileStream(FileName, fmCreate)
try
SpeedMark.CurrentProject.MainProgram.CreatePreviewStream(BitmapStream, 1200, 1200, 1)
finally
BitmapStream.Free
BitmapStream = nothing
end
end if
END SUB

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

54 / 135

7.3.4 TScGraphicElements
Property name

Returns

Description

Count

Integer

Read-only. Returns the number of graphic elements.

GraphicByIndex

TScGraphicElement [ ]

Parameter: Index as Integer (e.g. [0])


Read-only. Returns a graphic element object

GraphicByGUID

TScGraphicElement [ ]

Parameter: GUID as String (e.g. [{B39E1467-27DB4826-BB47-6356BEDB3859} ])


Read-only. Returns a graphic element object

GraphicByName

TScGraphicElement [ ]

Parameter: Name as String (e.g. [Outline Text])


Read-only. Returns a graphic element object

Method name

Returns

Parameters

Description

UpdateGraphics

Updates all graphics

Dim TextGraphic as TSmScTextGraphicElement


TextGraphic = SpeedMark.CurrentProgram.Graphics.GraphicByGUID["{B39E1467-27DB-4826-BB47-6356BEDB3859}"]

7.3.5 TScGraphicElement
This is the base class for all graphic element classes.
Property name

Returns

Description

GUID

WideString

Read-only. Returns the element GUID

Name

WideString

Read-only. Returns the element name

Comment

WideString

Read-only. Returns the element comment

Enabled

Boolean

Get/Set the element enabled state

Visible

Boolean

Get/Set the element visible state

Bounds

TScRect2D

Read-only. Returns the current bounds of the graphic


element

MarkingBounds

TScRect2D

Read-only. Returns the current marking bounds of the


graphic element

For some calculation purposes constants of type TRectPointPosition is used. The following constants are
available: rppTopLeft, rppTopCenter, rppTopRight, rppCenterLeft, rppCenter, rppCenterRight, rppBottomLeft,
rppBottomCenter, rppBottomRight
Method name

Parameters

Description

GetBoundsPoint

BoundsPointPosition as
TRectPointPosition, byref x as
Double, byref y as Double

Calculates the x, y position of a given


anchor point.

GetBoundsSize

byref Width as Double, byref


Height as Double

Calculates the bound size.

GetMarkingBoundsPoint

BoundsPointPosition as
TRectPointPosition, byref x as
Double, byref y as Double

Calculates the x, y position of a given


anchor point.

GetMarkingBoundsSize

byref Width as Double, byref


Height: as Double

Calculates the marking bound size

13/02/2013

Returns

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

55 / 135

Method name

Returns

Parameters

Description

MoveBy

MoveX: Double; MoveY: Double

Moves the graphic element by x and y

MoveTo

RectPointPosition:
TRectPointPosition; MoveToX:
Double; MoveToY: Double

Moves a graphic anchor point to a point


defined by x and y

Scale

RectPointPosition:
TRectPointPosition; ScaleX:
Double; ScaleY: Double

Scales a graphic element from an anchor


point by scalex and scaley

Rotate

RectPointPosition:
TRectPointPosition; Angle: Double

Rotates a graphic element around a


given anchor point

RotateXY

RotationPosX: Double;
RotationPosY: Double; Angle:
Double

Rotates a graphic element around a


given point

Shear

RectPointPosition:
TRectPointPosition; ShearX:
Double; ShearY: Double

Shears the graphic element by a given


anchor point

MirrorX

MirrorPosX: Double; MirrorPosY:


Double

Mirrors the graphic element over the x


axis and a given point

MirrorY

MirrorPosX: Double; MirrorPosY:


Double

Mirrors the graphic element over the y


axis and a given point

UpdateGraphic

Updates the graphic

Dim Graphic as TScGraphicElement


Graphic = SpeedMark.CurrentProgram.Graphics.GraphicByName["Outline Text"]
Graphic.MoveBy(10, 10)

7.3.6 TScRect2D
This class is the return value for bounds and marking bounds of the graphic element.
Property name

Returns

Description

Left

Double

Get/Set left point

Top

Double

Get/Set top point

Right

Double

Get/Set right point

Bottom

Double

Get/Set bootom point

7.3.7 TScTextGraphicElement
Derived from TScGraphicElement. This class type includes not only text and outline text, but also 1D and 2D
barcodes.
Property name

Returns

Description

Text

WideString

Get/Set the value of this text graphic element

Dim TextGraphic as TSmScTextGraphicElement


Dim BarcodeGraphic as TsmScTextGraphicElement
update an outline text graphic
TextGraphic = SpeedMark.CurrentProgram.Graphics.GraphicByName["Outline text"]
TextGraphic.Text = "Hello" set a valid text

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

56 / 135

update a barcode graphic


BarcodeGraphic = SpeedMark.CurrentProgram.Graphics.GraphicByGUID["{393CF92C-174C-47FA-9665-96BD5C18B001}"]
BarcodeGraphic.Text = "123456789012812" set a valid barcode (e.g. for EAN 13 + 2 Digits)

Text graphic update example

7.3.8 TScFileGraphicElement
Derived from TScGraphicElement. This class type includes raster and vector graphic elements.
Property name

Returns

Description

FileName

String

Read-only. Returns the file name of the graphic


element if available

Method name

Returns

Parameters

Description

UpdateGraphicFromFile

Boolean

FileName as string,
ApplyExistingTransformations as
Boolean

Updates the graphic with the data from a


given file

Dim VectorGraphic as TSmScFileGraphicElement


Dim RasterGraphic as TSmScFileGraphicElement
' update a vector graphic
VectorGraphic = SpeedMark.CurrentProgram.Graphics.GraphicByName["Vectorgraphic"]
VectorGraphic.UpdateGraphicFromFile("C:\Bentley.dxf", True)
' update a raster graphic
RasterGraphic = SpeedMark.CurrentProgram.Graphics.GraphicByGUID["{393CF92C-174C-47FA-9665-96BD5C18B001}"]
RasterGraphic.UpdateGraphicFromFile("C:\Audi.jpg", True)

File graphic update example

7.3.9 TScProgramVariables
The TScProgramVariables class is a container for variables of SpeedMark programs. Instances of this class
cannot be created via scripting.
The special about this container is that the properties are generated dynamically depending on the variables
defined in the SpeedMark program.
Property name

Returns

Description

<VariableName>

<Integer, String, Double>

Get/Set the value of the program variable

Currently matrix variables defined in SpeedMark programs are not supported. In case of a bigger
21
amount of data exchange, use the DataStore .

The following example shows how to access an integer variable named test (defined in a SpeedMark
program):
SpeedMark.CurrentProgram.Variables.test = 1

21

See 7.3.15 TScDataStore on page 61

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

57 / 135

7.3.10 TScLogging
Method name

Returns

AddProgramMessage

Parameters

Description

Message as WideString

Adds a program message to the


SpeedMark execution engine

ClearProgramMessages

Clears all program messages

AddProgramLogText

LogLevel as TLogLevel, Message


as WideString

Adds a program log text to the


SpeedMark execution enging. For log
level the following constants are allowed:
llFatal, llError, llWarn, llInfo, llDebug

ShowInfoMessage

Message as WideString,
[TimeOut: Integer = 0]

Shows an info message dialog. When


using timeout=0 the dialog is shown until
CloseInfoMessage is called

CloseInfoMessage

Closes an open info message dialog

InitStopWatch
(only scripting elements)
ReadStopWatch
(only scripting elements)

Double

StopWatchName as String

Initializes a named stopwatch

StopWatchName as String

Reads the current value of a named


stopwatch

Event name

Parameters

Description

OnAddProgramMessage
(only scripted run screen)

Sender as TObject, Msg as


String

Triggered when the add program message from simple


or advanced scripting is called
Triggerd when the clear program messages from
simple or advanced scripting is called

OnClearProgramMessages
(only scripted run screen)
OnAddProgramLogText
(only scripted run screen)

Sender as TObject, LogLevel as


TLogLevel, Text as String

Triggered when add program log text from simple or


advanced scripting is called

These events are mostly use from scripted run screen to present logging messages during program execution
on screen. An event example can be found at the end of this chapter.
All logging and program messages sent to SpeedMark are shown in the user windows program log and
program messages:
SpeedMark.Logging.AddProgramMessage("My first program message")
SpeedMark.Logging.AddProgramMessage("My second program message")
SpeedMark.Logging.ClearProgramMessages

Program message example


SpeedMark.Logging.AddProgramLogText(llFatal,
SpeedMark.Logging.AddProgramLogText(llError,
SpeedMark.Logging.AddProgramLogText(llWarn,
SpeedMark.Logging.AddProgramLogText(llInfo,
SpeedMark.Logging.AddProgramLogText(llDebug,

"Fatal log entry")


"Error log entry")
"Warning log entry")
"Info log entry")
"Debug log entry")

Program log text example


The next example shows how to implement the logging events handling when sending messages from a
SpeedMark program to a scripted run screen.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

58 / 135

OnAddProgramMessage
OnClearProgramMessages

SpeedMark Execution Engine

OnClearProgramMessages

Logging event handling


SUB DoOnAddProgramLogText(Sender, LogLevel, Text)
MemoLog.Lines.Add(Text)
END SUB
SUB FormMainShow(Sender AS TObject)
SpeedMark.Logging.OnAddProgramLogText = "DoOnAddProgramLogText"
END SUB
SUB FormMainDestroy(Sender AS TObject)
SpeedMark.Logging.OnAddProgramLogText = nothing
END SUB

Event handling example

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

59 / 135

7.3.11 TScErrorHandler
Property name

Returns

Description

Execution

TScExecutionErrors

Read-only. Returns execution errors object

System

TScSystemErrors

Read-only. Returns system errors object

Execution errors are only raised when a SpeedMark program is running. System errors raise when a
component reports a failure. So for example a serial port component reports an error (e.g. not connected),
this doesnt mean that an execution error is raised when the program never accesses this serial port.

7.3.12 TScExecutionErrors
Gives the possibility to check execution errors.
Property name

Returns

Description

ErrorString

String

Read-only. Returns the last error

Count

Integer

Read-only. Returns the count of all outstanding errors

Error

String [ ]

Parameter: Index as Integer (e.g. [0])


Read-only. Returns an error string defined by index

Method name

Returns

Parameters

Description

ClearAll

Clears all errors in the error list

ClearLast

Clears the last error in the error list

7.3.13 TScSystemErrors
Gives the possibility to check system errors.
Property name

Returns

Description

ErrorString

String

Read-only. Returns all system errors separated by


carriage return line feed

7.3.14 TScConfiguration
This class and its object is only available in scripted run screens.
Method name

Parameters

Description

ShowComponentListDlg

ParentWindowHandle as HWND

Shows the laser system configuration


dialog

ShowMaterialDatabaseDlg

ParentWindowHandle as HWND

Shows the material database dialog

ShowProjectMaterialDlg

ParentWindowHandle as HWND

Shows the project material dialog

13/02/2013

Returns

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

60 / 135

7.3.15 TScDataStore
22

The data store object is used to manage values and list values globally within SpeedMark . The data store
will keep the values also when loading or executing different projects. Through available functions in simple
scripting it is possible to pass data from advanced to simple scripting via the data store.
Property name

Returns

Description

NamedListsCount

Integer

Read-only. Returns the count of all registered named


lists

NamedValuesCount

Integer

Read-only. Returns the count of all registered named


values

NamedValueExists

Boolean

Read-only. Returns true if a named value exists

NamedValue

Variant

Get/Set the value of a named value entry

NamedListExists

Boolean

Read-only. Returns true if a named list exists


23

NamedList

TDataStoreList

Method name

Returns

Read-only. Returns a data store list object

Parameters

ClearAll

Description
Clears all. Named values and names
lists

AddNamedValue

'Name as String, Value as


Variant

Adds a named value to the data store

RemoveNamedValue

Name as String

Removes a named value from the data


store

ClearNamedValues
CreateNamedList
RemoveNamedList

Clears all named values


TDataStoreList

Name as String

Creates a named list

Name as String

Removes a named list from the data


store

ClearNamedLists

Clears all named lists

SpeedMark.DataStore.AddNamedValue("Val1", "This is a Test")


SpeedMark.DataStore.AddNamedValue("Val2", 100)
if SpeedMark.DataStore.NamedValueExists["Val1"] then
MsgBox("NamedValue Val1: " + SpeedMark.DataStore.NamedValue["Val1"])
else
MsgBox("DataStore named value Val1 does not exist!")
end if
if SpeedMark.DataStore.NamedValueExists["Val2"] then
MsgBox("NamedValue Val2: " & SpeedMark.DataStore.NamedValue["Val2"])
else
MsgBox("DataStore named value Val1 does not exist!")
end if
if SpeedMark.DataStore.NamedValueExists["Val3"] then
MsgBox("NamedValue Val3: " & SpeedMark.DataStore.NamedValue["Val3"])
else
MsgBox("DataStore named value Val3 does not exist!")
end if

Named value example

22
23

Currently it is not possible to load or save the data store to hard disk.
See the following chapter 7.3.16 TDataStoreList on page 62

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

61 / 135

7.3.16 TDataStoreList
Property name

Returns

Description

Name

String

Read-only. Returns the name of the data store list

Count

Integer

Read-only. Returns the count of all list entries

Empty

Boolean

Read-only. Returns true if the list is empty

Values

Variant [ ]

Parameter: Index as Integer (e.g. [0])


Get/Set the value of a list entry

Method name

Returns

Parameters

Description

Add

Value: Variant

Adds a value at the end of the list

Insert

Index: Integer; Value: Variant

Inserts a value at a specific position

Remove

Index: Integer

Removes a value from a specific


position

Clear

Clears the whole list

Push

Value: Variant

Adds a value at the end of the list

PopFirst

Variant

Reads the first value from the list and


removes this value from list

PopLast

Variant

Reads the last value from list and


removes this value from list

PeekFirst

Variant

Reads the first value from the list

PeekLast

Variant

Reads the last value from the list

Dim List as TDataStoreList


List = SpeedMark.DataStore.CreateNamedList("List")
List.Push("Hello1")
List.Push("Hello2")
List.Push("Hello3")
List.Push("Hello4")
List.Push("Hello5")
if SpeedMark.DataStore.NamedListExists["List"] then
List = SpeedMark.DataStore.NamedList["List"]
MsgBox(List.PeekLast)
MsgBox(List.PopLast)
MsgBox(List.PeekLast)
MsgBox(List.PeekFirst)
MsgBox(List.PopFirst)
MsgBox(List.PeekFirst)
else
MsgBox("DataStore named list List does not exist!")
end if

Data store list example

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

62 / 135

7.3.17 TScRunScreen
With a TScRunScreen object it is possible to establish an event based communication between a SpeedMark
program and a scripted run screen.
Method name

Returns

SendMesssage
(only scripting element)

Parameters

Description

ID as Integer, Text as
WideString, Data as Variant

Sends a message to SpeedMark


execution engine which generates an
event which can be handled by a scripted
run screen

Event name

Parameters

Description

OnMessage
(only scripted run screen)

Sender as TObject, ID as
Integer, Text as string, Data as
Variant

Triggered when the SendMessage function is called.

OnMessage

SpeedMark Execution
Engine

Run screen event handling


The following example sends a message from a scripting element to a scripted run screen.
SpeedMark.RunScreen.SendMessage(1, "C:\NewPreview.bmp", nothing)

The following examples shows how to catch events sent with the run screen object.
SUB DoOnRunScreenMessage(Sender, ID, Text, Data)
' Handles the message when Program Script Element sends a message (e.g. update the preview)
' see the following example (ID=1 changes the view image)
SELECT CASE ID
CASE 1 ' message one (defined by developer): Loads a new picture into image view
ImageView.Picture.LoadFromFile(Text)
CASE 2 ' currently not defined by developer
MsgBox("Message - ID: " & ID & ", Text: " & Text & ", Data: " & Data)
CASE 3 ' currently not defined by developer
MsgBox("Message - ID: " & ID & ", Text: " & Text & ", Data: " & Data)
CASE ELSE
MsgBox("Undefined RunScreen Message ID!")
END SELECT
END SUB
SUB FormMainShow(Sender AS TObject)
SpeedMark.RunScreen.OnMessage = "DoOnRunScreenMessage"

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

63 / 135

END SUB
SUB FormMainDestroy(Sender AS TObject)
SpeedMark.RunScreen.OnMessage = nothing
END SUB

7.3.18 TScLaserSystem
Within the application object SpeedMark the property system returns an object of class TScLaserSystem
which allows access to system relevant components and actions of SpeedMark and the underlying laser
hardware.
Property name

Returns

Description

BorderMarking

TScBorderMarking

Read-only. Returns border marking object

Components

TScComponents

Read-only. Returns components collection

IOControllerComponents

TScIOControllerComponents

Read-only. Returns io controller collection

LaserControllerComponents

TScLaserControllerComponents

Read-only. Returns laser controller collection

AxisControllerComponents

TScAxisControllerComponents

Read-only. Returns axis controller collection

SerialPortComponents

TScSerialPortComponents

Read-only. Returns serial port collection

TCPComponents

TScTCPComponents

Read-only. Returns tcp collection

VirtualInputIOs

TScVirtualInputIOs

Read-only. Returns input io collection

VirtualOutputIOs

TScVirtualOutputIOs

Read-only. Returns output io collection

ExhaustComponents

TScExhaustComponents

Read-only. Returns exhaust collection

7.3.19 TScBorderMarking
Property name

Returns

Description

IsRunning

Boolean

Read-only. States if border marking is currently running

IsValidSelection

Boolean

Read-Only. States if the current selection is valid for


border marking

Method name

Returns

UpdateSelection

Parameters

Description

Program as TScProgram,
Mode as
TBorderMarkingMode

Updates the border marking selection.


(Mode constants: bmmGraphics,
bmmPositioningGraphics)

Start

Starts the border marking with the


current selection

Stop

Stops the border marking

ShowBorderMarkingDlg

Parent as HWND

Shows the SpeedMark border marking


dialog

The following example shows how to init border marking, start it and stop it after the user has finished to
position his working piece.
SpeedMark.System.BorderMarking.UpdateSelection(SpeedMark.CurrentProject.MainProgram, bmmGraphics)
SpeedMark.System.BorderMarking.Start

if SpeedMark.System.BorderMarking.IsRunning then SpeedMark.System.BorderMarking.Stop

Border marking example

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

64 / 135

7.3.20 Components collections


The components collection classes include the following classes:

TScComponents
TScIOControllerComponents
TScLaserControllerComponents
TScAxisControllerComponents
TScSerialPortComponents
TScTCPComponents
TScVirtualInputIOs
TScVirtualOutputIOs
TScExhaustComponents

These classes have a property count for the number of components within the collection. The special about
these containers is that the properties are generated dynamically depending on the compnents defined in the
SpeedMark laser system configuration.
Property name

Returns

Description

Count

Integer

Read-only. Returns number of components within the


collection

<Component name>

<TScIOControllerComponent,
TScLaserControllerComponent,
TScAxisControllerComponent,
TScSerialPortComponent,
TScTCPComponent,
TScVirtualInputIOComponent,
TScVirtualOutputIOComponent,
TScExhaustComponent>

Read-only. Returns the component of the type


depending on the container

MsgBox(SpeedMark.System.LaserControllerComponents.TLC2.ComponentName)

7.3.21 TScCustomComponent
This is the base class for all controller component classes.
Property name

Returns

Description

ComponentName

String

Read-only. Returns the component name

ConfigFile

String

Read-only. Returns the configuration file name

ComponentStatus

TModuleComponentStatus

Read-only. Returns the component status. Constants


are mcsOpen, mcsClosed, mcsErrors

LastErrorMsg

String

Read-only. Returns the last error message

Errors

String

Read-only. Returns all error messages separated by


carriage return line feed

Event name

Parameters

Description

OnError
(only scripted run screen)

Sender as TObject

Triggered when a component errors comes up

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

65 / 135

7.3.22 TScIOControllerComponent
Derived from TScCustomComponent. The io controller component class handles the various io controllers
attached to the system.
Property name

Returns

Description

InputPort

Integer

Read-only. Returns the input port as 16 bit value

InputIO

Boolean [ ]

Parameter: Index as Integer (e.g. [0])


Read-only. Returns a input io value

OutputPort

Integer

Get/Set the current output port as 16 bit value

OutputIO

Boolean [ ]

Parameter: Index as Integer (e.g. [0])


Get/Set a output io value

Event name

Parameters

Description

OnInputPortChanged
(only scripted run screen)

Sender as TObject, IOPort as


Integer

Triggered when the input port has changed

OnOutputPortChanged
(only scripted run screen)

Sender as TObject, IOPort as


Integer

Triggered when the output port has changed

SpeedMark.System.IOControllerComponents.TLC2.OutputIO[5] = True

7.3.23 TScLaserControllerComponent
Derived from TScCustomComponent. The laser controller component class handles the various laser
controllers attached to the system.
Property name

Returns

Description

FocalizeLaser

Boolean

Set focalize laser

PilotLaser

Boolean

Set pilot laser

FieldHeight

Double

Read-only. Returns the field height

FieldWidth

Double

Read-only. Returns the field width

MinFrequency

Double

Read-only. Returns the minimum frequency

MaxFrequency

Double

Read-only. Returns the maximum frequency

Power

Double

Get/Set the power of the laser

Frequency

Double

Get/Set the frequency of the laser

PosSpeed

Double

Get/Set the positioning speed of the galvo mirrors

MarkSpeed

Double

Get/Set the marking speed of the galvo mirrors

LaserOnDelay

Double

Get/Set the laser on delay of the laser

LaserOffDelay

Double

Get/Set the laser off delay of the laser

PosDelay

Double

Get/Set the positioning delay of the laser

MarkDelay

Double

Get/Set the marking delay of the laser

PolygonDelay

Double

Get/Set the polygon delay of the laser

Event name

Parameters

Description

OnGeneralAlarmChanged

Sender as TObject,

Triggered when the general alarm changed

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

66 / 135

GeneralAlarm as Boolean
OnMarkingChanged

Sender as TObject,
MarkingStopped as Boolean

Triggered when marking changed

OnShutterChanged

Sender as TObject

Triggered when shutter changed

OnMarkingParametersChanged

Sender as TObject

Triggered when new marking parameters are


applied

SpeedMark.System.LaserControllerComponents.TLC2.Power = 100

7.3.24 TScAxisControllerComponent
Derived from TScCustomComponent. The axis controller component class handles the various axis
controllers attached to the system.
Property name

Returns

Description

Position

Double

Read-only. Returns the current position

IsMoving

Boolean

Read-only. Returns if the axis is moving

IsInPos

Boolean

Read-only. Returns if the axis is in position

IsInPosTimeout

Boolean

Read-only. Returns if the axis ran into an in position


timeout

IsReferenced

Boolean

Read-only. Returns if the axis is referenced

MaxPosition

Double

Read-only. Returns the maximum position of this axis

MinPosition

Double

Read-only. Returns the minimum position of this axis

LimitEnabled

Boolean

Read-only. Returns if the minimum/maximum limits are


enabled

Method name

Returns

Parameters

MoveAbs

Boolean

Position as Double

StopMotion

Boolean

Reference

Boolean

Description

SpeedMark.System.AxisControllerComponents.aAxis.MoveAbs(100)

7.3.25 TScSerialPortComponent
Derived from TScCustomComponent. The serial port controller component class handles the various serial
port controllers attached to the system.
Method name

Returns

Read

String

Write

Parameters

Description
Reads the data from the serial port

Data as String

Writes data to the serial port

SpeedMark.System.SerialPortComponents.Serial1.Write("Hello serial port!")

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

67 / 135

7.3.26 TScTCPComponent
Derived from TScCustomComponent. The TCP controller component class handles the various tcp ports
configured with the laser system.
Method name

Returns

Read

String

Write

Parameters

Description
Reads the data from the tcp port

Data as String

Writes data to the tcp port

SpeedMark.System.TCPComponents.TCP1.Write("Hello TCP port!")

7.3.27 TScCustomVirtualComponent
This is the base class for all virtual component classes. Currently there are no special properties or events
defined.
Virtual IOs and exhausts are components which are provided by other hardware components. E.g. the TLC2
card provides some ios controlling an attached exhaust.

7.3.28 TScVirtualInputIOComponent
Derived from TScCustomVirtualComponent. The virtual input io component class handles the various input
ios configured within the laser system.
Property name

Returns

Description

InputIO

Boolean

Read-only. Returns the io value

Event name

Parameters

Description

OnSignalChanged
(only scripted run screen)

Sender as TObject

Triggered when the io has changed

MsgBox(SpeedMark.System.VirtualInputIOs.MarkStart.InputIO)

7.3.29 TScVirtualOutputIOComponent
Derived from TScCustomVirtualComponent. The virtual output io component class handles the various output
ios configured within the laser system.
Property name

Returns

Description

OutputIO

Boolean

Read-only. Returns the io value

Event name

Parameters

Description

OnSignalChanged
(only scripted run screen)

Sender as TObject

Triggered when the io has changed

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

68 / 135

SpeedMark.System.VirtualOutputIOs.MarkBusy.OutputIO = True

7.3.30 TScExhaustComponent
Derived from TScCustomVirtualComponent. The virtual exhaust component class handles the various
exhausts configured within the laser system.
Property name

Returns

Description

IsRunning

Boolean

Read-only. Returns if the exhaust is running

Method name

Returns

Parameters

Description

StartExhaust

Starts the exhaust

StopExhaust

Stops the exhaust

Event name

Parameters

Description

OnStatusChanged
(only scripted run screen)

Sender as TObject

Triggered when the exhaust status has changed

SpeedMark.System.ExhaustComponents.atmos.StartExhaust

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

69 / 135

Scripted run screen tutorial

8.1 Scope of this tutorial


Objective of this tutorial is to create a scripted run screen with the following features:

Starts automatically with SpeedMark


Reads data from a database or a structured file
Data lines can be searched by a key code (e.g. with a barcode reader)
Supports multiple layouts
Layout preview before marking
Starting the marking process
Scripted RunScreen
Read key with
barcode reader

Manual data input

Read data from


file or database

Show data in main


form

Choose layout and


create a preview

Start marking

Marking project
Start

Close door of
workstation if available

Choose the marking


layout

Open door of
workstation if available

Layout 1

Layout 2

Layout 3

End

General workflow of the tutorial

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

70 / 135

8.2 Building the marking project


The marking project of this tutorial will contain a main program which handles
the layout selection and the workstation controls, as well as three sub programs
which are responsible for the actual marking tasks.

8.2.1 Main program


For data exchange with the scripted run
screen a SpeedMark variable called Layout is
needed. This variable will be filled with the
correct layout name at startup by using the
data store.

The main program performs the following tasks:

Reading the layout name from the scripted run


screen
Checking if a correct layout name is given
Waiting for the start trigger of the workstation
(optional)
Setting mark busy to close the workstation (optional)
Waiting while the workstation is closing
Starting the exhaust
Calling the needing marking sub program
Stoping the exhaust
Resetting mark busy to open the workstation
(optional)

In the assignment element Read layout name the current layout name is transferred via data store from the
scripted run screen to the SpeedMark variable Layout

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

71 / 135

The layout name check (If junction) provides the


simple check if a layout name is given.

Within the Sub program element it is only


necessary to select the option Dynamic selection
of sub program and provide the SpeedMark
variable Layout.

8.2.2 Layout 1

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

72 / 135

8.2.3 Layout 2

8.2.4 Layout 3

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

73 / 135

8.2.5 Layout IDs


To correctly access the different graphic elements from the scripted run screen an id handling strategy is
necessary.
In case of the text graphic elements it is possible to use the graphic element name for identification. In this
tutorial this would be:

TextValue1
TextValue2

In case of file graphic elements (e.g. dxf graphic) this strategy leads to a problem. Whenever SpeedMark
updates the graphic of a file graphic element the name of the new graphic file updates the element name.
This means that in this case the element name will change with any update and is not useable as an unique
id for the scripted run screen.
To solve this problem every graphic element has a unique id
in form of GUID structure.

To change the GUID of a graphic element, just move


the mouse pointer over the label ID and a button will
show up. Press the button and it is possible to change
the ID.

Within this tutorial we will use the following ID for the vector
and the raster graphic:
Vector graphic: {1D22EA63-E01B-4AD5-BEDC-C124760ABA4F}
Raster graphic: {8D91BB35-F678-4540-841E-EB77DBDF3E1E}

These ids will be used for all three layouts.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

74 / 135

8.3 Building the scripted run screen


8.3.1 File data structure
The data to read comes either from a simple comma separated value file (csv) or from a database which is
accessible via ODBC.
Column

Name

Description

Key

Numeric value with 4 digits

LayoutName

TextValue1

TextValue2

VectorFile

RasterFile

csv file example


0001;Layout1;Val1-0001;Val2-0001;mercedes.dxf;Audi.jpg
0002;Layout1;Val1-0002;Val2-0002;Bentley.dxf;Audi.jpg
0003;Layout2;Val1-0003;Val2-0003;mercedes.dxf;Pirates.jpg
0004;Layout3;Val1-0004;Val2-0004;Bentley.dxf;Pirates.jpg

8.3.2 Choosing a template

As a basis for the new scripted run screen, choose the following template Data oriented run screen with
menu point Tools  Scripted RunScreen  New from template.
We will take this template as a basis for the scripted run screen created by the end of this tutorial
Unless the unit TemplateFolder is not needed for this tutorial, remove it by selecting the unit and removing it
with menu point Scripting  Remove unit. Remove the unit TemplateFolder from the uses clause as well.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

75 / 135

8.3.3 Changing the main form

Delete the update project button


Select all edit fields with the mouse and shift key
Move them down to make place for the new key edit field and the according label
Insert new edit field EditKey and the according label LabelKey
Rename the fields family and first name to text value1 and text value 2
Rename the fields address and telephone to vector graphic and raster graphic
Remove the text entries of all edit fields

Input panel after inserting the key field and removing the button

Go to the code view


Delete function ButtonUpdateProject
Compile  No compile failure must be arise

8.3.4 Creating a folder structure unit


For better access to all the files needed, it is assumed that the tutorial marking project is loaded and therefore
it is possible to the tutorial folder.

Create a unit Folders by using menu point Scriping  Add new unit within the scripting IDE.

'******************************************************************************
' SpeedMark Advanced Scripting script written by Trotec copyright 2012
' The source code is given as is. The author is not responsible for any
' possible damage done due to the use of this code. This script code can be
' freely used in any SpeedMark application. The complete source code remains
' property of the author and may not be distributed, published, given or sold
' in any form as such. No parts of the source code can be included in any
' other application without written authorization of the author.
'******************************************************************************
FUNCTION GetProjectFolder as string
Dim ProjectFolder = ExtractFileDir(SpeedMark.CurrentProject.FileName)
ProjectFolder = IncludeTrailingBackslash(ProjectFolder)
return ProjectFolder
END FUNCTION

By passing the unit name folders in the uses clause of other units, it is now possible to call the function
GetProjectFolder which retrieves the folder of the current loaded project in SpeedMark.

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

76 / 135

8.3.5 Creating a data reading class unit


Regarding the data access a unit class will be built which will handle the complete data accessing
procedures. The main form will create an instance of this class.

Create a unit Data by using menu point Scriping  Add new unit within the scripting IDE.

'******************************************************************************
' SpeedMark Advanced Scripting script written by Trotec copyright 2012
' The source code is given as is. The author is not responsible for any
' possible damage done due to the use of this code. This script code can be
' freely used in any SpeedMark application. The complete source code remains
' property of the author and may not be distributed, published, given or sold
' in any form as such. No parts of the source code can be included in any
' other application without written authorization of the author.
'******************************************************************************
#CLASS TData
uses SysUtils, TextFileList, Folders
'******************************************************************************
' TData properties
Dim Key as String
Dim Layout as String
Dim TextValue1 as String
Dim TextValue2 as String
Dim VectorGraphic as String
Dim RasterGraphic as String
'******************************************************************************
' TData methods
SUB ClearProperties
Key = ""
Layout = ""
TextValue1 = ""
TextValue2 = ""
VectorGraphic = ""
RasterGraphic = ""
END SUB
'******************************************************************************
' TData class initializer
ClearProperties()

Class unit basic structure


After creating the basic structure of the data unit with the fields, add the file read function to the unit between
the ClearProperties function and the class initializer
PRIVATE FUNCTION ReadDataFromFile(Key as String) as Boolean
' prepare files and folders
Dim ProjectFolder as string = GetProjectFolder + "Data\"
Dim Filename as string = ProjectFolder + "Data.csv"
' clear the data
ClearProperties
' search for key in file
Dim FileLine as Integer
Dim FileData as string
TextFileList.LoadFile(FileName)
FileLine = TextFileList.FindInFile(Filename, ScanBarcode)
if FileLine > 0 then
FileData = TextFileList.GetFileLine(Filename, FileLine) + ";"
Dim DataArray = Split(FileData, ";")
if UBound(DataArray) > 0 then Key = DataArray[0]
if UBound(DataArray) > 1 then Layout = DataArray[1]
if UBound(DataArray) > 2 then TextValue1 = DataArray[2]
if UBound(DataArray) > 3 then TextValue2 = DataArray[3]
if UBound(DataArray) > 4 then VectorGraphic = DataArray[4]

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

77 / 135

if UBound(DataArray) >
return True
else
return False
end if
END FUNCTION

5 then RasterGraphic = DataArray[5]

Reading a comma separated values file


Additionally a database read function will be implemented. In the following version the existing csv file will be
read by the means of ODBC/ADO functionality. Put this function after the ReadDataFromFile function.
PRIVATE FUNCTION ReadDataFromDatabase(Key as String) as Boolean
' prepare files and folders
Dim ProjectFolder as string = GetProjectFolder + "Data"
Dim myDatabase = ProjectFolder
Dim Tablename as string = "Data.csv"
Dim OleDbConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + myDatabase +
";Extended Properties=""Text;HDR=No;FMT=Delimited"""
' clear the data
ClearProperties
' Open a database connection
Dim ObjConnection = CreateObject("ADODB.Connection")
ObjConnection.Open(OleDbConnStr)
' Open a recordset
Dim ObjRecordSet = CreateObject("ADODB.RecordSet")
Dim mySQL = "SELECT * FROM " + Tablename + " WHERE F1 = '" + Key + "'"
ObjRecordSet.ActiveConnection = ObjConnection
ObjRecordSet.Open(mySQL)
try
' Query the recordset
do while (ObjRecordSet.Eof = False)
' get the row data
Key = ObjRecordSet.Fields.Item("F1").Value
Layout = ObjRecordSet.Fields.Item("F2").Value
TextValue1 = ObjRecordSet.Fields.Item("F3").Value
TextValue2 = ObjRecordSet.Fields.Item("F4").Value
VectorGraphic = ObjRecordSet.Fields.Item("F5").Value
RasterGraphic = ObjRecordSet.Fields.Item("F6").Value
ObjRecordSet.MoveNext
loop
finally
' close recordset and connection
ObjRecordSet.Close
ObjConnection.Close
end
END FUNCTION

Reading csv data with ODBC/ADO


As stated the two read functions are private, so not accessible by other units. In this case a common
ReadData function is introduced, which takes care of the real function to use. Put this function after the
ReadDataFromDatabase function.
FUNCTION ReadData(Key as string) as Boolean
' choose which method to use
return ReadBarcodeDataFromFile(Key)
' return ReadDataFromDatabase(Key)
END FUNCTION

Public common read data function

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

78 / 135

8.3.6 Creating a layout updating unit


To show a correct preview of a layout it is necessary to update all data before performing the preview.
Therefore a new unit will be created:

Create a unit Layouts by using menu point Scriping  Add new unit within the scripting IDE.

'******************************************************************************
' SpeedMark Advanced Scripting script written by Trotec copyright 2012
' The source code is given as is. The author is not responsible for any
' possible damage done due to the use of this code. This script code can be
' freely used in any SpeedMark application. The complete source code remains
' property of the author and may not be distributed, published, given or sold
' in any form as such. No parts of the source code can be included in any
' other application without written authorization of the author.
'******************************************************************************
uses Data
PRIVATE SUB UpdateTextGraphic(TextGraphic as TScTextGraphicElement, TextData as string)
if Assigned(TextGraphic) then
if Trim(TextData) <> "" then
TextGraphic.Enabled = True
TextGraphic.Visible = True
TextGraphic.Text = TextData
else
TextGraphic.Enabled = False
TextGraphic.Visible = False
end if
end if
END SUB
PRIVATE SUB UpdateVectorGraphic(VectorGraphic as TScFileGraphicElement, FileName as string)
if Assigned(VectorGraphic) then
if Trim(FileName) <> "" then
VectorGraphic.Enabled = True
VectorGraphic.Visible = True
VectorGraphic.UpdateGraphicFromFile(FileName, True)
else
VectorGraphic.Enabled = False
VectorGraphic.Visible = False
end if
end if
END SUB
PRIVATE FUNCTION UpdateLayoutDefault(LayoutProgram as TScProgram, Data as TData, BitmapFolder as string) as Boolean
' prepare the variables
Dim FileName as string
' update all graphics to ensure that all values are correctly calculated
LayoutProgram.Graphics.UpdateGraphics
' set text value 1
UpdateTextGraphic(LayoutProgram.Graphics.GraphicByName["TextValue1"], Data.TextValue1)
' get text value 2
UpdateTextGraphic(LayoutProgram.Graphics.GraphicByName["TextValue2"], Data.TextValue2)
' get vector graphic
FileName = BitmapFolder + Data.VectorGraphic
UpdateVectorGraphic(LayoutProgram.Graphics.GraphicByGUID["{1D22EA63-E01B-4AD5-BEDC-C124760ABA4F}"], FileName)
' get vector graphic
FileName = BitmapFolder + Data.RasterGraphic
UpdateVectorGraphic(LayoutProgram.Graphics.GraphicByGUID["{8D91BB35-F678-4540-841E-EB77DBDF3E1E}"], FileName)
END FUNCTION
FUNCTION UpdateLayout(LayoutProgram as TScProgram, Data as TData) as Boolean
' check if layout program is correct
if Not Assigned(LayoutProgram) then return False
Dim GraphicFolder as string = GetProjectFolder + "Graphics\"
' check the layout calculation to use
select case Data.Layout
case "Layout1" return UpdateLayoutDefault(LayoutProgram, Data, GraphicFolder)
case "Layout2" return UpdateLayoutDefault(LayoutProgram, Data, GraphicFolder)
case "Layout3" return UpdateLayoutDefault(LayoutProgram, Data, GraphicFolder)
case else
MsgBox("Layout '" + Data.Layout + "' not found. Applying default layout!")
return UpdateLayoutDefault(LayoutProgram, Data, GraphicFolder)
end select
END FUNCTION

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

79 / 135

8.3.7 Combining the data unit with the main form


To use the data class unit within the main from an entry in the uses clause must be made. See the entry
Data after Buttons.

Now it is possible to create and use instances of the Data class unit within FormMain.
For better performance only one instance of a data class within FormMain will be created.
#FORM TFormMain, FormMain.sfm
uses
SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
ExtCtrls, ComCtrls, Buttons, Data
Dim LayoutData as TData ' initialized in FormCreate event and destroyed in FormDestroy

Before it is possible to create the a layout data object in FormMainCreate it is necessary to create this form
event:

Switch to the design view of FormMain


Select the form itself
Switch to events tab in the properties window
Double click the OnCreate event entry and the event handler will be created automatically
Cut and paste the new event handler before the existing function FormMainShow

In the function FormMainCreate insert the data object creation code line:
SUB FormMainCreate(Sender AS TObject)
LayoutData = new TData
END SUB
SUB FormMainShow(Sender AS TObject)
UpdateLaserStatus
UpdateParameterStatus
UpdateProjectName
UpdatePreview
SetEvents

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

80 / 135

END SUB
SUB FormMainDestroy(Sender AS TObject)
UnsetEvents
END SUB

To free the object when the form ends, insert the following statement into the function FormMainDestroy:
SUB FormMainDestroy(Sender AS TObject)
LayoutData.Free
LayoutData = nothing
UnsetEvents
END SUB

Now that the data object is created at form startup and destroyed when closing the script. The object is now
ready for usage.

8.3.8 Implementing key input handling


To read the key and start an automatic search in the data it is necessary to implement several events which
handle this workflow. Therefore two ways will be implemented: either by pressing a search button and
pressing the Enter key within the input field.

Switch to the design view of FormMain


Add a new button to the form and name it ButtonSearchKey

Double click the button to create an OnClickEvent

Now we create the Enter key handling

Switch to the design view of FormMain


Select the key edit field
Switch to events tab in the properties window
Double click the OnKeyPress event entry and the event handler will be created automatically

The code of FormMain should now look like this:


SUB FormMainDestroy(Sender AS TObject)
FreeAndNil(LayoutData)
UnsetEvents
END SUB
SUB ButtonSearchKeyClick(Sender AS TObject)
END SUB
SUB EditKeyKeyPress(Sender AS TObject, BYREF Key AS Char)
END SUB
SUB ButtonStartClick(Sender AS TObject)

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

81 / 135

SpeedMark.ExecuteProject(Self.Handle)
END SUB

The enter key handling will be implemented in the EditKeyKeyPress event handler. In this case just the event
handler of the button search will be called:
SUB EditKeyKeyPress (Sender AS TObject, BYREF Key AS Char)
if Key = Chr(13) then
ButtonSearchKeyClick(Sender)
end if
END SUB

The search button click event will then handle the search, data update and preview handling:
SUB ButtonSearchKeyClick(Sender AS TObject)
if LayoutData.ReadData(EditKey.Text) then
UpdateLayoutAndPreview
else
ClearData
MsgBox("Reading the data failed!")
end if
' Focus and selct the key field for the next input
EditKey.SetFocus
EditKey.SelectAll
END SUB

In the button search event handler two unknown functions are introduced which have to be implemented:
ClearData, UpdateData and UpdateLayoutAndPreview:
SUB ClearData
' clear the input fields
EditKey.Text = ""
EditTextValue1.Text = ""
EditTextValue2.Text = ""
EditVectorGraphic.Text = ""
EditRasterGraphic.Text = ""
' clear the preview
ImagePreview.Picture.Bitmap = nothing
END SUB
SUB UpdateData
EditKey.Text = LayoutData.Key
EditTextValue1.Text = LayoutData.TextValue1
EditTextValue2.Text = LayoutData.TextValue2
EditVectorGraphic.Text = LayoutData.VectorGraphic
EditRasterGraphic.Text = LayoutData.RasterGraphic
END SUB

Put after FormMainDestroy

8.3.9 Updating the preview


The update of the layout data including the preview and the main form will be done by sub
UpdateLayoutAndPreview. Put this sub after Clear data.
SUB UpdateLayoutAndPreview
' find the correct layout
Dim LayoutProgram as TScProgram = SpeedMark.CurrentProject.SubProgramByName[LayoutData.Layout]
if Assigned(LayoutProgram) then
ClearData
MsgBox("Layout was not found!")
return

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

82 / 135

end if
' update the layout and reset the changes
try
try
UpdateLayout(LayoutProgram, LayoutData)
catch
MsgBox("Failure during update of layout: " + LastExceptionMessage)
ClearData
end
finally
LayoutProgram.Modified = False
SpeedMark.CurrentProject.Modified = False ' reset modified flags
end
' update the preview
Dim Bitmap as TBitmap
Bitmap = new TBitmap
try
LayoutProgram.Graphics.UpdateGraphics ' update all graphics to ensure that all values are
correctly calculated
LayoutProgram.CreatePreviewBitmap(Bitmap, ImagePreview.Width, ImagePreview.Height, 1)
ImagePreview.Picture.Assign(Bitmap)
finally
Bitmap.Free
Bitmap = nothing
end
END SUB

8.4 Automating the startup


To automate the startup of
marking project and scripted
run screen open the settings
dialog in SpeedMark.
The section AutoStart
provides the fields Load
project on start and
Execute at startup Scripted
RunScreen to automate
SpeedMark.
It is possible to disable
autostarts by pressing the
shift key when starting
SpeedMark.

Another way to control


startups is the usage of
command line parameters.
SpeedMark.exe loadproject:<file path of the project> executerunscreen:<file path of scripted run screen>

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

83 / 135

Debugging of scripts

The scripting IDE supports debugging of scripts line by line including function step in and variable watching.

9.1 Debugging in general


9.1.1 Setting breakpoints on code lines
By clicking the line
number sidebar
with the mouse or
by pressing the F5
key a breakpoint is
set or unset.

9.1.2 Creating variable watches


By pressing the key combination Ctrl+F5 it is
possible to create variable watches which are
shown in the watch list window.

9.1.3 Debugging shortcuts


Shortcut

Action

F4

Run to cursor

F5

Toggle breakpoint

F7

Step into

F8

Step over

F9

Run

Shift+F9

Pause

Ctrl+F2

Reset

Shift+F11

Run until return

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

84 / 135

10

Class and function reference

This chapter describes the available functions and classes in the different units. Unless all chapters are
important, three of them are important for daily use:

10.3.1 Default system functions on page 86


10.3.2 Default Visual Basic related functions on page 89
10.4.8 Unit: SysUtils on page 115

10.1 Explanations of terms or abbreviations


Definition

Description

Constants

Are defined with fixed values

Enumerations

Are named types with a list of possible values. E.g. TfloatFormat =


(ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency). In case of method
parameter types you know that you can use a constant like ffGeneral.
Enumerations always start with zero which means ffGeneral=0,
ffExponent=1,

Create method

The create methods stated in the class definitions show which parameters
have to be passed with the new statement. If no create method is defined no
parameters have to be passed

10.2 Default base class


The base class of all object classes is TObject. This class provides basic methods to create an object with the
new operator and a method Free to destroy the object. With some classes it is possible or necessary to
pass some parameters during creation with new.
Dim BitmapStream as TFileStream
BitmapStream = new TFileStream(aFileName, fmCreate)
try
...
' work with the stream
...
finally
BitmapStream.Free
BitmapStream = nothing
end

Object lifecycle handling example


Dim BitmapStream as TFileStream
BitmapStream = new TFileStream(aFileName, fmCreate)
try
...
' work with the stream
...
finally
FreeAndNil(BitmapStream)
end

Object lifecycle handling with SysUtils.FreeAndNil function

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

85 / 135

10.3 Default function and classes


In case of the following functions and classes it is not necessary to make an entry in the uses clause of a
scripting unit. These functions are available by default. This behaviour relates to Default system functions as
well as Default Visual Basic related functions.

10.3.1 Default system functions


Function name

Returns

Parameters

Description

Abs

Float

X as Real

Absolut value of a given number

AnsiCompareStr

String

S1:String, S2 as String

AnsiCompareText

String

S1 as String, S2 as String

AnsiLowerCase

String

S as String

AnsiUpperCase

String

S as String

ArcTan

Float

X as extended

Assigned

Integer

P as Variant

Beep
Chdir

S as String

Chr

String

X as Byte

CompareStr

Integer

S1 as String, S2 as String

CompareText

Integer

S1 as String, S2:String

Copy

String

S as String, Index as integer,


Count as integer

Cos

Float

X as extended

CreateOleObject

Variant

ClassName as String

Date

Float

DateTimeToStr

String

DateTime as TDateTime

DateToStr

String

DateTime as TDateTime

DayOfWeek

Integer

Datetime as TDateTime

Dec

Integer

byref X as Ordinal

DecodeDate

Integer

DateTime as TDateTime, byref


Year as Word, byref Month as
Word, byref Day as Word

DecodeTime

Integer

DateTime as TDateTime, byref


Hour as Word, byref Min as
Word, byref Sec as Word, byref
MSec as Word

Delete

String

byref S as String, Index as


integer, Count as integer

EncodeDate

Float

Year as Word, Month as Word,


Day as Word

EncodeTime

Float

Hour as Word, Min as Word,


Sec as Word, MSec as Word

Exp

Float

X as extended

FloatToStr

String

Value as extended

Format

String

Format as String, Args as

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

86 / 135

Function name

Returns

Parameters

Description

VariantArray
FormatDateTime

Float

Format as String, DateTime as


TDateTime

FormatFloat

String

Format as String, Value as


extended

Frac

Float

X as extended

GetActiveOleObject

Variant

ClassName as String

High

Integer

X as VariantArray

Inc

Integer

byref X as Ordinal

IncMonth

Float

DateTime as TDateTime,
NumberOfMonths as integer

InputQuery

String

ACaption as String, APrompt as


String, byref Value as String

Insert

String

SubStr as String, byref Dest as


String, Index as integer

Int

Integer

X as extended

Interpret

ScriptCode as String

IntToHex

String

Value as integer, Digits as


integer

IntToStr

String

Value as integer

IsLeapYear

Integer

Year as Word

IsValidIdent

Integer

Ident as String

Length

Integer

S as String

Ln

Float

X as extended

Low

Integer

X as VariantArray

LowerCase

String

S as String

Machine

Class

Now

Float

Odd

Boolean

X as integer

Ord

Integer

X as Ordinal

Pos

Integer

SubStr as String, Str as String

Random

Float

Round

Integer

Scripter

Class

SetOf

Set

Values as VariantArray

ShowMessage

String

Msg as String

Sin

Float

X as extended

Sqr

Float

X as Real

Sqrt

Float

X as extended

StrToDate

Float

S as String

StrToDateTime

Float

S as String

StrToFloat

Float

S as String

StrToInt

Integer

S as String

StrToIntDef

Integer

S as String, Default as integer

13/02/2013

X as Real

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

87 / 135

Function name

Returns

Parameters

StrToTime

Float

S as String

Time

Float

TimeToStr

String

DateTime as TDateTime

Trim

String

S as String

TrimLeft

String

S as String

TrimRight

String

S as String

Trunc

Integer

X as Real

UpperCase

String

S as string

VarArrayCreate

Variant

Bounds as VariantArray,
AVarType as integer

VarArrayHighBound

Integer

A as variant, Dim as integer

VarArrayLowBound

Integer

A as variant, Dim as integer

VarIsNull

Integer

V as Variant

VarToStr

String

V as Variant

Description

Bounds (e.g. [0, 5])


AvarType:
varEmpty = $0000;
varNull = $0001;
varSmallint = $0002;
varInteger = $0003;
varSingle = $0004;
varDouble = $0005;
varCurrency = $0006;
varDate = $0007;
varOleStr = $0008;
varDispatch = $0009;
varError = $000A;
varBoolean = $000B;
varVariant = $000C;
varUnknown = $000D;
varShortInt = $0010;
varByte = $0011;
varWord = $0012;
varLongWord = $0013;
varInt64 = $0014;
varStrArg = $0048;
varString = $0100;
varAny
= $0101;
varTypeMask = $0FFF;
varArray = $2000;
varByRef = $4000;

Basic file handling functions


Function name

Returns

Parameters

AssignFile

TFileClass

byref F as File, FileName as


String

Reset

F as File

Rewrite

F as File

Append

F as File

CloseFile

F as File

Write

F as File, Value

WriteLn

F as File, Value

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

88 / 135

Function name

Returns

Parameters

ReadLn

Variant

F as File

EOF

Variant

F as File

FilePos

Integer

F as File

FileSize

Integer

F as File

Description

24

Exception handling helper functions and properties


Function name

Returns

Raise

Parameters

Description

ExceptionMsg as String

Property name

Returns

Description

LastExceptionMessage

String

Read-only. Returns the last available exception


message

LastExceptionHelpContext

Integer

LastExceptionClassName

String

10.3.2 Default Visual Basic related functions


Function name

Returns

Parameters

Asc

Integer

C as Char

Atn

Float

X as Extended

CBool

Boolean

V as Variant

CByte

Integer

V as Variant

CCur

Float

V as Variant

CDate

Float

V as Variant

CDbl

Float

V as Variant

CInt

Integer

V as Variant

CLng

Integer

V as Variant

CreateObject

Variant

ClassName as string

CSng

Float

V as Variant

CStr

String

V as Variant

DatePart

Integer

DatePart as string, DateTime as


TDateTime

DateSerial

Float

Year as Word, Month as Word,


Day as Word

DateValue

Float

DateTime as TDateTime

Day

Integer

DateTime as TDateTime

Fix

Integer

X as Real

FormatCurrency

String

Value as Real, Digits as integer

FormatDateTime

String

Value as TDateTime, Format as


integer

24

Description

//<-- Uses same as CInt

Format constants: vbGeneralDate = 0,


vbLongDate = 1, vbShortDate = 2,
vbLongTime = 3, vbShortTime = 4

Find additional exception handling statements in 6.1.17 Try catch finally on page 40

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

89 / 135

Function name

Returns

Parameters

FormatNumber

String

Value as Real, Digits as integer

Hex

String

X as Integer

Hour

Integer

DateTime as TDateTime

InputBox

Integer

APrompt as string, ACaption as


string, Value as string

InStr

Integer

Str as String, SubStr as String

Int

Integer

X as Real

IsArray

Boolean

V as Variant

IsDate

Boolean

V as Variant

IsEmpty

Boolean

V as Variant

IsNull

Boolean

V as Variant

IsNumeric

Boolean

V as Variant

Join

String

V as VariantArray, Delimiter as
Char = " "

LBound

Integer

V as VariantArray, Dim as
integer = 1

LCase

String

S as string

Left

String

S as string, Count as integer

Len

Integer

S as string

Log

Float

X as Extended

LTrim

String

S as string

Mid

String

S as string, Index as integer,


Count as integer

Minute

Integer

DateTime as TDateTime

Month

Integer

DateTime as TDateTime

MonthName

String

Month as integer, ShortName


as Boolean

MsgBox

Integer

Text as string, Caption as string


= "", Type as integer =
vbOkOnly

Description

Type constants (connect with or):


vbOKOnly=0, vbOKCancel=1,
vbAbortRetryIgnore=2,
vbYesNoCancel=3, vbYesNo=4,
vbRetryCancel=5, vbCritical=16,
vbQuestion=32, vbExclamation=48,
vbInformation=64, vbDefaultButton1=0,
vbDefaultButton2=256,
vbDefaultButton3=512,
vbDefaultButton4=768,
vbApplicationModal=0,
vbSystemModal=4096
Return constants:
vbOK = 1, vbCancel = 2, vbAbort = 3,
vbRetry = 4, vbIgnore = 5, vbYes = 6,
vbNo = 7

Randomize

???

Redim

Variant

???

10 Parameters

RedimPreserve

Variant

???

2 Parameters, first byref

Replace

String

S as string, OldPattern as
string, NewPattern as string

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

90 / 135

Function name

Returns

Parameters

Right

String

S as string, Count as integer

Rnd

Float

???

RTrim

String

S as string

Second

Integer

DateTime as TDateTime

Sgn

Integer

X as Real

Space

String

Count as integer

Split

Variant

S as string, Delimiter as Char =


" ", Count as integer=-1

StrComp

Integer

S1 as string, S2 as string

String

String

Count as integer, C as Char

StrReverse

String

S as string

Timer

Integer

TimeSerial

Float

Hour as Word, Min as Word,


Sec as Word

TimeValue

Float

DateTime as TDateTime

UBound

Integer

V as VariantArray, Dim as
integer = 1

UCase

String

S as string

Weekday

Integer

DateTime as TDateTime

WeekdayName

String

DateTime as TDateTime,
ShortName as boolean

Year

Integer

DateTime as TDateTime

13/02/2013

Description

Delphi function Random without


parameter

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

91 / 135

10.4 Functions and classes by units


In case of the following functions and classes it is necessary to make an entry in the uses:
uses Classes, SysUtils

example uses clause at the beginning of each scripting unit

10.4.1 Unit: Classes


Class TList
Property name

Returns

Description

Capacity

Integer

Get/set the capacity

Count

Integer

Get/set the count.

Method name

Returns

Parameters

Description

Clear
Delete

Index as Integer

Error

Msg as string, Data as Integer

Exchange

Index1 as Integer, Index2 as


Integer

Expand

TList

Move

CurIndex as Integer, NewIndex


as Integer

Pack
Assign

ListA as TList, AOperator as


TListAssignOp = laCopy, ListB
as TList = nil

Class TStrings
Property name

Returns

Description

Capacity

Integer

Get/set

CommaText

Variant

Get/set

Count

Integer

Read-only.

Delimiter

Variant

Get/set

DelimitedText

Variant

Get/set

Names

Variant [ ]

Read-only.

Objects

TObject [ ]

Get/set

QuoteChar

Variant

Get/set

Values

Variant [ ]

Get/set

ValueFromIndex

Variant [ ]

Get/set

NameValueSeparator

Variant

Get/set

DefinePropStrings

Variant [ ]

Default index property.


Get/set

Text

Variant

Get/set

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

92 / 135

Method name

Returns

Parameters

Description

Add

Integer

S as string

AddObject

Integer

S as string, AObject as TObject

Append

S as string

AddStrings

Strings as TStrings

Assign

Source as TPersistent

BeginUpdate
Clear
Delete

Index as Integer

EndUpdate
Equals

Variant

Exchange

Strings as TStrings
Index1 as Integer, Index2 as
Integer

GetText

Variant

IndexOf

Integer

S as string

IndexOfName

Integer

Name as string

IndexOfObject

Integer

AObject as TObject

Insert

Index as Integer, S as string

InsertObject

Index as Integer, S as string,


AObject as TObject

LoadFromFile

FileName as string

LoadFromStream

Stream as TStream

Move

CurIndex as Integer, NewIndex


as Integer

SaveToFile

FileName as string

SaveToStream

Stream as TStream

SetText

Text as PChar

Class TStringList
Enumeration name

Values

Description

TDuplicates

dupIgnore, dupAccept, dupError

Property name

Returns

Description

Duplicates

TDuplicates

Get/set .

Sorted

Variant

Get/set

CaseSensitive

Variant

Get/set

Method name

Returns

Parameters

Add

Integer

S as string

AddObject

Integer

S as string, AObject as TObject

Description

Clear
Delete

Index as Integer

Exchange

Index1 as Integer, Index2 as

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

93 / 135

Integer
Find

Variant

S as string, Index as
Integer).SetVarArgs([1]),

IndexOf

Integer

S as string

Insert

Index as Integer, S as string

InsertObject

Index as Integer, S as string,


AObject as TObject

Sort

TStream
Property name

Returns

Description

Position

Variant

Get/set

Size

Variant

Get/set

Method name

Returns

Parameters

Read

Integer

Buffer, Count as
Longint).SetVarArgs([0]

Write

Integer

Buffer, Count as Longint

Seek

Integer

Offset as Longint, Origin as


Word

Description

ReadBuffer

Buffer, Count as
Longint).SetVarArgs([0]

WriteBuffer

Buffer, Count as Longint

CopyFrom

Variant

Source as TStream, Count as


Int64

ReadComponent

TComponent

Instance as TComponent

ReadComponentRes

TComponent

Instance as TComponent

WriteComponent

Instance as TComponent

WriteComponentRes

ResName as string, Instance


as TComponent

WriteDescendent

Instance as TComponent,
Ancestor as TComponent

WriteDescendentRes

ResName as string, Instance


as TComponent, Ancestor as
TComponent

WriteResourceHeader

ResName as string, byref


FixupInfo as Integer

FixupResourceHeader

FixupInfo as Integer

ReadResHeader

Class TFileStream (derived from TStream)


Property name

Returns

Description

Handle

Integer

Read-only.

Method name

Returns

Parameters

Create

TFileStream

AHandle as Integer

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

94 / 135

Create

TFileStream

FileName as string, Mode as


Word

Read

Integer

ByRef Buffer, Count as Longint

Write

Integer

Buffer, Count as Longint

Class TStringStream (derived from TStream)


Property name

Returns

Description

DataString

Variant

Read-only.

Method name

Returns

Parameters

Create

TStringStream

AString as string

Read

Integer

byref Buffer, Count as Longint

ReadString

Variant

Count as Longint

Seek

Integer

Offset as Longint, Origin as


Word

Write

Integer

Buffer, Count as Longint

WriteString

Description

AString as string

Class TCustomMemoryStream (derived from TStream)


Method name

Returns

Parameters

Read

Integer

byref Buffer, Count as Longint

Seek

Integer

Offset as Longint, Origin as


Word

SaveToStream

Stream as TStream

SaveToFile

FileName as string

Description

Class TMemoryStream (derived from TCustomMemoryStream)


Method name

Returns

Parameters

Read

Integer

byref Buffer, Count as Longint

Seek

Integer

Offset as Longint, Origin as


Word

SaveToStream

Stream as TStream

SaveToFile

FileName as string

Description

Clear
LoadFromStream

Stream as TStream

LoadFromFile

FileName as string

SetSize

NewSize as Longint

Write

Integer

Buffer, Count as Longint

Class TResourceStream (derived from TCustomMemoryStream)


Method name

Returns

Parameters

Create

TResourceStream

Instance as THandle,

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

95 / 135

ResName as string,
ResType as PChar
CreateFromID

TResourceStream

Instance as THandle,
ResID as Integer,
ResType as PChar

Write

Integer

Buffer, Count as Longint

10.4.2 Unit: Clipbrd


Unit properties and functions
Property name

Returns

Description

CF_PICTURE

Integer

Get/set

CF_COMPONENT'

Integer

Get/set

Function name

Returns

Clipboard

TClipboard

SetClipboard

TClipboard

Parameters

Description

NewClipboard as
TClipboard

Class TClipborad
Property name

Returns

Description

AsText

Variant

Get/set

FormatCount

Integer

Read-only.

Formats

Integer [ ]

Read-only.

Method name

Returns

Assign

Parameters

Description

Source as TPersistent

Clear
Close
GetComponent

TComponent

Owner as TComponent,
Parent as TComponent

GetAsHandle

Integer

Format as Word

GetTextBuf

Integer

Buffer as PChar, BufSize


as Integer

HasFormat

Variant

Format as Word

Open
SetComponent

Component as
TComponent

SetAsHandle

Format as Word, Value as


THandle

SetTextBuf

Buffer as PChar

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

96 / 135

10.4.3 Unit: DateUtils


Defined in default system unit: TDateTime = type Double

Unit properties and functions


Constant name

Value

Description

Enumeration name

Values

Description

TDuplicates

dupIgnore, dupAccept, dupError

TValueRelationship

-1 .. 1

Property name

Returns

Description

ApproxDaysPerMonth

Variant

Get/set

ApproxDaysPerYear

Variant

Get/set

Function name

Returns

Parameters

DateOf

Variant

AValue as TDateTime

TimeOf

Variant

AValue as TDateTime

IsInLeapYear

Variant

AValue as TDateTime

IsPM

Variant

AValue as TDateTime

IsValidDate

Variant

AYear as Word, AMonth


as Word, ADay as Word

IsValidTime

Variant

AHour as Word, AMinute


as Word, ASecond as
Word, AMilliSecond as

DaysPerWeek
WeeksPerFortnight
MonthsPerYear
YearsPerDecade
YearsPerCentury
YearsPerMillennium
DayMonday
DayTuesday
DayWednesday
DayThursday
DayFriday
DaySaturday
DaySunday
OneHour
OneMinute
OneSecond
OneMillisecond
RecodeLeaveFieldAsIs

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

97 / 135

Function name

Returns

Parameters

Description

Word
IsValidDateTime

Variant

AYear as Word, AMonth


as Word, ADay as Word,
AHour as Word, AMinute
as Word, ASecond as
Word, AMilliSecond as
Word

IsValidDateDay

Variant

AYear as Word,
ADayOfYear as Word

IsValidDateWeek

Variant

AYear as Word,
AWeekOfYear as Word,
ADayOfWeek as Word

IsValidDateMonthWeek

Variant

AYear as Word, AMonth


as Word, AWeekOfMonth
as Word, ADayOfWeek as
Word

WeeksInYear

Integer

AValue as TDateTime

WeeksInAYear

Integer

AYear as Word

DaysInYear

Integer

AValue as TDateTime

DaysInAYear

Integer

AYear as Word

DaysInMonth

Integer

AValue as TDateTime

DaysInAMonth

Integer

AYear as Word, AMonth


as Word

Today

Variant

Yesterday

Variant

Tomorrow

Variant

IsToday

Variant

AValue as TDateTime

IsSameDay

Variant

AValue as TDateTime,
ABasis as TDateTime

YearOf

Integer

AValue as TDateTime

MonthOf

Integer

AValue as TDateTime

WeekOf

Integer

AValue as TDateTime

DayOf

Integer

AValue as TDateTime

HourOf

Integer

AValue as TDateTime

MinuteOf

Integer

AValue as TDateTime

SecondOf

Integer

AValue as TDateTime

MilliSecondOf

Integer

AValue as TDateTime

StartOfTheYear

Variant

AValue as TDateTime

EndOfTheYear

Variant

AValue as TDateTime

StartOfAYear

Variant

AYear as Word

EndOfAYear

Variant

AYear as Word

StartOfTheMonth

Variant

AValue as TDateTime

EndOfTheMonth

Variant

AValue as TDateTime

StartOfAMonth

Variant

AYear as Word, AMonth


as Word

EndOfAMonth

Variant

AYear as Word, AMonth


as Word

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

98 / 135

Function name

Returns

Parameters

StartOfTheWeek

Variant

AValue as TDateTime

EndOfTheWeek

Variant

AValue as TDateTime

StartOfAWeek

Variant

AYear as Word,
AWeekOfYear as Word,
ADayOfWeek as Word = 1

EndOfAWeek

Variant

AYear as Word,
AWeekOfYear as Word,
ADayOfWeek as Word = 7

StartOfTheDay

Variant

AValue as TDateTime

EndOfTheDay

Variant

AValue as TDateTime

StartOfADay

Variant

AYear as Word, AMonth


as Word, ADay as Word

EndOfADay

Variant

AYear as Word, AMonth


as Word, ADay as Word

MonthOfTheYear

Integer

AValue as TDateTime

WeekOfTheYear

Integer

AValue as TDateTime

DayOfTheYear

Integer

AValue as TDateTime

HourOfTheYear

Integer

AValue as TDateTime

MinuteOfTheYear

Integer

AValue as TDateTime

SecondOfTheYear

Integer

AValue as TDateTime

MilliSecondOfTheYear

Variant

AValue as TDateTime

WeekOfTheMonth

Integer

AValue as TDateTime

DayOfTheMonth

Integer

AValue as TDateTime

HourOfTheMonth

Integer

AValue as TDateTime

MinuteOfTheMonth

Integer

AValue as TDateTime

SecondOfTheMonth

Integer

AValue as TDateTime

MilliSecondOfTheMonth

Integer

AValue as TDateTime

DayOfTheWeek

Integer

AValue as TDateTime

HourOfTheWeek

Integer

AValue as TDateTime

MinuteOfTheWeek

Integer

AValue as TDateTime

SecondOfTheWeek

Integer

AValue as TDateTime

MilliSecondOfTheWeek

Integer

AValue as TDateTime

HourOfTheDay

Integer

AValue as TDateTime

MinuteOfTheDay

Integer

AValue as TDateTime

SecondOfTheDay

Integer

AValue as TDateTime

MilliSecondOfTheDay

Integer

AValue as TDateTime

MinuteOfTheHour

Integer

AValue as TDateTime

SecondOfTheHour

Integer

AValue as TDateTime

MilliSecondOfTheHour

Integer

AValue as TDateTime

SecondOfTheMinute

Integer

AValue as TDateTime

MilliSecondOfTheMinute

Integer

AValue as TDateTime

MilliSecondOfTheSecond

Integer

AValue as TDateTime

WithinPastYears

Variant

ANow as TDateTime,
AThen as TDateTime,

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

99 / 135

Function name

Returns

Parameters

Description

AYears as Integer
WithinPastMonths

Variant

ANow as TDateTime,
AThen as TDateTime,
AMonths as Integer

WithinPastWeeks

Variant

ANow as TDateTime,
AThen as TDateTime,
AWeeks as Integer

WithinPastDays

Variant

ANow as TDateTime,
AThen as TDateTime,
ADays as Integer

WithinPastHours

Variant

ANow as TDateTime,
AThen as TDateTime,
AHours as Int64

WithinPastMinutes

Variant

ANow as TDateTime,
AThen as TDateTime,
AMinutes as Int64

WithinPastSeconds

Variant

ANow as TDateTime,
AThen as TDateTime,
ASeconds as Int64

WithinPastMilliSeconds

Variant

ANow as TDateTime,
AThen as TDateTime,
AMilliSeconds as Int64

YearsBetween

Integer

ANow as TDateTime,
AThen as TDateTime

MonthsBetween

Integer

ANow as TDateTime,
AThen as TDateTime

WeeksBetween

Integer

ANow as TDateTime,
AThen as TDateTime

DaysBetween

Integer

ANow as TDateTime,
AThen as TDateTime

HoursBetween

Variant

ANow as TDateTime,
AThen as TDateTime

MinutesBetween

Variant

ANow as TDateTime,
AThen as TDateTime

SecondsBetween

Variant

ANow as TDateTime,
AThen as TDateTime

MilliSecondsBetween

Variant

ANow as TDateTime,
AThen as TDateTime

YearSpan

Variant

ANow as TDateTime,
AThen as TDateTime

MonthSpan

Variant

ANow as TDateTime,
AThen as TDateTime

WeekSpan

Variant

ANow as TDateTime,
AThen as TDateTime

DaySpan

Variant

ANow as TDateTime,
AThen as TDateTime

HourSpan

Variant

ANow as TDateTime,
AThen as TDateTime

MinuteSpan

Variant

ANow as TDateTime,
AThen as TDateTime

SecondSpan

Variant

ANow as TDateTime,
AThen as TDateTime

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

100 / 135

Function name

Returns

Parameters

MilliSecondSpan

Variant

ANow as TDateTime,
AThen as TDateTime

IncYear

Variant

AValue as TDateTime,
ANumberOfYears as
Integer = 1

IncWeek

Variant

AValue as TDateTime,
ANumberOfWeeks as
Integer = 1

IncDay

Variant

AValue as TDateTime,
ANumberOfDays as
Integer = 1

IncHour

Variant

AValue as TDateTime,
ANumberOfHours as Int64
=1

IncMinute

Variant

AValue as TDateTime,
ANumberOfMinutes as
Int64 = 1

IncSecond

Variant

AValue as TDateTime,
ANumberOfSeconds as
Int64 = 1

IncMilliSecond

Variant

AValue as TDateTime,
ANumberOfMilliSeconds
as Int64 = 1

EncodeDateTime

Variant

AYear as Word, AMonth


as Word, ADay as Word,
AHour as Word, AMinute
as Word, ASecond as
Word, AMilliSecond as
Word

DecodeDateTime

AValue as TDateTime,
byref AYear as Word,
byref AMonth as Word,
byref ADay as Word, byref
AHour as Word, byref
AMinute as Word, byref
ASecond as Word, byref
AMilliSecond as Word

EncodeDateWeek

Variant

DecodeDateWeek

AYear as Word,
AWeekOfYear as Word,
ADayOfWeek as Word = 1
AValue as TDateTime,
byref AYear as Word,
byref AWeekOfYear as
Word, byref ADayOfWeek
as Word

EncodeDateDay

Variant

DecodeDateDay

AYear as Word,
ADayOfYear as Word
AValue as TDateTime,
byref AYear as Word,
byref ADayOfYear as
Word

EncodeDateMonthWeek

DecodeDateMonthWeek

13/02/2013

Description

Variant

AYear as Word, AMonth


as Word, AWeekOfMonth
as Word, ADayOfWeek as
Word
AValue as TDateTime,

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

101 / 135

Function name

Returns

Parameters

Description

byref AYear as Word,


byref AMonth as Word,
byref AWeekOfMonth as
Word, byref ADayOfWeek
as Word
TryEncodeDateTime

Variant

AYear as Word, AMonth


as Word, ADay as Word,
AHour as Word, AMinute
as Word, ASecond as
Word, AMilliSecond as
Word, AValue as
TDateTime).SetVarArgs([7
]

TryEncodeDateWeek

Variant

AYear as Word,
AWeekOfYear as Word,
AValue as TDateTime,
ADayOfWeek as Word =
1).SetVarArgs([2]

TryEncodeDateDay

Variant

AYear as Word,
ADayOfYear as Word,
AValue as
TDateTime).SetVarArgs([2
]

TryEncodeDateMonthWe
ek

Variant

AYear as Word, AMonth


as Word, AWeekOfMonth
as Word, ADayOfWeek as
Word, AValue as
TDateTime).SetVarArgs([4
]

RecodeYear

Variant

AValue as TDateTime,
AYear as Word

RecodeMonth

Variant

AValue as TDateTime,
AMonth as Word

RecodeDay

Variant

AValue as TDateTime,
ADay as Word

RecodeHour

Variant

AValue as TDateTime,
AHour as Word

RecodeMinute

Variant

AValue as TDateTime,
AMinute as Word

RecodeSecond

Variant

AValue as TDateTime,
ASecond as Word

RecodeMilliSecond

Variant

AValue as TDateTime,
AMilliSecond as Word

RecodeDate

Variant

AValue as TDateTime,
AYear as Word, AMonth
as Word, ADay as Word

RecodeTime

Variant

AValue as TDateTime,
AHour as Word, AMinute
as Word, ASecond as
Word, AMilliSecond as
Word

RecodeDateTime

Variant

AValue as TDateTime,
AYear as Word, AMonth
as Word, ADay as Word,
AHour as Word, AMinute
as Word, ASecond as

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

102 / 135

Function name

Returns

Parameters

Description

Word, AMilliSecond as
Word
TryRecodeDateTime

Variant

AValue as TDateTime,
AYear as Word, AMonth
as Word, ADay as Word,
AHour as Word, AMinute
as Word, ASecond as
Word, AMilliSecond as
Word, byref AResult as
TdateTime

CompareDateTime

TValueRelationshi
p

A as TDateTime, B as
TdateTime

SameDateTime

Variant

A as TDateTime, B as
TdateTime

CompareDate

TValueRelationshi
p

A as TDateTime, B as
TdateTime

SameDate

Variant

A as TDateTime, B as
TdateTime

CompareTime

TValueRelationshi
p

A as TDateTime, B as
TdateTime

SameTime

Variant

A as TDateTime, B as
TdateTime

NthDayOfWeek

Integer

AValue as TDateTime

DecodeDayOfWeekInMo
nth

AValue as TDateTime,
byref AYear as Word,
byref AMonth as Word,
byref ANthDayOfWeek as
Word, byref ADayOfWeek
as Word

EncodeDayOfWeekInMo
nth

Variant

AYear as Word, AMonth


as Word,
ANthDayOfWeek as
Word, ADayOfWeek as
Word

TryEncodeDayOfWeekIn
Month

Variant

AYear as Word, AMonth


as Word,
ANthDayOfWeek as
Word, ADayOfWeek as
Word, byref AValue as
TDateTime

InvalidDateTimeError

AYear as Word, AMonth


as Word, ADay as Word,
AHour as Word, AMinute
as Word, ASecond as
Word, AMilliSecond as
Word, ABaseDate as
TDateTime = 0

InvalidDateWeekError

AYear as Word,
AWeekOfYear as Word,
ADayOfWeek as Word

InvalidDateDayError

AYear as Word,
ADayOfYear as Word

InvalidDateMonthWeekEr
ror

AYear as Word, AMonth


as Word, AWeekOfMonth
as Word, ADayOfWeek as
Word

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

103 / 135

Function name

Returns

InvalidDayOfWeekInMont
hError

Parameters

Description

AYear as Word, AMonth


as Word,
ANthDayOfWeek as
Word, ADayOfWeek as
Word

DateTimeToJulianDate

Variant

AValue as TDateTime

JulianDateToDateTime

Variant

AValue as Double

TryJulianDateToDateTim
e

Variant

AValue as Double, byref


ADateTime as TDateTime

DateTimeToModifiedJulia
nDate

Variant

AValue as TDateTime

ModifiedJulianDateToDat
eTime

Variant

AValue as Double

TryModifiedJulianDateTo
DateTime

Variant

AValue as Double, byref


ADateTime as TDateTime

DateTimeToUnix

Variant

AValue as TDateTime

UnixToDateTime

Variant

AValue as Int64

10.4.4 Unit: IniFiles


TCustomIniFile (abstract base class)
Property name

Returns

Description

FileName

Variant

Read-only.

Method name

Returns

Parameters

Create

TCustomIniFile

FileName as string

SectionExists

Variant

Section as string

ReadString

Variant

Section as string, Ident as


string, Default as string

WriteString
ReadInteger

Section as String, Ident as


String, Value as String
Integer

WriteInteger
ReadBool

Section as string, Ident as


string, Default as Longint
Section as string, Ident as
string, Value as Longint

Variant

WriteBool

Section as string, Ident as


string, Default as Boolean
Section as string, Ident as
string, Value as Boolean

ReadBinaryStream

Integer

Section as string, Name


as string, Value as
TStream

ReadDate

Variant

Section as string, Name


as string, Default as
TDateTime

ReadDateTime

Variant

Section as string, Name


as string, Default as
TDateTime

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

104 / 135

Method name

Returns

Parameters

Description

ReadFloat

Variant

Section as string, Name


as string, Default as
Double

ReadTime

Variant

Section as string, Name


as string, Default as
TDateTime

WriteBinaryStream

Section as string, Name


as string, Value as
TStream

WriteDate

Section as string, Name


as string, Value as
TDateTime

WriteDateTime

Section as string, Name


as string, Value as
TDateTime

WriteFloat

Section as string, Name


as string, Value as Double

WriteTime

Section as string, Name


as string, Value as
TDateTime

ReadSection

Section as string, Strings


as TStrings

ReadSections

Strings as TStrings

ReadSectionValues

Section as string, Strings


as TStrings

EraseSection

Section as string

DeleteKey

Section as String, Ident as


String

UpdateFile
ValueExists

Variant

Section as string, Ident as


string

Class TMemInifFile (derived from TCustomIniFile)


Property name

Returns

Description

CaseSensitive

Variant

Get/set

Method name

Returns

Parameters

Create

TMemIniFile

FileName as string

Description

Clear
DeleteKey

Section as String, Ident as


String

EraseSection

Section as string

GetStrings

List as TStrings

ReadSection

Section as string, Strings


as TStrings

ReadSections

Strings as TStrings

ReadSectionValues

Section as string, Strings


as TStrings

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

105 / 135

Method name

Returns

Parameters

Description

ReadString

Variant

Section as string, Ident as


string, Default as string

Rename

FileName as string, Reload


as Boolean

SetStrings

List as TStrings

UpdateFile
WriteString

Section as String, Ident as


String, Value as String

TIniFile (derived from TCustomIniFile)


Method name

Returns

Parameters

Description

ReadString

Variant

Section as string, Ident as


string, Default as string

WriteString

Section as String, Ident as


String, Value as String

ReadSection

Section as string, Strings


as TStrings

ReadSections

Strings as TStrings

ReadSectionValues

Section as string, Strings


as TStrings

EraseSection

Section as string

DeleteKey

Section as String, Ident as


String

UpdateFile

10.4.5 Unit: Math


Unit properties and functions
Constant name

Value

MinSingle

1.5e-45

MaxSingle

3.4e+38

MinDouble

5.0e-324

MaxDouble

1.7e+308

NaN

0.0 / 0.0

Infinity

1.0 / 0.0

NegInfinity

-1.0 / 0.0

NegativeValue

-1

ZeroValue

PositiveValue

Enumeration name

Values

TValueSign

-1..1

13/02/2013

Description

The following constants should not be used for


comparison, only assignments. For comparison please
use the IsNan and IsInfinity functions provided below.

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

106 / 135

Enumeration name

Values

TValueRelationship

-1..1

TPaymentTime

ptEndOfPeriod, ptStartOfPeriod

TFPURoundingMode

rmNearest, rmDown, rmUp,


rmTruncate

TFPUPrecisionMode

pmSingle, pmReserved,
pmDouble, pmExtended

TFPUException

exInvalidOp, exDenormalized,
exZeroDivide, exOverflow,
exUnderflow, exPrecision

Function name

Returns

Parameters

ArcCos

Variant

X as Extended

ArcSin

Variant

X as Extended

ArcTan2

Variant

Y as Extended, X as
Extended

SinCos

Description

Theta as Extended, byref


Sin as Extended, byref
Cos as Extended

Tan

Variant

X as Extended

Cotan

Variant

X as Extended

Secant

Variant

X as Extended

Cosecant

Variant

X as Extended

Hypot

Variant

X as Extended, Y as
Extended

RadToDeg

Variant

Radians as Extended

RadToGrad

Variant

Radians as Extended

RadToCycle

Variant

Radians as Extended

DegToRad

Variant

Degrees as Extended

DegToGrad

Variant

Degrees as Extended

DegToCycle

Variant

Degrees as Extended

GradToRad

Variant

Grads as Extended

GradToDeg

Variant

Grads as Extended

GradToCycle

Variant

Grads as Extended

CycleToRad

Variant

Cycles as Extended

CycleToDeg

Variant

Cycles as Extended

CycleToGrad

Variant

Cycles as Extended

Cot

Variant

X as Extended

Sec

Variant

X as Extended

Csc

Variant

X as Extended

Cosh

Variant

X as Extended

Sinh

Variant

X as Extended

Tanh

Variant

X as Extended

CotH

Variant

X as Extended

SecH

Variant

X as Extended

CscH

Variant

X as Extended

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

107 / 135

Function name

Returns

Parameters

ArcCot

Variant

X as Extended

ArcSec

Variant

X as Extended

ArcCsc

Variant

X as Extended

ArcCosh

Variant

X as Extended

ArcSinh

Variant

X as Extended

ArcTanh

Variant

X as Extended

ArcCotH

Variant

X as Extended

ArcSecH

Variant

X as Extended

ArcCscH

Variant

X as Extended

LnXP1

Variant

X as Extended

Log10

Variant

X as Extended

Log2

Variant

X as Extended

LogN

Variant

Base as Extended, X as
Extended

IntPower

Variant

Base as Extended,
Exponent as Integer

Power

Variant

Base as Extended,
Exponent as Extended

Frexp

X as Extended, byref
Mantissa as Extended,
byref Exponent as Integer

Ldexp

Variant

X as Extended, P as
Integer

Ceil

Integer

X as Extended

Floor

Integer

X as Extended

Min

Integer

A as Integer, B as Integer

Max

Integer

A as Integer, B as Integer

RandG

Variant

Mean as Extended,
StdDev as Extended

IsNan

Variant

AValue as Double

IsInfinite

Variant

AValue as Double

Sign

TValueSign

AValue as Integer

CompareValue

TValueRelationship

A as Extended, B as
Extended, Epsilon as
Extended = 0

SameValue

Variant

A as Extended, B as
Extended, Epsilon as
Extended = 0

IsZero

Variant

A as Extended, Epsilon as
Extended = 0

IfThen

Integer

AValue as Boolean, ATrue


as Integer, AFalse as
Integer = 0

RandomRange

Integer

AFrom as Integer, ATo as


Integer

InRange

Variant

AValue as Integer, AMin


as Integer, AMax as

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

108 / 135

Function name

Returns

Parameters

Description

Integer
EnsureRange

Integer

DivMod

AValue as Integer, AMin


as Integer, AMax as
Integer
Dividend as Integer,
Divisor as Word, byref
Result as Word, byref
Remainder as Word

RoundTo

Variant

AValue as Double, ADigit


as TRoundToRange

SimpleRoundTo

Variant

AValue as Double, ADigit


as TRoundToRange = -2

DoubleDecliningBalance

Variant

Cost as Extended,
Salvage as Extended, Life
as Integer, Period as
Integer

FutureValue

Variant

Rate as Extended,
NPeriods as Integer,
Payment as Extended,
PresentValue as
Extended, PaymentTime
as TPaymentTime

InterestPayment

Variant

Rate as Extended, Period


as Integer, NPeriods as
Integer, PresentValue as
Extended, FutureValue as
Extended, PaymentTime
as TPaymentTime

InterestRate

Variant

NPeriods as Integer,
Payment as Extended,
PresentValue as
Extended, FutureValue as
Extended, PaymentTime
as TPaymentTime

NumberOfPeriods

Variant

Rate as Extended,
Payment as Extended,
PresentValue as
Extended, FutureValue as
Extended, PaymentTime
as TPaymentTime

Payment

Variant

Rate as Extended,
NPeriods as Integer,
PresentValue as
Extended, FutureValue as
Extended, PaymentTime
as TPaymentTime

PeriodPayment

Variant

Rate as Extended, Period


as Integer, NPeriods as
Integer, PresentValue as
Extended, FutureValue as
Extended, PaymentTime
as TPaymentTime

PresentValue

Variant

Rate as Extended,
NPeriods as Integer,
Payment as Extended,
FutureValue as Extended,
PaymentTime as
TPaymentTime

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

109 / 135

Function name

Returns

Parameters

SLNDepreciation

Variant

Cost as Extended,
Salvage as Extended, Life
as Integer

SYDDepreciation

Variant

Cost as Extended,
Salvage as Extended, Life
as Integer, Period as
Integer

GetRoundMode

TFPURoundingMode

SetRoundMode

TFPURoundingMode

GetPrecisionMode

TFPUPrecisionMode

SetPrecisionMode

TFPUPrecisionMode

GetExceptionMask

TFPUExceptionMask

SetExceptionMask

TFPUExceptionMask

ClearExceptions

Description

RoundMode as
TFPURoundingMode

Precision as
TFPUPrecisionMode

Mask as
TFPUExceptionMask
RaisePending as Boolean
= True

10.4.6 Unit: Registry


Unit properties and functions
Enumeration name

Values

Description

TRegDataType

rdUnknown, rdString,
rdExpandString, rdInteger,
rdBinary

Record TRegDataInfo
Element name

Returns

Description

RegData

TRegDataType

Get/set

DataSize

Integer

Get/set

Property name

Returns

Description

CurrentKey

Integer

Read-only.

CurrentPath

Variant

Read-only.

LazyWrite

Variant

Get/set

RootKey

Integer

Get/set

Access

Integer

Get/set

Method name

Returns

Create

TRegistry

Class TRegistry

Parameters

Description

CloseKey
CreateKey

13/02/2013

Variant

Key as string

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

110 / 135

Method name

Returns

Parameters

DeleteKey

Variant

Key as string

DeleteValue

Variant

Name as string

GetDataInfo

Variant

ValueName as string, byref


Value as TRegDataInfo

GetDataSize

Integer

ValueName as string

GetDataType

TRegDataType

ValueName as string

GetKeyInfo

Variant

Byref Value as
TRegKeyInfo

GetKeyNames

Strings as TStrings

GetValueNames

Strings as TStrings

HasSubKeys

Variant

KeyExists

Variant

Key as string

LoadKey

Variant

Key as string, FileName as


string

MoveKey

OldName as string,
NewName as string, Delete
as Boolean

OpenKey

Variant

Key as string, CanCreate


as Boolean

OpenKeyReadOnly

Variant

Key as String

ReadCurrency

Variant

Name as string

ReadBinaryData

Integer

Name as string, byref


Buffer, BufSize as Integer

ReadBool

Variant

Name as string

ReadDate

Variant

Name as string

ReadDateTime

Variant

Name as string

ReadFloat

Variant

Name as string

ReadInteger

Integer

Name as string

ReadString

Variant

Name as string

ReadTime

Variant

Name as string

RegistryConnect

Variant

UNCName as string

RenameValue

OldName as string,
NewName as string

ReplaceKey

Variant

Key as string, FileName as


string, BackUpFileName as
string

RestoreKey

Variant

Key as string, FileName as


string

SaveKey

Variant

Key as string, FileName as


string

UnLoadKey

Variant

Key as string

ValueExists

Variant

Name as string

WriteCurrency

Name as string, Value as


Currency

WriteBinaryData

Name as string, byref


Buffer, BufSize as Integer

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

111 / 135

Method name

Returns

Parameters

WriteBool

Name as string, Value as


Boolean

WriteDate

Name as string, Value as


TDateTime

WriteDateTime

Name as string, Value as


TDateTime

WriteFloat

Name as string, Value as


Double

WriteInteger

Name as string, Value as


Integer

WriteString

Name as string, Value as


string

WriteExpandString

Name as string, Value as


string

WriteTime

Name as string, Value as


TDateTime

Description

Class TRegistryIniFile (derived from IniFiles.TCustomIniFile)


Method name

Returns

Parameters

Create

TRegistryIniFile

FileName as string

ReadDate

Variant

Section as string, Name as


string, Default as
TDateTime

ReadDateTime

Variant

Section as string, Name as


string, Default as
TDateTime

ReadInteger

Integer

Section as string, Ident as


string, Default as Longint

ReadFloat

Variant

Section as string, Name as


string, Default as Double

ReadString

Variant

Section as string, Ident as


string, Default as string

ReadTime

Variant

Section as string, Name as


string, Default as
TDateTime

ReadBinaryStream

Integer

Section as string, Name as


string, Value as TStream

WriteDate

Section as string, Name as


string, Value as TDateTime

WriteDateTime

Section as string, Name as


string, Value as TDateTime

WriteFloat

Section as string, Name as


string, Value as Double

WriteInteger

Section as string, Ident as


string, Value as Longint

WriteString

Section as String, Ident as


String, Value as String

WriteTime

Section as string, Name as


string, Value as TDateTime

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

112 / 135

WriteBinaryStream

Section as string, Name as


string, Value as TStream

ReadSection

Section as string, Strings


as TStrings

ReadSections

Strings as TStrings

ReadSectionValues

Section as string, Strings


as TStrings

EraseSection

Section as string

DeleteKey

Section as String, Ident as


String

UpdateFile

10.4.7 Unit: StrUtils


Unit properties and functions
Enumeration name

Values

TStringSeachOption

soDown, soMatchCase,
soWholeWord

Property name

Returns

Description

WordDelimiters

Integer

Read-only.

Function name

Returns

Parameters

AnsiResemblesText

Variant

AText as string, AOther as


string

AnsiContainsText

Variant

AText as string, ASubText


as string

AnsiStartsText

Variant

ASubText as string, AText


as string

AnsiEndsText

Variant

ASubText as string, AText


as string

AnsiReplaceText

Variant

AText as string, AFromText


as string, AToText as string

AnsiContainsStr

Variant

AText as string, ASubText


as string

AnsiStartsStr

Variant

ASubText as string, AText


as string

AnsiEndsStr

Variant

ASubText as string, AText


as string

AnsiReplaceStr

Variant

AText as string, AFromText


as string, AToText as string

DupeString

Variant

AText as string, ACount as


Integer

ReverseString

Variant

AText as string

AnsiReverseString

Variant

AText as AnsiString

StuffString

Variant

AText as string, AStart as


Cardinal, ALength as
Cardinal, ASubText as

13/02/2013

Description

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

113 / 135

string
IfThen

Variant

AValue as Boolean, ATrue


as string, AFalse as string
=

LeftStr

Variant

AText as AnsiString,
ACount as Integer

RightStr

Variant

AText as AnsiString,
ACount as Integer

MidStr

Variant

AText as AnsiString, AStart


as Integer, ACount as
Integer

LeftBStr

Variant

AText as AnsiString,
AByteCount as Integer

RightBStr

Variant

AText as AnsiString,
AByteCount as Integer

MidBStr

Variant

AText as AnsiString,
AByteStart as Integer,
AByteCount as Integer

AnsiLeftStr

Variant

AText as AnsiString,
ACount as Integer

AnsiRightStr

Variant

AText as AnsiString,
ACount as Integer

AnsiMidStr

Variant

AText as AnsiString, AStart


as Integer, ACount as
Integer

SearchBuf

Variant

Buf as PChar, BufLen as


Integer, SelStart as
Integer, SelLength as
Integer, SearchString as
String, Options as
TStringSearchOptions =
[soDown]

PosEx

Integer

SubStr as string, S as
string, Offset as Cardinal =
1

Soundex

Variant

AText as string, ALength


as TSoundexLength = 4

SoundexInt

Integer

AText as string, ALength


as TSoundexIntLength = 4

DecodeSoundexInt

Variant

AValue as Integer

SoundexWord

Integer

AText as string

DecodeSoundexWord

Variant

AValue as Word

SoundexSimilar

Variant

AText as string, AOther as


string, ALength as
TSoundexLength = 4

SoundexCompare

Integer

AText as string, AOther as


string, ALength as
TSoundexLength = 4

SoundexProc

Variant

AText as string, AOther as


string

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

114 / 135

10.4.8 Unit: SysUtils


Unit properties and functions
Constant name

Value

fmOpenRead

0x0000

fmOpenWrite

0x0001

fmOpenReadWrite

0x0002

fmShareCompat

0x0000

fmShareExclusive

0x0010

fmShareDenyWrite

0x0020

fmShareDenyRead

0x0030

fmShareDenyNone

0x0040

faReadOnly

0x00000001

faHidden

0x00000002

faSysFile

0x00000004

faVolumeID

0x00000008

faDirectory

0x00000010

faArchive

0x00000020

faSymLink

0x00000040

faAnyFile

0x0000003F

HoursPerDay

24

MinsPerHour

60

SecsPerMin

60

MsecsPerSec

1000

MinsPerDay

HoursPerDay * MinsPerHour

SecsPerDay

MinsPerDay * SecsPerMin

MsecsPerDay

SecsPerDay * MSecsPerSec

DateDelta

693594

Days between 1/1/0001 and 12/31/1899

UnixDateDelta

25569

Days between TDateTime basis (12/31/1899) and Unix


time_t basis (1/1/1970)

MaxEraCount

PathDelim

PathSep

DefaultTrueBoolStr

True

DefaultFalseBoolStr

False

Enumeration name

Values

TFloatValue

fvExtended, fvCurrency

TFloatFormat

ffGeneral, ffExponent, ffFixed,


ffNumber, ffCurrency

TMbcsByteType

mbSingleByte, mbLeadByte,
mbTrailByte

TFilenameCaseMatch

mkNone, mkExactMatch,
mkSingleMatch, mkAmbiguous

13/02/2013

Description

Description

MultiByte Character Set (MBCS) byte type

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

115 / 135

Property name

Returns

Description

EmptyStr

Variant

Get/set

EmptyWideStr

Variant

Get/set

Win32Platform

Integer

Get/set

Win32MajorVersion

Integer

Get/set

Win32MinorVersion

Integer

Get/set

Win32BuildNumber

Integer

Get/set

Win32CSDVersion

Variant

Get/set

CurrencyString

Variant

Get/set

CurrencyFormat

Integer

Get/set

NegCurrFormat

Integer

Get/set

ThousandSeparator

Variant

Get/set

DecimalSeparator

Variant

Get/set

CurrencyDecimals

Integer

Get/set

DateSeparator

Variant

Get/set

ShortDateFormat

Variant

Get/set

LongDateFormat

Variant

Get/set

TimeSeparator

Variant

Get/set

TimeAMString

Variant

Get/set

TimePMString

Variant

Get/set

ShortTimeFormat

Variant

Get/set

LongTimeFormat

Variant

Get/set

SysLocale

Variant

Get/set

TwoDigitYearCenturyWin
dow

Integer

Get/set

ListSeparator

Variant

Get/set

MinCurrency

Variant

Read-only.

MaxCurrency

Variant

Read-only.

MinDateTime

Variant

Read-only.

MaxDateTime

Variant

Read-only.

LeadBytes

Integer

Get/set

HexDisplayPrefix

Variant

Get/set

Function name

Returns

Parameters

CheckWin32Version

Variant

AMajor as Integer, AMinor


as Integer = 0

GetFileVersion

Integer

AFileName as string

Languages

TLanguages

AppendStr

byref Dest as string, S as


string

UpperCase

Variant

S as string

LowerCase

Variant

S as string

CompareStr

Integer

S1 as string, S2 as string

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

116 / 135

Function name

Returns

Parameters

CompareText

Integer

S1 as string, S2 as string

SameText

Variant

S1 as string, S2 as string

AnsiUpperCase

Variant

S as string

AnsiLowerCase

Variant

S as string

AnsiCompareStr

Integer

S1 as string, S2 as string

AnsiSameStr

Variant

S1 as string, S2 as string

AnsiCompareText

Integer

S1 as string, S2 as string

AnsiSameText

Variant

S1 as string, S2 as string

AnsiStrComp

Integer

S1 as PChar, S2 as PChar

AnsiStrIComp

Integer

S1 as PChar, S2 as PChar

AnsiStrLComp

Integer

S1 as PChar, S2 as PChar,
MaxLen as Cardinal

AnsiStrLIComp

Integer

S1 as PChar, S2 as PChar,
MaxLen as Cardinal

AnsiStrLower

Variant

Str as PChar

AnsiStrUpper

Variant

Str as PChar

AnsiLastChar

Variant

S as string

AnsiStrLastChar

Variant

P as PChar

WideUpperCase

Variant

S as WideString

WideLowerCase

Variant

S as WideString

WideCompareStr

Integer

S1 as WideString, S2 as
WideString

WideSameStr

Variant

S1 as WideString, S2 as
WideString

WideCompareText

Integer

S1 as WideString, S2 as
WideString

WideSameText

Variant

S1 as WideString, S2 as
WideString

Trim

Variant

S as string

TrimLeft

Variant

S as string

TrimRight

Variant

S as string

QuotedStr

Variant

S as string

AnsiQuotedStr

Variant

S as string, Quote as Char

AnsiExtractQuotedStr

Variant

Byref Src as PChar, Quote


as Char

AnsiDequotedStr

Variant

S as string, AQuote as
Char

AdjustLineBreaks

Variant

S as string, Style as
TTextLineBreakStyle =
tlbsCRLF

IsValidIdent

Variant

Ident as string

IntToStr

Variant

Value as Integer

IntToHex

Variant

Value as Integer, Digits as


Integer

StrToInt

Integer

S as string

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

117 / 135

Function name

Returns

Parameters

StrToIntDef

Integer

S as string, Default as
Integer

TryStrToInt

Variant

S as string, byref Value as


Integer

StrToInt64

Variant

S as string

StrToInt64Def

Variant

S as string, Default as
Int64

TryStrToInt64

Variant

S as string, byref Value as


Int64

StrToBool

Variant

S as string

StrToBoolDef

Variant

S as string, Default as
Boolean

TryStrToBool

Variant

S as string, byref Value as


Boolean

BoolToStr

Variant

B as Boolean, UseBoolStrs
as Boolean = False

LoadStr

Variant

Ident as Integer

FileOpen

Integer

FileName as string, Mode


as LongWord

FileCreate

Integer

FileName as string

FileRead

Integer

Handle as Integer, byref


Buffer, Count as LongWord

FileWrite

Integer

Handle as Integer, Buffer,


Count as LongWord

FileSeek

Integer

Handle as Integer, Offset


as Integer, Origin as
Integer

FileClose

Handle as Integer

FileAge

Integer

FileName as string

FileExists

Variant

FileName as string

DirectoryExists

Variant

Directory as string

ForceDirectories

Variant

Dir as string

FindFirst

Integer

Path as string, Attr as


Integer, byref F as
TSearchRec

FindNext

Integer

byref F as TSearchRec

FindClose

byref F as TSearchRec

FileGetDate

Integer

Handle as Integer

FileSetDate

Integer

FileName as string, Age as


Integer

FileGetAttr

Integer

FileName as string

FileSetAttr

Integer

FileName as string, Attr as


Integer

FileIsReadOnly

Variant

FileName as string

FileSetReadOnly

Variant

FileName as string,
ReadOnly as Boolean

DeleteFile

Variant

FileName as string

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

118 / 135

Function name

Returns

Parameters

RenameFile

Variant

OldName as string,
NewName as string

ChangeFileExt

Variant

FileName as string,
Extension as string

ExtractFilePath

Variant

FileName as string

ExtractFileDir

Variant

FileName as string

ExtractFileDrive

Variant

FileName as string

ExtractFileName

Variant

FileName as string

ExtractFileExt

Variant

FileName as string

ExpandFileName

Variant

FileName as string

ExpandFileNameCase

Variant

FileName as string, byref


MatchFound as
TFilenameCaseMatch

ExpandUNCFileName

Variant

FileName as string

ExtractRelativePath

Variant

BaseName as string,
DestName as string

ExtractShortPathName

Variant

FileName as string

FileSearch

Variant

Name as string, DirList as


string

DiskFree

Variant

Drive as Byte

DiskSize

Variant

Drive as Byte

FileDateToDateTime

Variant

FileDate as Integer

DateTimeToFileDate

Integer

DateTime as TDateTime

GetCurrentDir

Variant

SetCurrentDir

Variant

Dir as string

CreateDir

Variant

Dir as string

RemoveDir

Variant

Dir as string

StrLen

Integer

Str as PChar

StrEnd

Variant

Str as PChar

StrMove

Variant

Dest as PChar, Source as


PChar, Count as Cardinal

StrCopy

Variant

Dest as PChar, Source as


PChar

StrECopy

Variant

Dest as PChar, Source as


PChar

StrLCopy

Variant

Dest as PChar, Source as


PChar, MaxLen as
Cardinal

StrPCopy

Variant

Dest as PChar, Source as


string

StrPLCopy

Variant

Dest as PChar, Source as


string, MaxLen as Cardinal

StrCat

Variant

Dest as PChar, Source as


PChar

StrLCat

Variant

Dest as PChar, Source as


PChar, MaxLen as
Cardinal

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

119 / 135

Function name

Returns

Parameters

StrComp

Integer

Str1 as PChar, Str2 as


PChar

StrIComp

Integer

Str1 as PChar, Str2 as


PChar

StrLComp

Integer

Str1 as PChar, Str2 as


PChar, MaxLen as
Cardinal

StrLIComp

Integer

Str1 as PChar, Str2 as


PChar, MaxLen as
Cardinal

StrScan

Variant

Str as PChar, Chr as Char

StrRScan

Variant

Str as PChar, Chr as Char

StrPos

Variant

Str1 as PChar, Str2 as


PChar

StrUpper

Variant

Str as PChar

StrLower

Variant

Str as PChar

StrPas

Variant

Str as PChar

StrAlloc

Variant

Size as Cardinal

StrBufSize

Integer

Str as PChar

StrNew

Variant

Str as PChar

StrDispose

Str as PChar

FloatToStr

Variant

Value as Extended

CurrToStr

Variant

Value as Currency

FloatToCurr

Variant

Value as Extended

TryFloatToCurr

Variant

Value as Extended, byref


AResult as Currency

FloatToStrF

Variant

Value as Extended, Format


as TFloatFormat, Precision
as Integer, Digits as
Integer

CurrToStrF

Variant

Value as Currency, Format


as TFloatFormat, Digits as
Integer

FloatToText

Integer

BufferArg as PChar, Value,


ValueType as TFloatValue,
Format as TFloatFormat,
Precision as Integer, Digits
as Integer

FormatFloat

Variant

Format as string, Value as


Extended

FormatCurr

Variant

Format as string, Value as


Currency

FloatToTextFmt

Integer

Buf as PChar, Value,


ValueType as TFloatValue,
Format as PChar

StrToFloat

Variant

S as string

StrToFloatDef

Variant

S as string, Default as
Extended

TryStrToFloat

Variant

S as string, byref Value as


Extended

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

120 / 135

Function name

Returns

Parameters

StrToCurr

Variant

S as string

StrToCurrDef

Variant

S as string, Default as
Currency

TryStrToCurr

Variant

S as string, byref Value as


Currency

TextToFloat

Variant

Buffer as PChar, byref


Value, ValueType as
TFloatValue

FloatToDecimal

byref Result as TFloatRec,


Value, ValueType as
TFloatValue, Precision as
Integer, Decimals as
Integer

DateTimeToTimeStamp

Variant

DateTime as TDateTime

TimeStampToDateTime

Variant

TimeStamp as
TTimeStamp

MSecsToTimeStamp

Variant

MSecs as Comp

TimeStampToMSecs

Variant

TimeStamp as
TTimeStamp

EncodeDate

Variant

Year as Word, Month as


Word, Day as Word

EncodeTime

Variant

Hour as Word, Min as


Word, Sec as Word, MSec
as Word

TryEncodeDate

Variant

Year as Word, Month as


Word, Day as Word, byref
Date as TDateTime

TryEncodeTime

Variant

Hour as Word, Min as


Word, Sec as Word, MSec
as Word, byref Time as
TDateTime

DecodeDate

DateTime as TDateTime,
byref Year as Word, byref
Month as Word, byref Day
as Word

DecodeDateFully

Variant

DateTime as TDateTime,
byref Year as Word, byref
Month as Word, byref Day
as Word, baref DOW as
Word

DecodeTime

DateTime as TDateTime,
byref Hour as Word, byref
Min as Word, byref Sec as
Word, byref MSec as Word

DateTimeToSystemTime

DateTime as TDateTime,
byref SystemTime as
TSystemTime

SystemTimeToDateTime

Variant

SystemTime as
TSystemTime

DayOfWeek

Integer

DateTime as TDateTime

Date

Variant

Time

Variant

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

121 / 135

Function name

Returns

GetTime

Variant

Now

Variant

CurrentYear

Integer

IncMonth

Variant

Parameters

DateTime as TDateTime,
NumberOfMonths as
Integer = 1

IncAMonth

byref Year as Word, byref


Month as Word, byref Day
as Word, NumberOfMonths
as Integer = 1

ReplaceTime

byref DateTime as
TDateTime, NewTime as
TDateTime

ReplaceDate

byref DateTime as
TDateTime, NewDate as
TDateTime

IsLeapYear

Variant

Year as Word

DateToStr

Variant

DateTime as TDateTime

TimeToStr

Variant

DateTime as TDateTime

DateTimeToStr

Variant

DateTime as TDateTime

StrToDate

Variant

S as string

StrToDateDef

Variant

S as string, Default as
TDateTime

TryStrToDate

Variant

S as string, byref Value as


TDateTime

StrToTime

Variant

S as string

StrToTimeDef

Variant

S as string, Default as
TDateTime

TryStrToTime

Variant

S as string, byref Value as


TDateTime

StrToDateTime

Variant

S as string

StrToDateTimeDef

Variant

S as string, Default as
TDateTime

TryStrToDateTime

Variant

S as string, byref Value as


TDateTime

FormatDateTime

Variant

Format as string, DateTime


as TDateTime

DateTimeToString

byref Result as string,


Format as string, DateTime
as TDateTime

FloatToDateTime

Variant

Value as Extended

TryFloatToDateTime

Variant

Value as Extended, byref


AResult as TDateTime

SysErrorMessage

Variant

ErrorCode as Integer

GetLocaleStr

Variant

Locale as Integer,
LocaleType as Integer,
Default as string

GetLocaleChar

Variant

Locale as Integer,
LocaleType as Integer,
Default as Char

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

122 / 135

Function name

Returns

Parameters

Description

GetFormatSettings
GetLocaleFormatSettings

LCID as Integer, byref


FormatSettings as
TFormatSettings

Sleep

milliseconds as Cardinal

GetModuleName

Variant

Module as HMODULE

ByteType

TMbcsByteType

S as string, Index as
Integer

StrByteType

TMbcsByteType

Str as PChar, Index as


Cardinal

ByteToCharLen

Integer

S as string, MaxLen as
Integer

CharToByteLen

Integer

S as string, MaxLen as
Integer

ByteToCharIndex

Integer

S as string, Index as
Integer

CharToByteIndex

Integer

S as string, Index as
Integer

StrCharLength

Integer

Str as PChar

StrNextChar

Variant

Str as PChar

CharLength

Integer

S as String, Index as
Integer

NextCharIndex

Integer

S as String, Index as
Integer

IsPathDelimiter

Variant

S as string, Index as
Integer

IsDelimiter

Variant

Delimiters as string, S as
string, Index as Integer

IncludeTrailingPathDelimi
ter

Variant

S as string

IncludeTrailingBackslash

Variant

S as string

ExcludeTrailingPathDelim
iter

Variant

S as string

ExcludeTrailingBackslash

Variant

S as string

LastDelimiter

Integer

Delimiters as string, S as
string

AnsiCompareFileName

Integer

S1 as string, S2 as string

SameFileName

Variant

S1 as string, S2 as string

AnsiLowerCaseFileName

Variant

S as string

AnsiUpperCaseFileName

Variant

S as string

AnsiPos

Integer

Substr as string, S as
string

AnsiStrPos

Variant

Str as PChar, SubStr as


PChar

Abort
OutOfMemoryError
Beep

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

123 / 135

Function name

Returns

Parameters

AnsiStrRScan

Variant

Str as PChar, Chr as Char

AnsiStrScan

Variant

Str as PChar, Chr as Char

StringReplace

Variant

S as string, OldPattern as
string, NewPattern as
string, Flags as
TReplaceFlags

WrapText

Variant

Line as string, BreakStr as


string, BreakChars as
TSysCharSet, MaxCol as
Integer

FindCmdLineSwitch

Variant

Switch as string, Chars as


TSysCharSet, IgnoreCase
as Boolean

FreeAndNil

Description

byref Obj

Supports

Variant

Instance as TObject, IID as


TGUID, byref Intf

CreateGUID

Integer

byref Guid as TGUID

StringToGUID

Variant

S as string

GUIDToString

Variant

GUID as TGUID

IsEqualGUID

Variant

guid1 as TGUID, guid2 as


TGUID

LoadPackage

Integer

Name as string

UnloadPackage

Module as HMODULE

GetPackageDescription

Variant

ModuleName as PChar

InitializePackage

Module as HMODULE

FinalizePackage

Module as HMODULE

RaiseLastOSError
RaiseLastWin32Error
Win32Check

Variant

CallTerminateProcs

Variant

GDAL

Integer

RetVal as BOOL

RCS
RPR
SafeLoadLibrary

Integer

FileName as string,
ErrorMode as UINT =
SEM_NOOPENFILEERRO
RBOX

GetEnvironmentVariable

Variant

Name as string

Class TLanguages
Property name

Returns

Count

Integer

Name

Variant [ ]

NameFromLocaleID

Variant [ ]

NameFromLCID

Variant [ ]

ID

Variant [ ]

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

124 / 135

LocaleID

Integer [ ]

Ext

Variant [ ]

Method name

Returns

Create

TLanguages

IndexOf

Integer

Parameters

Description

ID as LCID

10.4.9 Unit: TextFileList


Unit properties
Property name

Returns

TextFileList

TTextFileList

Description

TTextFileList class
Method name

Returns

Parameters

Description

Clear
NewFile

FileName as string

LoadFile

FileName as string

SaveFile

FileName as string

ClearFile

FileName as string

GetFileLine

Variant

FileName as string, LineNumber


as Integer

AddFileLine

FileName as string, LineText as


string

DelFileLine

FileName as string, LineNumber


as Integer

SetFileLine

FileName as string, LineNumber


as Integer, LineText as string

GetFileLineCount

Integer

FileName as string

FindInFile

Integer

FileName as string, Substr as


string, CaseSensitive as
Boolean=True

FileExists

Variant

FileName as string

DeleteFile

Variant

FileName as string

CopyFile

Variant

SourceFileName as string,
TargetFileName as string

RenameFile

Variant

SourceFileName as string,
TargetFileName as string

MoveFile

Variant

SourceFileName as string,
TargetFileName as string

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

125 / 135

10.4.10 Unit: Unicode


Function name

Returns

Parameters

WideChr

WideString

X as Word

WideUpperCase

Variant

S as WideString

WideLowerCase

Variant

S as WideString

WideLastChar

Variant

S as WideString

WideStringReplace

Variant

S as WideString, OldPattern as
WideString, NewPattern as
WideString, Flags as
TReplaceFlags, WholeWord as
Boolean = False

WideWrapText

Variant

Line as WideString, BreakStr


as WideString, BreakChars as
TSysCharSet, MaxCol as
Integer

WideIncludeTrailingBacks
lash

Variant

S as WideString

WideIncludeTrailingPathD
elimiter

Variant

S as WideString

WideExcludeTrailingBack
slash

Variant

S as WideString

WideExcludeTrailingPath
Delimiter

Variant

S as WideString

WideIsDelimiter

Variant

Delimiters as WideString, S as
WideString, Index as Integer

WideIsPathDelimiter

Variant

S as WideString, Index as
Integer

WideLastDelimiter

Integer

Delimiters as WideString, S as
WideString

WideChangeFileExt

Variant

FileName as WideString,
Extension as WideString

WideExtractFilePath

Variant

FileName as WideString

WideExtractFileDir

Variant

FileName as WideString

WideExtractFileDrive

Variant

FileName as WideString

WideExtractFileName

Variant

FileName as WideString

WideExtractFileExt

Variant

FileName as WideString

WideExtractRelativePath

Variant

BaseName as WideString,
DestName as WideString

WideExpandFileName

Variant

FileName as WideString

WideExtractShortPathNa
me

Variant

FileName as WideString

WideFileCreate

Integer

FileName as WideString

WideFileOpen

Integer

FileName as WideString, Mode


as LongWord

WideFileAge

Integer

FileName as WideString

WideDirectoryExists

Variant

Name as WideString

WideFileExists

Variant

Name as WideString

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

126 / 135

Function name

Returns

Parameters

WideFileGetAttr

Integer

FileName as WideString

WideFileSetAttr

Variant

FileName as WideString, Attr


as Integer

WideFileIsReadOnly

Variant

FileName as WideString

WideFileSetReadOnly

Variant

FileName as WideString,
ReadOnly as Boolean

WideRenameFile

Variant

OldName as WideString,
NewName as WideString

WideDeleteFile

Variant

FileName as WideString

WideCopyFile

Variant

FromFile as WideString, ToFile


as WideString, FailIfExists as
Boolean

WideCreateDir

Variant

Dir as WideString

WideRemoveDir

Variant

Dir as WideString

WideGetCurrentDir

Variant

WideSetCurrentDir

Variant

Dir as WideString

WideTryStrToDateTime

Variant

Str as WideString, DateTime as


TDateTime).SetVarArgs([1]

WideTryStrToDate

Variant

Str as WideString, DateTime as


TDateTime).SetVarArgs([1]

WideTryStrToTime

Variant

Str as WideString, DateTime as


TDateTime).SetVarArgs([1]

WideValidDateTimeStr

Variant

Str as WideString

WideValidDateStr

Variant

Str as WideString

WideValidTimeStr

Variant

Str as WideString

WideStrToDateTime

Variant

Str as WideString

WideStrToDate

Variant

Str as WideString

WideStrToTime

Variant

Str as WideString

WideStrToDateTimeDef

Variant

Str as WideString, Default as


TDateTime

WideTextPos

Integer

SubStr as WideString, S as
WideString

WideAsc

Integer

C as WideChar

WideInStr

Integer

Str as WideString, SubStr as


WideString

WideLen

Integer

S as WideString

WideLeft

WideString

S as WideString, Count as
integer

WideMid

WideString

S as WideString, Index as
integer, Count as integer

WideRight

WideString

S as WideString, Count as
integer

WideLTrim

WideString

S as WideString

WideRTrim

WideString

S as WideString

WideLCase

WideString

S as WideString

WideUCase

WideString

S as WideString

13/02/2013

Description

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

127 / 135

Function name

Returns

Parameters

Description

WideReplace

WideString

S as WideString, OldPattern as
WideString, NewPattern as
WideString

WideSpace

WideString

Count as integer

WideStrComp

Integer

S1 as WideString, S2 as
WideString

WideString

WideString

Count as integer, C as
WideChar

WideSplit

Variant

S as WideString, Delimiter as
WideChar = " ", Count as
integer=-1

WideJoin

WideString

V as VariantArray, Delimiter as
WideChar = " "

WideStrReverse

WideString

S as WideString

10.4.11 Unit: Variants


Unit properties and functions
Enumeration name

Values

TVarCompareResult

crLessThan, crEqual,
crGreaterThan

TVariantRelationship

vrEqual, vrLessThan,
vrGreaterThan, vrNotEqual

TNullCompareRule

ncrError, ncrStrict, ncrLoose

TBooleanToStringRule

bsrAsIs, bsrLower, bsrUpper

Property name

Returns

EmptyParam

Variant

NullEqualityRule

TNullCompareRule

NullMagnitudeRule

TNullCompareRule

NullStrictConvert

Variant

NullAsStringValue

Variant

PackVarCreation

Variant

BooleanToStringRule

TBooleanToStringRule

Function name

Returns

Parameters

VarType

Integer

V as Variant

VarAsType

Variant

V as Variant, AVarType as
TVarType

VarIsType

Variant

V as Variant, AVarType as
TVarType

VarIsByRef

Variant

V as Variant

VarIsEmpty

Variant

V as Variant

VarCheckEmpty
VarIsNull

13/02/2013

Description

Description

Description

V as Variant
Variant

V as Variant

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

128 / 135

Function name

Returns

Parameters

VarIsClear

Variant

V as Variant

VarIsCustom

Variant

V as Variant

VarIsOrdinal

Variant

V as Variant

VarIsFloat

Variant

V as Variant

VarIsNumeric

Variant

V as Variant

VarIsStr

Variant

V as Variant

VarToStr

Variant

V as Variant

VarToStrDef

Variant

V as Variant, ADefault as
string

VarToWideStr

Variant

V as Variant

VarToWideStrDef

Variant

V as Variant, ADefault as
WideString

VarToDateTime

Variant

V as Variant

VarFromDateTime

Variant

DateTime as TDateTime

VarInRange

Variant

AValue as Variant, AMin as


Variant, AMax as Variant

VarEnsureRange

Variant

AValue as Variant, AMin as


Variant, AMax as Variant

VarSameValue

Variant

A as Variant, B as Variant

VarCompareValue

TVariantRelations
hip

A as Variant, B as Variant

VarIsEmptyParam

Variant

V as Variant

VarIsError

Variant

V as Variant, byref AResult


as HRESULT

VarAsError

Variant

AResult as HRESULT

VarSupports

Variant

V as Variant, IID as
TGUID, byref Intf

VarCopyNoInd

Description

byref Dest as Variant,


Source as Variant

VarIsArray

Variant

A as Variant

VarArrayRef

Variant

A as Variant

VarTypeIsValidArrayType

Variant

AVarType as TVarType

VarTypeIsValidElementT
ype

Variant

AVarType as TVarType

VarArrayDimCount

Integer

A as Variant

VarArrayLowBound

Integer

A as Variant, Dim as
Integer

VarArrayHighBound

Integer

A as Variant, Dim as
Integer

VarArrayUnlock

A as Variant

Unassigned

Variant

Null

Variant

FindCustomVariantType

Variant

AVarType as TVarType,
byref CustomVariantType
as TCustomVariantType

VarCastError

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

129 / 135

Function name

Returns

Parameters

Description

VarInvalidOp
VarInvalidNullOp
VarOverflowError

ASourceType as
TVarType, ADestType as
TVarType

VarRangeCheckError

ASourceType as
TVarType, ADestType as
TVarType

VarArrayCreateError
VarResultCheck

AResult as HRESULT

HandleConversionExcepti
on

ASourceType as
TVarType, ADestType as
TVarType

VarTypeAsText

13/02/2013

Variant

AType as TVarType

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

130 / 135

11

Appendix

11.1 Function Comparison Simple vs. Advanced Scripting


This appendix shows the equivalent functions and subs to use in advanced scriptings in comparison to the
existing simple scripting.

11.1.1 General functions


Simple scripting function

Advanced scripting function

GetProgramVersion

SpeedMark.ApplicationVersion

AddProgramMessage

SpeedMark.Logging.AddProgramMessage

AddProgramLogText

SpeedMark.Logging.AddProgramLogText

ClearMessageWindow

SpeedMark.Logging.ClearProgramMessages

Message

SpeedMark.Logging.ShowInfoMessage

CloseMessage

SpeedMark.Logging.CloseInfoMessage

Dialog

MsgBox

Extern

StartProcess

ExternWait

StartProcess

InputBox

InputBox

Wait

11.1.2 Mathematic functions


Simple scripting function

Advanced scripting function

Sin

Sin

Cos

Cos

Tan

Math.Tan

ArcSin

Math.ArcSin

ArcCos

Math.ArcCos

ArcTan

Math.ArcTan

Abs

Abs

Round

Round

RoundDown

Floor

RoundUp

Ceil

Frac

Frac

Exp

Exp

Log

Log

Power

Power

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

131 / 135

11.1.3 Type conversion functions


Simple scripting function

Advanced scripting function

IntToHexStr

IntToHex

IntToBinStr

IntToBin

BinStrToInt

BinToInt

HexStrToInt

HexToInt

IntToString

IntToStr

IntToStringFmt

Format("%d", [100])

FloatToString

FloatToStr

FloatToStringFmt

Format(%f, [99.99])
FormatFloat(0.00, 99.99)

StringToInt

StrToInt

StringToFloat

StrToFloat

11.1.4 Text functions


Simple scripting function

Advanced scripting function

Asc

Chr
WideChr

Ord

Asc
WideAsc

Length

Length

Replace

Replace

Cut

Replace  Replace(Test, Test, )

Copy

Copy

Delete

Delete

Pos

Pos
WideTextPos

LowerCase

LowerCase

UpperCase

UpperCase

11.1.5 Time and Date Functions


Simple scripting function

Advanced scripting function

CalendarWeek

DateUtils.WeekOfTheYear

Date

DateToStr(Date)

DateDay

DateUtils.DecodeDate

DateMonth

DateUtils.DecodeDate

DayOfTheWeek

DateUtils.DayOfTheWeek

DayOfTheYear

DateUtils.DayOfTheYear

DateYear

DateUtils.DecodeDate

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

132 / 135

Simple scripting function

Advanced scripting function

StartWatch

SpeedMark.Logging.InitStopWatch

Time

TimeToStr(Time)

Watch

SpeedMark.Logging.ReadStopWatch

11.1.6 File Handling Functions


Simple scripting function

Advanced scripting function

AddFileLine

TextFileList.AddFileLine

ClearFile

TextFileList.ClearFile

CopyFile

TextFileList.CopyFile, CopyFile

DeleteFile

TextFileList.DeleteFile, DeleteFile

DelFileLine

TextFileList.DelFileLine

FileExists

TextFileList.FileExists, FileExists

FindInFile

TextFileList.FindInFile

GetFileLine

TextFileList.GetFileLine

GetFileLineCount

TextFileList.GetFileLineCount

LoadFile

TextFileList.LoadFile

MoveFile

TextFileList.MoveFile, Windows.MoveFile

NewFile

TextFileList.NewFile

RenameFile

TextFileList.RenameFile, Windows.MoveFile

SaveFile

TextFileList.SaveFile

SetFileLine

TextFileList.SetFileLine

11.1.7 Execution Error Functions


Simple scripting function

Advanced scripting function

Errors

SpeedMark.Errors.Execution.Count

ErrorString

SpeedMark.Errors.Execution.ErrorString

ClearError

SpeedMark.Errors.Execution.ClearLast

ClearAllErrors

SpeedMark.Errors.Execution.ClearAll

11.1.8 Graphic manipulation


Simple scripting function

Advanced scripting function

GetGraphicPosX

SpeedMark.CurrentProgram.Graphics.GraphicByName["Name"].GetRectPoint(rppCenter,
PosX, PosY)

GetGraphicPosY

SpeedMark.CurrentProgram.Graphics.GraphicByName["Name"].GetRectPoint(rppCenter,
PosX, PosY)

GetGraphicHeight

SpeedMark.CurrentProgram.Graphics.GraphicByName["Name"].GetRectSize(Width,
Height)

GetGraphicWidth

SpeedMark.CurrentProgram.Graphics.GraphicByName["Name"].GetRectSize(Width,
Height)

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

133 / 135

11.1.9 DataStore
Simple scripting function

Advanced scripting function

DataStoreValue

SpeedMark.DataStore.NamedValue["Name]

DataStoreListPeekFirstAsFloat
DataStoreListPeekFirstAsInt
DataStoreListPeekFirstAsText

SpeedMark.DataStore.NamedList["Name"].PeekFirst

DataStoreListPeekLastAsFloat
DataStoreListPeekLastAsInt
DataStoreListPeekLastAsText

SpeedMark.DataStore.NamedList["Name"].PeekLast

DataStoreListPopFirstAsFloat
DataStoreListPopFirstAsInt
DataStoreListPopFirstAsText

SpeedMark.DataStore.NamedList["Name"].PopFirst

DataStoreListPopLastAsFloat
DataStoreListPopLastAsInt
DataStoreListPopLastAsText

SpeedMark.DataStore.NamedList["Name"].PopLast

DataStoreListEmpty

SpeedMark.DataStore.NamedList["Name"].Empty

11.1.10 Laser statements (LaserController)


Simple scripting function

Advanced scripting function

GetFrequency

SpeedMark.LaserController.Frequency

GetPower

SpeedMark.LaserController.Power

GetLaserOffDelay

SpeedMark.LaserController.LaserOffDelay

GetLaserOnDelay

SpeedMark.LaserController.LaserOnDelay

SetFrequency

SpeedMark.LaserController.Frequency

SetPower

SpeedMark.LaserController.Power

SetLaserOffDelay

SpeedMark.LaserController.LaserOffDelay

SetLaserOnDelay

SpeedMark.LaserController.LaserOnDelay

11.1.11 Galvo control statements (LaserController)


Simple scripting function

Advanced scripting function

GetMarkDelay

SpeedMark.LaserController.MarkDelay

GetMarkSpeed

SpeedMark.LaserController.MarkSpeed

GetPolygonDelay

SpeedMark.LaserController.PolygonDelay

GetPosSpeed

SpeedMark.LaserController.PosSpeed

GetPosDelay

SpeedMark.LaserController.PosDelay

SetMarkDelay

SpeedMark.LaserController.MarkDelay

SetMarkSpeed

SpeedMark.LaserController.MarkSpeed

SetPolygonDelay

SpeedMark.LaserController.PolygonDelay

SetPosDelay

SpeedMark.LaserController.PosDelay

SetPosSpeed

SpeedMark.LaserController.PosSpeed

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

134 / 135

11.1.12 Extended IOs (LaserController)


Simple scripting function

Advanced scripting function

Get

SpeedMark.System.IOControllerComponents.TLC2.InputPort

GetIndex

SpeedMark.System.IOControllerComponents.TLC2.InputIO[0]

Close
Open
Reset

SpeedMark.System.IOControllerComponents.TLC2.OutputIO[0]=0

ResetIndex

SpeedMark.System.IOControllerComponents.TLC2.OutputIO[0]=0

Set

SpeedMark.System.IOControllerComponents.TLC2.OutputIO[0]=1

SetIndex

SpeedMark.System.IOControllerComponents.TLC2.OutputIO[0]=1

13/02/2013

Trotec Produktions- und Vertriebs GmbH_Linzer Strasse 156, A-4600 Wels, Austria, Technical Support
tel_+43 (0)7242 239-7000, fax_+43 (0)7242 239-7380, mailto: techsupport@troteclaser.com

135 / 135

You might also like