Upload
kathryn-bates
View
38
Download
0
Tags:
Embed Size (px)
Citation preview
Script Language Reference Edition: 2013
Script Language Reference
Iris, Greek goddess of the rainbow
Software that brings information
The choice to name our software Iris is well thought over. You will find remarkable unique
features that very well compare to how the Greek goddess Iris is described.
In Greek mythology, Iris is a goddess of communication. She is the messenger of the gods, particularly Zeus and Hera, to humankind. She is pictured with wings and personifies the rainbow. It was said that Iris leaves Mount Olympus only to deliver messages to mankind who look to her as an advisor and guide, linking her between the worlds of the gods and humanity.
One of the strong features of Iris SCADA and PanelWare relates to communication with the process. No other SCADA or PanelWare software supports the same high and accurate
performance to bring process and production data to the operators, and back.
Apart from carrying messages Goddess Iris had many other tasks to perform. One was to deliver a jug of water from the river Styx so to put whoever lies to sleep. The Greek called her 'The source of water from above'. If the Gods argue, or if they lie about something, Iris will get water out of the river Styx. With this water, the Gods must pledge the truth. If they lied, they lost their immortality.
Besides the strong communication in Iris SCADA and PanelWare you also will find many smart engineering tools that will help you to generate quickly solutions for different type of
applications. Iris SCADA and PanelWare holds a very strong event driven task handler. This guarantees that data is always handled correctly and communicated to the different modules
(e.g. alarming, trending, visualization and more).
Travelling through all dimensions, Iris uses her gifts to prevent unnecessary suffering by severing the silver cord that binds them to Mother Earth bringing relief from a slow death. Though she was sometimes called upon to deliver bad news, Iris was known as a sweet tempered Goddess with no enemies. This gave her access to the universe and welcome in all corners of the earth and beyond.
Iris SCADA and PanelWare is independent from whatever type of control equipment. The unique architecture is suited for a wide variety of applications. Iris SCADA and PanelWare can
be used in small stations and in large control rooms, in simple to mission critical applications. Iris SCADA and PanelWare can be fully adjusted and new functionality can be added always.
Iris not being a mere follower and deliverer of others' messages, her other qualities are gentle strength and communication skills born out of the art of balance. She arrests action and creates harmony. Iris is a bringer of hope and justice through temperance rather than force. It has been said that all the colours of the rainbow blended together create the colour white, essence of the Spirit.
Iris SCADA and PanelWare is not comparable with regular SCADA systems. It is software
developed by engineers for engineers allowing easy and rapid application development, saving valuable engineering time. Even changes to the application can be made without
stopping the process, if needed from a remote development station. All the different modules in Iris SCADA and PanelWare make it an ideal platform to develop specific solutions.
Script Language Reference
Abstract This document is the Script Language Reference for Iris, a product of Raster Products B.V. Iris is a program build to control and visualize data from Programmable logic Controllers
(PLC) or Process Control Systems (PCS) through highly efficient data communication. Iris is
equipped with lots of extensive features, provided to create the best possible interface with the user.
Raster Products B.V.
P.O. box 3
6620 AA DREUMEL
The Netherlands
Phone: +31 (0)487-572719
Fax: +31 (0)487-573394
E-mail: [email protected]
Website: www.raster.com
Script Language Reference
History
Edition Date Author Description
2009 16-JUL-2009 Alex Oskam Newly written for Iris V4
2011 28-JAN-2011 Alex Oskam Slightly updated
2013 10-AUG-2013 RvW Slightly updated
This document is property of Raster Products B.V. No part of it may be reproduced or used in
any form or by any means without written permission of the owner.
Although this manual is written with the most care, Raster will not be responsible for any mistakes in this manual or damage that is a result of the information in this manual.
Script Language Reference
2001-2013 Raster Products B.V. All right reserved
Script Language Reference
Table of Contents 1. Abort - Aborts the current processing with a silent exception ...................................... 12
2. Abs - Gives the absolute value of a number (-ve sign is removed) .............................. 13
3. And - Boolean and or bitwise and of two arguments .................................................. 14
4. AnsiChar - A character type guaranteed to be 8 bits in size ........................................ 15
5. AnsiCompareStr - Compare two strings for equality .................................................... 16
6. AnsiCompareText - Compare two strings for equality, ignoring case ............................ 18
7. AnsiLowerCase - Change upper case characters in a string to lower case .................... 20
8. AnsiPos - Find the position of one string in another .................................................... 21
9. AnsiString - A data type that holds a string of AnsiChars ............................................ 22
10. AnsiUpperCase - Change lower case characters in a string to upper case .................. 24
11. Append - Open a text file to allow appending of text to the end ............................... 25
12. ArcCos - The Arc Cosine of a number, returned in radians ........................................ 27
13. ArcSin - The Arc Sine of a number, returned in radians ............................................ 28
14. ArcTan - The Arc Tangent of a number, returned in radians ..................................... 29
15. Array - A data type holding indexable collections of data .......................................... 30
16. AssignFile - Assigns a file handle to a binary or text file ........................................... 32
17. Beep - Make a beep sound ..................................................................................... 34
18. Begin - Keyword that starts a statement block ......................................................... 35
19. Boolean - Allows just True and False values ............................................................ 36
20. Break - Forces a jump out of a single loop .............................................................. 37
21. Byte - An integer type supporting values 0 to 255 ................................................... 38
22. Cardinal - The basic unsigned integer type .............................................................. 39
23. Case - A mechanism for acting upon different values of an Ordinal ........................... 40
24. ChangeFileExt - Change the extension part of a file name ........................................ 42
25. ChangePage - Change a page ................................................................................ 43
26. Char - Variable type holding a single character ........................................................ 44
27. ChDir - Change the working drive plus path for a specified drive .............................. 45
28. Chr - Convert an integer into a character ................................................................ 46
29. ClearMailBox - Clears the current MailBox................................................................ 47
30. CloseCurrentPage - Close a screen .......................................................................... 48
31. CloseFile - Closes an open file ................................................................................ 49
32. CompareStr - Compare two strings for equality ....................................................... 51
33. CompareText - Compare two strings for equality, ignoring case ................................ 53
34. CompareValue - Compare numeric values with a tolerance ....................................... 55
35. Const - Starts the definition of fixed data values ...................................................... 57
36. Continue - Forces a jump to the next iteration of a loop ........................................... 58
37. Copy - Create a copy of part of a string or an array ................................................. 59
38. Cos - The Cosine of a number ................................................................................ 60
39. CreateDir - Create a directory ................................................................................. 61
40. Currency - A floating point type with 4 decimals used for financial values ................. 62
41. CurrencyDecimals - Defines decimal digit count in the Format function ..................... 63
42. CurrencyFormat - Defines currency string placement in curr display functions ........... 64
Script Language Reference
43. CurrencyString - The currency string used in currency display functions .................... 65
44. CurrentPageName - Show the current page name ................................................... 66
45. CurrToStr - Convert a currency value to a string ...................................................... 67
46. CurrToStrF - Convert a currency value to a string with formatting............................. 68
47. Date - Gives the current date ................................................................................. 69
48. DateSeparator - The character used to separate display date fields .......................... 70
49. DateTimeToFileDate - Convert a TDateTime value to a file date/time format ............. 71
50. DateTimeToStr - Converts TDateTime date and time values to a string ..................... 73
51. DateTimeToString - Rich formatting of a TDateTime variable into a string ................. 74
52. DateToStr - Converts a TDateTime date value to a string ......................................... 77
53. DayOfTheMonth - Gives day of month index for a TDateTime value (ISO 8601) ........ 78
54. DayOfTheWeek - Gives day of week index for a TDateTime value (ISO 8601) ........... 79
55. DayOfTheYear - Gives the day of the year for a TDateTime value (ISO 8601) ........... 80
56. DayOfWeek - Gives day of week index for a TDateTime value .................................. 81
57. DaysBetween - Gives the whole number of days between 2 dates ............................ 82
58. DaysInAMonth - Gives the number of days in a month ............................................. 83
59. DaysInAYear - Gives the number of days in a year .................................................. 84
60. DaySpan - Gives the fractional number of days between 2 dates .............................. 85
61. Dec - Decrement an ordinal variable ....................................................................... 86
62. DecimalSeparator - The character used to display the decimal point ......................... 87
63. DecodeDate - Extracts the year, month, day values from a TDateTime var. .............. 88
64. DecodeTime - Break a TDateTime value into individual time values .......................... 89
65. DegToRad - Convert a degrees value to radians ...................................................... 90
66. Delete - Delete a section of characters from a string ................................................ 91
67. DeleteFile - Delete a file specified by its file name ................................................... 92
68. DirectoryExists - Returns true if the given directory exists ........................................ 94
69. Div - Performs integer division, discarding the remainder ......................................... 95
70. Do - Defines the start of some controlled action ...................................................... 96
71. Double - A floating point type supporting about 15 digits of precision ....................... 97
72. Downto - Prefixes an decremental for loop target value ........................................... 98
73. Else - Starts false section of if, case and try statements ........................................... 99
74. EncodeDate - Build a TDateTime value from year, month and day values ............... 101
75. EncodeDateTime - Build a TDateTime value from day and time values .................... 102
76. EncodeTime - Build a TDateTime value from hour, min, sec and msec values.......... 103
77. End - Keyword that terminates statement blocks ................................................... 104
78. EndOfADay - Generate a TDateTime value set to the very end of a day .................. 105
79. EndOfAMonth - Generate a TDateTime value set to the very end of a month .......... 106
80. Eof - Returns true if a file opened with Reset is at the end ..................................... 107
81. Erase - Erase a file............................................................................................... 109
82. Except - Starts the error trapping clause of a try statement .................................... 110
83. Exit - exit abruptly from a function or procedure .................................................... 111
84. Exp - Gives the exponent of a number .................................................................. 112
85. ExpandMailBox - Expands a MailBox ..................................................................... 113
86. ExpandPowerTree - Expands a PowerTree ............................................................ 114
Script Language Reference
87. ExtractFileDir - Extracts the dir part of a full file name ........................................... 115
88. ExtractFileDrive - Extracts the drive part of a full file name .................................... 116
89. ExtractFileExt - Extracts the extension part of a full file name ................................. 117
90. ExtractFileName - Extracts the name part of a full file name ................................... 118
91. ExtractFilePath - Extracts the path part of a full file name ...................................... 119
92. File - Defines a typed or untyped file .................................................................... 120
93. FileAge - Get the last modified date/time of a file without opening it ...................... 122
94. FileDateToDateTime - Converts a file date/time format to a TDateTime value ......... 123
95. FileExists - Returns true if the given file exists ....................................................... 124
96. FileGetAttr - Gets the attributes of a file ................................................................ 126
97. FileSearch - Search for a file in one or more directories .......................................... 129
98. FileSetDate - set the last modified date and time of a file ....................................... 131
99. Finally - Starts the unconditional code section of a try statement ............................ 133
100. FloatToStr - Convert a floating point value to a string .......................................... 135
101. FloatToStrF - Convert a floating point value to a string with formatting ................ 136
102. Flush - Flushes buffered text file data to the file .................................................. 139
103. For - Starts a loop that executes a finite number of times .................................... 141
104. ForceDirectories - Create a new path of directories ............................................. 142
105. Format - Rich formatting of numbers and text into a string .................................. 143
106. FormatCurr - Rich formatting of a currency value into a string ............................. 146
107. FormatDateTime - Rich formatting of a TDateTime variable into a string .............. 149
108. FormatFloat - Rich formatting of a floating point number into a string .................. 154
109. Frac - The fractional part of a floating point number ............................................ 157
110. Function - Defines a subroutine that returns a value ............................................ 158
111. GetCurrentDir - Get the current directory (drive plus directory) ............................ 161
112. GetDir - Get the default directory (drive plus path) for a specified drive ................ 162
113. GetPageDir - Returns the page directory ............................................................. 163
114. GetTagProp - Reads a property of a tag.............................................................. 164
115. GetTagValue - Reads the value of a tag .............................................................. 166
116. Goto - Forces a jump to a label, regardless of nesting ......................................... 169
117. If - Starts a conditional expression to determine what to do next ......................... 170
118. Implementation - Starts the implementation (code) section of a unit .................... 172
119. Inc - Increment an ordinal variable .................................................................... 175
120. IncDay - Increments a TDateTime variable by + or - number of days ................... 176
121. IncMillisecond - Increments a TDateTime variable by + or - number of mseconds . 177
122. IncMinute - Increments a TDateTime variable by + or - number of minutes .......... 178
123. IncMonth - Increments a TDateTime variable by a number of months .................. 179
124. IncSecond - Increments a TDateTime variable by + or - number of seconds ......... 180
125. IncYear - Increments a TDateTime variable by a number of years ........................ 181
126. Infinity - Floating point value of infinite size ........................................................ 182
127. InputBox - Display a dialog that asks for user text input, with default ................... 183
128. InputQuery - Display a dialog that asks for user text input ................................... 184
129. Insert - Insert a string into another string ........................................................... 185
130. Int - The integer part of a floating point number as a float .................................. 186
Script Language Reference
131. Integer - The basic Integer type ........................................................................ 187
132. Interface - Used for definitions ........................................................................... 188
133. IntToHex - Convert an Integer into a hexadecimal string ..................................... 191
134. IntToStr - Convert an integer into a string .......................................................... 192
135. IsInfinite - Checks whether a floating point number is infinite .............................. 193
136. IsLeapYear - Returns true if a given calendar year is a leap year .......................... 194
137. LastDelimiter - Find the last position of selected characters in a string .................. 195
138. Length - Return the number of elements in an array or string .............................. 196
139. LinkedPopup - Open a Linked Popup .................................................................. 197
140. Ln - Gives the natural logarithm of a number ...................................................... 198
141. Log10 - Gives the log to base 10 of a number ..................................................... 199
142. LongDateFormat - Long version of the date to string format ................................ 200
143. LongInt - An Integer whose size is guaranteed to be 32 bits ................................ 201
144. LongTimeFormat - Long version of the time to string format ................................ 202
145. LowerCase - Change upper case characters in a string to lower case .................... 203
146. Max - Gives the maximum of two integer values ................................................. 204
147. MessageBox - Displays a message, symbol, and selectable buttons ...................... 205
148. MessageDlg - Displays a message, symbol, and selectable buttons ....................... 206
149. MessageDlgPos - Displays a message plus buttons at a given screen position ....... 208
150. Min - Gives the minimum of two integer values ................................................... 210
151. MinsPerDay - Gives the number of minutes in a day ............................................ 211
152. MkDir - Make a directory .................................................................................... 212
153. Mod - Performs integer division, returning the remainder..................................... 213
154. ModalPopup - Open a Modal Popup .................................................................... 214
155. MonthOfTheYear - Gives the month of the year for a TDateTime value ................. 215
156. NegCurrFormat - Defines negative amount formatting in currency displays ........... 216
157. Not - Boolean not or bitwise not of one arguments .............................................. 218
158. Now - Gives the current date and time ............................................................... 219
159. Null - A variable that has no value ...................................................................... 220
160. NumEditor - Shows a numerical popup to write the value of a tag ........................ 222
161. Or - Boolean or or bitwise or of two arguments ................................................... 224
162. Ord - Provides the Ordinal value of an integer, character or enum........................ 225
163. PageBack - Show Previous Page ......................................................................... 227
164. PageForward - Show Next Page ......................................................................... 228
165. Pi - The mathematical constant .......................................................................... 229
166. Popup - Open a Popup ...................................................................................... 230
167. Pos - Find the position of one string in another ................................................... 231
168. Pred - Decrement an ordinal variable .................................................................. 232
169. Private - Starts the section of private data and methods in a class ....................... 233
170. Procedure - Defines a subroutine that does not return a value ............................. 234
171. PtInRect - Tests to see if a point lies within a rectangle ....................................... 237
172. Public - Starts an externally accessible section of a class...................................... 238
173. RadToDeg - Converts a radian value to degrees .................................................. 239
174. Random - Generate a random floating point or integer number ............................ 240
Script Language Reference
175. Randomize - Reposition the Random number generator next value ...................... 242
176. RandomRange - Generate a random integer number within a supplied range........ 244
177. RandSeed - Reposition the Random number generator next value ........................ 245
178. ReadLn - read a complete line of data from a text file ......................................... 247
179. ReadRecipe - read a recipe file. .......................................................................... 249
180. RecodeDate - Change only the date part of a TDateTime variable ........................ 250
181. RecodeTime - Change only the time part of a TDateTime variable ........................ 251
182. RemoveDir - Remove a directory ........................................................................ 252
183. RemoveMailBox - Removes a MailBox ................................................................. 253
184. Rename - Rename a file .................................................................................... 254
185. Repeat - repeat statements until a ternmination condition is met ......................... 256
186. ReplaceDate - Change only the date part of a TDateTime variable ....................... 258
187. ReplaceTime - Change only the time part of a TDateTime variable ....................... 259
188. Result - A variable used to hold the return value from a function ......................... 260
189. ReWrite - Open a text or binary file for write access ............................................ 261
190. RmDir - Remove a directory ............................................................................... 263
191. Round - Rounds a floating point number to an integer ......................................... 264
192. SecsPerDay - Gives the number of seconds in a day ............................................ 265
193. SetCurrentDir - Change the current directory ...................................................... 266
194. SetMailBox - Sets a MailBox to a specific value .................................................... 267
195. SetPageDir - Sets the page directory .................................................................. 268
196. SetTagValue - Sets a value of a tag .................................................................... 269
197. Shl - Shift an integer value left by a number of bits ............................................. 272
198. ShortDateFormat - Compact version of the date to string format .......................... 273
199. ShortInt - An integer type supporting values -128 to 127 ..................................... 274
200. ShortString - Defines a string of up to 255 characters .......................................... 275
201. ShortTimeFormat - Short version of the time to string format .............................. 276
202. ShowMessage - Display a string in a simple dialog with an OK button ................... 277
203. ShowMessageFmt - Display formatted data in a simple dialog with an OK button .. 278
204. ShowMessagePos - Display a string in a simple dialog at a given screen position ... 281
205. Shr - Shift an integer value right by a number of bits .......................................... 282
206. Sin - The Sine of a number ................................................................................ 283
207. Single - The smallest capacity and precision floating point type ............................ 284
208. SmallInt - An Integer type supporting values from -32768 to 32767 ..................... 285
209. Sqr - Gives the square of a number .................................................................... 286
210. Sqrt - Gives the square root of a number ............................................................ 287
211. StopRunTime - Stops the runtime....................................................................... 288
212. String - A data type that holds a string of characters ........................................... 289
213. StringReplace - Replace one or more substrings found within a string .................. 290
214. StrToCurr - Convert a number string into a currency value ................................... 291
215. StrToDate - Converts a date string into a TDateTime value .................................. 293
216. StrToDateTime - Converts a date+time string into a TDateTime value .................. 294
217. StrToFloat - Convert a number string into a floating point value ........................... 295
218. StrToInt - Convert an integer string into an Integer value .................................... 296
Script Language Reference
219. StrToIntDef - Convert a string into an Integer value with default ......................... 298
220. StrToTime - Converts a time string into a TDateTime value ................................. 300
221. Succ - Increment an ordinal variable .................................................................. 301
222. Tan - The Tangent of a number ......................................................................... 302
223. TBits - An object that can hold an infinite number of Boolean values .................... 303
224. TDateTime - Data type holding a date and time value ......................................... 305
225. TextFile - Declares a file type for storing lines of text .......................................... 306
226. TFloatFormat - Formats for use in floating point number display functions ............ 308
227. TFormatSettings - A record for holding locale values ........................................... 311
228. Then - Part of an if statement - starts the true clause.......................................... 313
229. ThousandSeparator - The character used to display the thousands separator ........ 315
230. Time - Gives the current time ............................................................................ 316
231. TimeAMString - Determines AM value in DateTimeToString procedure .................. 317
232. TimePMString - Determines PM value in DateTimeToString procedure .................. 318
233. TimeSeparator - The character used to separate display time fields ...................... 319
234. TimeToStr - Converts a TDateTime time value to a string .................................... 320
235. To - Prefixes an incremental for loop target value ............................................... 321
236. Tomorrow - Gives the date tomorrow ................................................................. 322
237. Trim - Removes leading and trailing blanks from a string ..................................... 323
238. TrimLeft - Removes leading blanks from a string ................................................. 324
239. TrimRight - Removes trailing blanks from a string ............................................... 325
240. Trunc - The integer part of a floating point number ............................................. 326
241. Try - Starts code that has error trapping ............................................................. 327
242. TStringList - Holds a variable length list of strings ............................................... 330
243. TwoDigitYearCenturyWindow - Sets the century threshold for 2 digit years ........... 334
244. Unit - Defines the start of a script file ................................................................. 335
245. Until - Ends a repeat control loop ....................................................................... 338
246. UpperCase - Change lower case characters in a string to upper case .................... 340
247. Uses - Declares a list of Units to be imported ...................................................... 341
248. Var - Starts the definition of a section of data variables ....................................... 344
249. Variant - A variable type that can hold changing data types ................................. 346
250. VarType - Gives the current type of a Variant variable ......................................... 347
251. VarTypeMask - Mask for the meta-type part of a Variant variable ......................... 350
252. While - repeat statements whilst a continuation condition is met .......................... 353
253. WideString - A data type that holds a string of WideChars ................................... 355
254. Word - An integer type supporting values 0 to 65535 .......................................... 357
255. WriteLn - write a complete line of data to a text file ............................................ 358
256. WriteRecipe - write a recipe file.......................................................................... 360
257. WriteTagValue - Writes a value of a tag .............................................................. 361
258. Xor - Boolean xor or bitwise xor of two arguments .............................................. 364
259. Yesterday - Gives the date yesterday.................................................................. 365
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 12 of 366
1. Abort - Aborts the current processing with a silent exception
1.1. Unit
SysUtils
1.2. Type
Procedure
1.3. Description
The Abort procedure stops the current processing and exits to the last exception block. In
doing so, no end user message is produced - the abort is silent.
1.4. Syntax procedure Abort;
1.5. Example
1.5.1. Name
Aborting from a try block
1.5.2. Code begin
// enter a try block
try
ShowMessage('Before abort');
Abort;
ShowMessage('After abort');
except
ShowMessage('Exception occurred');
end;
ShowMessage('After try');
end;
1.5.3. Result Before abort
Exception occurred
After try
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 13 of 366
2. Abs - Gives the absolute value of a number (-ve sign is removed)
2.1. Unit
System
2.2. Type
Function
2.3. Description
The Abs function returns the absolute value of a negative or positive number. It does this by
removing a negative sign, if found. The Number can be any numeric type, and can even be a Variant, as long as it can be converted to a number. For example, a Variant set to a string '-
1.23' will work fine. Always, Abs converts the Variant to an Extended floating point number
prior to removing any negative sign, even if the result is an integer value.
2.4. Syntax function Abs(Number : Numeric type) : Numeric type;
2.5. Example
2.5.1. Name
Illustrating absolute values of different data types
2.5.2. Code var
float : single;
int : Integer;
varVar : Variant;
begin
float := -1.5; // small negative floating point number
int := -7; // negative integer
varVar := '-98'; // variants are converted to floating point!
ShowMessage('Abs(float) = '+FloatToStr(Abs(float)));
ShowMessage('Abs(int) = '+FloatToStr(Abs(int)));
// variants are converted into extended floating types
float := Abs(varVar);
ShowMessage('Abs(varVar) = '+FloatToStr(float));
end;
2.5.3. Result Abs(float) = 1.5
Abs(int) = 7
Abs(varVar) = 98
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 14 of 366
3. And - Boolean and or bitwise and of two arguments
3.1. Unit
Iris Standard
3.2. Type
Keyword
3.3. Description
The and keyword is used in two different ways: 1. to perform a logical or Boolean 'and' of
two logical values. If both are true, then the result is true, otherwise, the result is false. 2. To
perform a mathematical 'and' of two integers. The result is a bitwise 'and' of the two numbers. For example: 10110001 and 01100110 = 00100000
3.4. Syntax 1 Boolean expression and Boolean expression
2 Integer expression and Integer expression
3.5. Example
3.5.1. Name
Illustrate both types of and usage
3.5.2. Code var
num1, num2, num3 : Integer;
letter : Char;
begin
num1 := $25; // binary value : 0010 0101
num2 := $32; // binary value : 0011 0010
// and-ed value : 0010 0000 = $20 = 32 dec
letter := 'G';
// and used to return a boolean value
if (num1 > 0) and (letter = 'G')
then ShowMessage('Both values are true')
else ShowMessage('None or only one true value');
// and used to perform a mathematical and operation
num3 := num1 and num2;
ShowMessageFmt('$25 and $32 = $%x',[num3]);
end;
3.5.3. Result Both values are true
$25 and $32 = $20
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 15 of 366
4. AnsiChar - A character type guaranteed to be 8 bits in size
4.1. Unit
System
4.2. Type
Type
4.3. Description
The AnsiChar type is used to hold single characters. It is guaranteed to be 8 bits in size. It
can be assigned from a character or integer value.
4.4. Syntax type AnsiChar = #0..#255;
4.5. Example
4.5.1. Name
Different ways of assigning to and from an AnsiChar
4.5.2. Code var
myChar : AnsiChar;
begin
myChar := 'g'; // assign from a character constant
ShowMessage('Letter g = '+myChar);
myChar := #65; // assign from an integer constant
ShowMessage('#65 = '+myChar);
myChar := Chr(66); // using chr to convert a number
ShowMessage('Chr(66) = '+myChar);
end;
4.5.3. Result Letter g = g
#65 = A
Chr(66) = B
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 16 of 366
5. AnsiCompareStr - Compare two strings for equality
5.1. Unit
SysUtils
5.2. Type
Function
5.3. Description
The AnsiCompareStr function compares String1 and String2 for equality. This is the modern,
Locale safe form of CompareStr. All Ansi commands support multi-byte and accented
characters. It returns these values: String1 < String2 : -ve numberString1 = String2 : 0String1 > String2 : +ve number The comparison is not affected by length - it is carried out
on a letter by letter basis. But a longer string is greater than a shorter, otherwise matching string. The comparison is case sensitive.
5.4. Syntax function AnsiCompareStr(const String1, String2 : string) : Integer;
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 17 of 366
5.5. Example
5.5.1. Name
Compare various strings
5.5.2. Code // remember to declare the procedure at type using the following line
// procedure comparestrings(const string1, string2: string);
begin
// compare two obviously different strings
CompareStrings('HELLO', 'WORLD');
// compare identical strings
CompareStrings('Hi 2 you', 'Hi 2 you');
// upper case letters follow lower case in iris
CompareStrings('ABC', 'abc');
// all letters follow numbers in iris
CompareStrings('abc', '123');
end;
// compare two strings, and show which is bigger than the other
procedure TUntitled.CompareStrings(const string1, string2: string);
var
result : Integer;
begin
// compare some strings
result := AnsiCompareStr(string1, string2);
if result < 0 then ShowMessage(string1+' < '+string2);
if result = 0 then ShowMessage(string1+' = '+string2);
if result > 0 then ShowMessage(string1+' > '+string2);
end;
5.5.3. Result HELLO < WORLD
Hi 2 you = Hi 2 you
ABC > abc
abc > 123
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 18 of 366
6. AnsiCompareText - Compare two strings for equality, ignoring case
6.1. Unit
SysUtils
6.2. Type
Function
6.3. Description
The AnsiCompareText function compares String1 and String2 for equality, ignoring case. This
is the modern, Locale safe form of CompareStr. All Ansi commands support multi-byte and accented characters. It returns these values: String1 < String2 : -ve numberString1 = String2
: 0String1 > String2 : +ve number The comparison is not affected by length - it is carried out
on a letter by letter basis. But a longer string is greater than a shorter, otherwise matching string.
6.4. Syntax function AnsiCompareText(const String1, String2 : string) : Integer;
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 19 of 366
6.5. Example
6.5.1. Name
Compare various strings
6.5.2. Code // remember to declare the procedure at type using the following line
// procedure comparestrings(const string1, string2: string);
begin
// compare two obviously different strings
CompareStrings('HELLO', 'WORLD');
// compare identical strings
CompareStrings('Hi 2 you', 'Hi 2 you');
// ansicomparetext treats upper and lower case identically
CompareStrings('ABCdef', 'abcDEF');
// all letters follow numbers in iris
CompareStrings('abc', '123');
end;
// compare two strings, and show which is bigger than the other
procedure TUntitled.CompareStrings(const string1, string2: string);
var
result : Integer;
begin
// compare some strings
result := AnsiCompareText(string1, string2);
if result < 0 then ShowMessage(string1+' < '+string2);
if result = 0 then ShowMessage(string1+' = '+string2);
if result > 0 then ShowMessage(string1+' > '+string2);
end;
6.5.3. Result HELLO < WORLD
Hi 2 you = Hi 2 you
ABCdef = abcDEF
abc > 123
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 20 of 366
7. AnsiLowerCase - Change upper case characters in a string to lower case
7.1. Unit
SysUtils
7.2. Type
Function
7.3. Description
The AnsiLowerCase function creates a copy of MixedString with all letters converted to lower
case. All Ansi commands support multi-byte and accented characters.
7.4. Syntax function AnsiLowerCase(const MixedString : string) : string;
7.5. Example
7.5.1. Name
Converting a mixed case string to lower case
7.5.2. Code var
SimpleString : string;
begin
SimpleString := AnsiLowerCase('The Cat Sat on The MAT');
ShowMessage('SimpleString : '+SimpleString);
end;
7.5.3. Result SimpleString : the cat sat on the mat
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 21 of 366
8. AnsiPos - Find the position of one string in another
8.1. Unit
SysUtils
8.2. Type
Function
8.3. Description
The AnsiPos function looks for a substring Needle in a string HayStack, returning the position
in the string of the first occurrence. All Ansi commands support multi-byte and accented
characters. if the string is not found, 0 is returned. The search is case sensitive.
8.4. Syntax function AnsiPos(const Needle, HayStack : string) : Integer;
8.5. Example
8.5.1. Name
Find a word in a sentence
8.5.2. Code var
position : Integer;
begin
// look for the word 'cat' in a sentence
// note : that this search is case sensitive, so that
// the first 'cat' is not matched
position := AnsiPos('Cat', 'The cat sat on the Cat mat');
if position = 0
then ShowMessage('''Cat'' not found in the sentence')
else ShowMessage('''Cat'' was found at character '+IntToStr(position));
end;
8.5.3. Result 'Cat' was found at character 20
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 22 of 366
9. AnsiString - A data type that holds a string of AnsiChars
9.1. Unit
System
9.2. Type
Type
9.3. Description
The AnsiString data type is used to hold sequences of characters, like sentences. Each
character is an AnsiChar, guaranteed to be 8 bits in size. An AnsiString can hold any number of characters, restricted only by memory. Unlike ShortStrings, AnsiStrings are pointer
referenced variables. Storage is allocated for an AnsiString only when needed. for example,
assigning the value of one AnsiString to another does not allocate storage for a copy of the first string. Instead, the reference count of the first string is incremented, and the second
AnsiString set to point to it. But when the second string is changed, new storage is obtained for this new string, and the reference count for the first string is decremented. AnsiStrings
can be assigned from other strings, from functions that return a string, and with
concatenations as in the sample code.
9.4. Syntax type AnsiString;
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 23 of 366
9.5. Example
9.5.1. Name
Assign to two AnsiStrings and manipulate these
9.5.2. Code var
string1, string2 : AnsiString;
begin
// assign a famous sentence to the first string
string1 := 'Hello World';
// assign to the second string
// this simply points string2 at string1
// the 'hello world' string storage has a reference count of 2
string2 := string1;
// add to the second string
// this disassociates from string1 - new string storage is
// created to hold the string2 value
string2 := string2 + ', how is everyone?';
// and finally, set the length of the first string to 5
SetLength(string1, 5);
// display both strings
ShowMessage('String1 = '+string1);
ShowMessage('String2 = '+string2);
end;
9.5.3. Result String1 = Hello
String2 = Hello World, how is everyone?
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 24 of 366
10. AnsiUpperCase - Change lower case characters in a string to upper case
10.1. Unit
SysUtils
10.2. Type
Function
10.3. Description
The AnsiUpperCase function creates a copy of MixedString with all letters converted to upper
case. All Ansi commands support multi-byte and accented characters.
10.4. Syntax function AnsiUpperCase(const MixedString : string) : string;
10.5. Example
10.5.1. Name
Converting a mixed case string to upper case
10.5.2. Code var
SimpleString : string;
begin
SimpleString := AnsiUpperCase('The Cat Sat on The MAT');
ShowMessage('SimpleString : '+SimpleString);
end;
10.5.3. Result SimpleString : THE CAT SAT on THE MAT
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 25 of 366
11. Append - Open a text file to allow appending of text to the end
11.1. Unit
System
11.2. Type
Procedure
11.3. Description
The Append procedure opens a file given by FileHandle to allow subsequent writes to append
to the end of the file. You must use AssignFile to assign a file to the FileHandle before using Append. This is often used when logging information - existing log data must be preserved,
with the new log information appended to the end. Use write or WriteLn to write to the file
after this Append is executed.
11.4. Syntax procedure Append(var FileHandle : TextFile);
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 26 of 366
11.5. Example
11.5.1. Name
Appending a line of text to an existing file
11.5.2. Code var
myFile : TextFile;
text : string;
begin
// try to open the test.txt file for writing to
AssignFile(myFile, 'Test.txt');
ReWrite(myFile);
// write a couple of well known words to this file
WriteLn(myFile, 'Hello');
WriteLn(myFile, 'World');
// close the file
CloseFile(myFile);
// reopen to append a final line to the file
Append(myFile);
// write this final line
WriteLn(myFile, 'Final line added');
// close the file
CloseFile(myFile);
// reopen the file for reading
Reset(myFile);
// display the file contents
while not Eof(myFile) do
begin
ReadLn(myFile, text);
ShowMessage(text);
end;
// close the file for the last time
CloseFile(myFile);
end;
11.5.3. Result Hello
World
Final line added
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 27 of 366
12. ArcCos - The Arc Cosine of a number, returned in radians
12.1. Unit
Math
12.2. Type
Function
12.3. Description
The ArcCos function is a mathematical function giving the value in radians of the Arc Cosine
of Number. PI radians = 180 degrees
12.4. Syntax function ArcCos(const Number : Extended) : Extended;
12.5. Example
12.5.1. Name
The ArcCos of 0.5 gives 60 degrees
12.5.2. Code var
float : single;
begin
// the arccos of 0.5 should give 60 degrees
float := ArcCos(0.5);
float := RadToDeg(float); // convert result to degrees
ShowMessage('ArcCos of 0.5 = '+FloatToStr(float)+' degrees');
end;
12.5.3. Result ArcCos of 0.5 = 60 degrees
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 28 of 366
13. ArcSin - The Arc Sine of a number, returned in radians
13.1. Unit
Math
13.2. Type
Function
13.3. Description
The ArcSin function is a mathematical function giving the value in radians of the Arc Sine of
Number. PI radians = 180 degrees
13.4. Syntax function ArcSin(const Number : Extended) : Extended;
13.5. Example
13.5.1. Name
The ArcSin of 0.5 gives 30 degrees
13.5.2. Code var
float : single;
begin
// the arcsin of 0.5 should give 30 degrees
float := ArcSin(0.5);
float := RadToDeg(float); // convert result to degrees
ShowMessage('ArcSin of 0.5 = '+FloatToStr(float)+' degrees');
end;
13.5.3. Result ArcSin of 0.5 = 30 degrees
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 29 of 366
14. ArcTan - The Arc Tangent of a number, returned in radians
14.1. Unit
System
14.2. Type
Function
14.3. Description
The ArcTan function is a mathematical function giving the value in radians of the Arc Tangent
of Number. PI radians = 180 degrees
14.4. Syntax function ArcTan(const Number : Extended) : Extended;
14.5. Example
14.5.1. Name
Get the ArcTan of PI/2
14.5.2. Code var
float : single;
begin
// the arctan of pi/2 should give 1.0
float := ArcTan(PI/2);
ShowMessage('ArcTan of PI/2 = '+FloatToStr(float));
end;
14.5.3. Result ArcTan of PI/2 = 1.00388479232788
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 30 of 366
15. Array - A data type holding indexable collections of data
15.1. Unit
Iris Standard
15.2. Type
Keyword
15.3. Description
The array keyword provides single and multi dimensional arrays (indexable sequences) of
data. Arrays in Iris always have a fixed, unchangeable size. They may be single or multidimensional - the latter being an array of arrays (of arrays etc). The size and range of
such a multidimensional array is always given for the highest, leftmost array - the parent
array.
15.4. Syntax type Name = array[index type|Ordinal..Ordinal {,...}] of Base type;
15.5. Example 1
15.5.1. Name
Declaring and using arrays
15.5.2. Code var
IntArr : array[0..20] of integer;
i : Integer;
begin
// use indexing to furnish an array
for i := 5 to 20 do
IntArr[i] := i * 5;
// now use indexing to display 2 of the elements
ShowMessage('element 7 = '+IntToStr( IntArr[7] ));
ShowMessage('element 20 = '+IntToStr( IntArr[20] ));
end;
15.5.3. Result element 7 = 35
element 20 = 100
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 31 of 366
15.6. Example 2
15.6.1. Name
Declaring and using multidimensional arrays
15.6.2. Code var
FloatArr : array[0..9,20..29] of single;
x,y : Integer;
begin
// use indexing to furnish an array
for x := 0 to 9 do
begin
for y := 20 to 29 do
FloatArr[x,y] := x+(y/100);
end;
// now use indexing to display 2 of the elements
ShowMessage('coordinate [3,24] = '+FloatToStr( FloatArr[3,24] ));
ShowMessage('coordinate [8,22] = '+FloatToStr( FloatArr[8,22] ));
end;
15.6.3. Result coordinate [3,24] = 3.24
coordinate [8,22] = 8.22
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 32 of 366
16. AssignFile - Assigns a file handle to a binary or text file
16.1. Unit
System
16.2. Type
Procedure
16.3. Description
The AssignFile procedure assigns a value to FileHandle for a FileName in preparation for
reading or writing to that file. Takes a text file variable type as the handle. The file is treated
as a textfile when opened. if the file name is an empty string, then file access is made to the console standard input and output streams.
16.4. Syntax procedure AssignFile(var FileHandle : TextFile; const FileName : string);
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 33 of 366
16.5. Example
16.5.1. Name
write to a text file, and then read back its contents
16.5.2. Code var
myFile : TextFile;
text : string;
begin
// try to open the test.txt file for writing to
AssignFile(myFile, 'Test.txt');
ReWrite(myFile);
// write a couple of well known words to this file
WriteLn(myFile, 'Hello');
WriteLn(myFile, 'World');
// close the file
CloseFile(myFile);
// reopen the file for reading
Reset(myFile);
// display the file contents
while not Eof(myFile) do
begin
ReadLn(myFile, text);
ShowMessage(text);
end;
// close the file for the last time
CloseFile(myFile);
end;
16.5.3. Result Hello
World
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 34 of 366
17. Beep - Make a beep sound
17.1. Unit
SysUtils
17.2. Type
Procedure
17.3. Description
The Beep procedure creates a very short and quiet sound through the internal speaker of
your PC. It is used as an indication that the user has done something wrong.
17.4. Syntax procedure Beep;
17.5. Example
17.5.1. Name
Very simple!
17.5.2. Code begin
Beep;
end;
17.5.3. Result No result specified
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 35 of 366
18. Begin - Keyword that starts a statement block
18.1. Unit
Iris Standard
18.2. Type
Keyword
18.3. Description
The begin keyword is fundamental to Iris - it starts statement blocks. The begin-end pair
fence in a set of statements. You may place such a block anywhere in your code. It is
particularly sensible in if and for statements, even if only one statement is required. It means that adding an additional statement in the future is easy.
18.4. Syntax begin
Statements
end
18.5. Example
18.5.1. Name
Some examples of the begin statement
18.5.2. Code var
myChars : array[1..2] of char;
myBytes : array[1..2] of Byte;
i : Integer;
// the begin statement always starts the code part of a subroutine
begin
// use a for block to assign to both arrays
for i := 1 to 2 do
begin
myChars[i] := Chr(i+64);
myBytes[i] := i+64;
end;
// use a for block to observe the contents
for i := 1 to 2 do
begin
ShowMessage('myChars['+IntToStr(i)+'] = '+myChars[i]);
ShowMessage('myBytes['+IntToStr(i)+'] = '+IntToStr(myBytes[i]));
end;
end;
18.5.3. Result myChars[1] = A
myBytes[1] = 65
myChars[2] = B
myChars[2] = 66
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 36 of 366
19. Boolean - Allows just True and False values
19.1. Unit
System
19.2. Type
Type
19.3. Description
The Boolean type provides an enumeration of the logical True and False values. Unlike other
languages, it is not a number - it will only allow these values. This makes the code much
more reliable.
19.4. Syntax type Boolean = (False, True);
19.5. Example
19.5.1. Name
Boolean assignments and tests
19.5.2. Code var
same : Boolean;
small, large, i : Integer;
begin
small := 23;
large := 455555;
// test directly to see if these numbers are the same size
if small = large
then ShowMessage('small = large')
else ShowMessage('small large');
// use a boolean to hold and test this outcome
same := (small = large);
if same
then ShowMessage('small = large')
else ShowMessage('small large');
// assign a direct logical value to this boolean
same := True;
if same
then ShowMessage('same is True')
else ShowMessage('same is False');
end;
19.5.3. Result small large
small large
same is True
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 37 of 366
20. Break - Forces a jump out of a single loop
20.1. Unit
System
20.2. Type
Procedure
20.3. Description
The Break procedure forces a jump out of the setof statements within a loop. Like the goto
statement, it should be used with caution. It is important to note that the Break statement
only jumps out of the current loop - not out of any nested loops above it. The goto statement can.
20.4. Syntax procedure Break;
20.5. Example
20.5.1. Name
Breaking out of a loop for good reason
20.5.2. Code var
i : Integer;
s : string;
begin
s := '';
// a big loop
for i := 1 to 10 do
begin
s := s + IntToStr(i) + ' ';
// exit loop when a certain condition is met
if Random(4) = 2 then Break;
end;
ShowMessage('i = '+IntToStr(i));
ShowMessage('s = '+s);
end;
20.5.3. Result i = 6
s = 1 2 3 4 5 6
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 38 of 366
21. Byte - An integer type supporting values 0 to 255
21.1. Unit
System
21.2. Type
Type
21.3. Description
The Byte type is the smallest form of integer, occupying 8 bits (1 byte) of storage. It supports
only the positive integers from 0 to 255.
21.4. Syntax type Byte = 0..255;
21.5. Example
21.5.1. Name
Showing maximum and minimum byte values
21.5.2. Code var
A, B : Byte;
begin
// set the values of this data type
A := 5;
B := 100;
ShowMessage('A = '+IntToStr(A)+' and B = '+IntToStr(B));
ShowMessage('A + B = '+IntToStr(A+B));
end;
21.5.3. Result A = 5 and B = 100
A + B = 100
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 39 of 366
22. Cardinal - The basic unsigned integer type
22.1. Unit
System
22.2. Type
Type
22.3. Description
The Cardinal type is an Integer whose size is not guaranteed. It is the basic unsigned integer
type, and currently has the same capacity as the LongWord: 32 bits. to hold very large
integers, use the Int64 type.
22.4. Syntax type Cardinal = 0..4294967295; // at the time of writing
22.5. Example
22.5.1. Name
Showing the capacity of Cardinal
22.5.2. Code var
A, B : Cardinal;
begin
// set the values of this data type
A := 1;
B := 999999;
ShowMessage('A = '+IntToStr(A)+' and B = '+IntToStr(B));
ShowMessage('A + B = '+IntToStr(A+B));
end;
22.5.3. Result A = 1 and B = 999999
A + B = 1000000
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 40 of 366
23. Case - A mechanism for acting upon different values of an Ordinal
23.1. Unit
Iris Standard
23.2. Type
Keyword
23.3. Description
The case keyword provides a structured equivalent to a sequence of if statements on the
same variable. The case statement is more elegant, more efficient, and easier to maintain than multiple if nestings.
23.4. Syntax 1 case Ordinal expression of
Ordinal value {,ordinal value...} : Statement;
{...}
else Statement;
end;
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 41 of 366
23.5. Example
23.5.1. Name
Standard case statement usage
23.5.2. Code // remember to declare the procedure at type using the following line
// procedure showcolour(colour : string);
var
colour : string;
number : Integer;
begin
// show the colour before it has an assigned value
ShowColour(colour);
// now set the colour and try again
colour := 'Green';
ShowColour(colour);
// calculations can also be used in the case statement
number := 17;
case number mod 2 of
0 : ShowMessage(IntToStr(Number)+' mod 2 = 0');
1 : ShowMessage(IntToStr(Number)+' mod 2 = 1');
else ShowMessage(IntToStr(Number)+' mod 2 is unknown');
end;
end;
// procedure to show the colour of a passed
procedure TUntitled.ShowColour(colour : string);
begin
// use a case statement to see the colour of the passed var
// note how important the else clause is, even though we have
// apparently covered all string values!
case colour of
'Red' : ShowMessage('The colour is Red');
'Green' : ShowMessage('The colour is Green');
'Blue' : ShowMessage('The colour is Blue');
'Yellow' : ShowMessage('The colour is Yellow');
else ShowMessage('The colour is Unknown!');
end;
end;
23.5.3. Result The colour is Unknown!
The colour is Green
17 mod 2 is 1
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 42 of 366
24. ChangeFileExt - Change the extension part of a file name
24.1. Unit
SysUtils
24.2. Type
Function
24.3. Description
The ChangeFileExt function changes the Extension value of a file FileName, returning the new
value as a string.
24.4. Syntax function ChangeFileExt(const FileName, Extension : string) : string;
24.5. Example
24.5.1. Name
Renaming Test.exe to Test.bak
24.5.2. Code var
oldName, newName : string;
begin
// try to rename the current test.exe to test.bak
oldName := 'Test.exe';
newName := ChangeFileExt(oldName, '.bak');
// show the old and new values
ShowMessage('Old name = '+oldName);
ShowMessage('New name = '+newName);
end;
24.5.3. Result Old name = Test.exe
New name = Test.bak
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 43 of 366
25. ChangePage - Change a page
25.1. Unit
Iris Standard
25.2. Type
Frame Function
25.3. Description
Opens a new screen instead of the active screen
25.4. Syntax procedure ChangePage(PageName: string);
25.5. Example 1
25.5.1. Name
Open the screen 'ScreenName'
25.5.2. Code begin
ChangePage('ScreenName');
end;
25.5.3. Result No result specified
25.6. Example 2
25.6.1. Name
Open the screen 'ScreenName' in the frame 'FrameName'
25.6.2. Code begin
FrameName.ChangePage('ScreenName');
end;
25.6.3. Result No result specified
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 44 of 366
26. Char - Variable type holding a single character
26.1. Unit
System
26.2. Type
Type
26.3. Description
The Char type is a simple variable type used to hold a single character. It can be assigned
from a character constant, or an integer.
26.4. Syntax type : Char = #0..#255;
26.5. Example
26.5.1. Name
Different ways of assigning to and from a Char
26.5.2. Code var
myChar : Char;
begin
myChar := 'g'; // assign from a character constant
ShowMessage('Letter g = '+myChar);
myChar := #65; // assign from an integer constant
ShowMessage('#65 = '+myChar);
myChar := Chr(66); // using chr to convert a number
ShowMessage('Chr(66) = '+myChar);
end;
26.5.3. Result Letter g = g
#65 = A
Chr(66) = B
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 45 of 366
27. ChDir - Change the working drive plus path for a specified drive
27.1. Unit
System
27.2. Type
Procedure
27.3. Description
The ChDir procedure sets the working drive + path values to the supplied Directory. There
are as many working directories as drives on the target machine. if the directory is invalid, you will get an error such as ElnOutError, and the directory will remain unchanged.
27.4. Syntax procedure ChDir(const Directory : string);
27.5. Example
27.5.1. Name
Getting and setting the directory for the C: drive
27.5.2. Code var
directory : string;
begin
// get the directory for the c drive
GetDir(2, directory);
ShowMessage('default C drive directory = '+directory);
// set the c directory to this value
ChDir(directory);
GetDir(2, directory);
ShowMessage('default C drive directory = '+directory);
// try to set to an invalid value
ChDir('C:Bad/Path/Value');
GetDir(2, directory);
ShowMessage('default C drive directory = '+directory);
end;
27.5.3. Result The following output is representative, and will necessarily vary
from PC to PC:
C:\IrisTest
C:\IrisTest
EInOutError ('Invalid file name')
IrisTest
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 46 of 366
28. Chr - Convert an integer into a character
28.1. Unit
System
28.2. Type
Function
28.3. Description
The Chr function converts an IntValue integer into either an AnsiChar or WideChar as
appropriate.
28.4. Syntax function Chr(IntValue : Integer) : AnsiChar;
28.5. Example
28.5.1. Name
Showing Chr usage
28.5.2. Code var
tab : char;
crlf : string;
begin
// show the use of chr
tab := Chr(9);
crlf := Chr(13)+Chr(10);
ShowMessage('Hello'+tab+'World');
ShowMessage('');
ShowMessage('Hello'+crlf+'World');
ShowMessage('');
end;
28.5.3. Result Hello World
Hello
World
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 47 of 366
29. ClearMailBox - Clears the current MailBox
29.1. Unit
Iris Standard
29.2. Type
MailBox Function
29.3. Description
Clears the current mailbox. MailBoxes can be used to pass structrured values to for example
popups.
29.4. Syntax procedure ClearMailbox;
29.5. Example
29.5.1. Name
Using MailBoxes
29.5.2. Code begin
// set the mailbox 'mymailbox' to the object 'unit23'
SetMailBox('MyMailBox','Unit23')
// the following could be done in a linked popup
// write a value to the tag '[mymailbox].open', - which will be unit23.open
WriteTagValue(ExpandMailbox('[MyMailBox].Open'),1);
// remove the mailbox
RemoveMailbox('MyMailBox')
// the following could be done in another linked popup
// set the mailbox 'mymailbox' to the object 'unit23.modulea'
SetMailBox('MyMailBox','Unit23.ModuleA')
// write a value to the tag '[mymailbox].status', - which will be unit23.modulea.status
WriteTagValue(ExpandMailbox('[MyMailBox].Open'),0);
// clear the current mailbox
ClearMailbox;
end;
29.5.3. Result
Unit23.Open is written inside popup 1
Unit23.ModuleA.Status is written inside popup 2 that is a popup from popup 1
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 48 of 366
30. CloseCurrentPage - Close a screen
30.1. Unit
Iris Standard
30.2. Type
Frame Function
30.3. Description
Closes the active screen. Note that this can also be a popup screen.
30.4. Syntax procedure CloseCurrentPage;
30.5. Example
30.5.1. Name
Close the current screen
30.5.2. Code begin
// closes the screen
CloseCurrentPage;
end;
30.5.3. Result No result specified
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 49 of 366
31. CloseFile - Closes an open file
31.1. Unit
System
31.2. Type
Procedure
31.3. Description
The CloseFile procedure closes an open file given by FileHandle. The file must have been
assigned, and opened with Append, Reset or ReWrite. The file is closed, and the handle is
made available for further assignment to files.
31.4. Syntax procedure CloseFile(var FileHandle : TextFile);
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 50 of 366
31.5. Example
31.5.1. Name
Closing after write and read operations
31.5.2. Code var
myFile : TextFile;
text : string;
begin
// try to open the test.txt file for writing to
AssignFile(myFile, 'Test.txt');
ReWrite(myFile);
// write a couple of well known words to this file
WriteLn(myFile, 'Hello');
WriteLn(myFile, 'World');
// close the file
CloseFile(myFile);
// reopen the file in read only mode
Reset(myFile);
// display the file contents
while not Eof(myFile) do
begin
ReadLn(myFile, text);
ShowMessage(text);
end;
// close the file for the last time
CloseFile(myFile);
end;
31.5.3. Result Hello
World
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 51 of 366
32. CompareStr - Compare two strings for equality
32.1. Unit
SysUtils
32.2. Type
Function
32.3. Description
The CompareStr function compares String1 and String2 for equality. It returns these values :
String1 < String2 : -ve numberString1 = String2 : 0String1 > String2 : +ve number The
comparison is not affected by length - it is carried out on a letter by letter basis. But a longer string is greater than a shorter, otherwise matching string. The comparison is case sensitive.
32.4. Syntax function CompareStr(const String1, String2 : string) : Integer;
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 52 of 366
32.5. Example
32.5.1. Name
Compare various strings
32.5.2. Code // remember to declare the procedure at type using the following line
// procedure comparestrings(const string1, string2: string);
begin
// compare two obviously different strings
CompareStrings('HELLO', 'WORLD');
// compare identical strings
CompareStrings('Hi 2 you', 'Hi 2 you');
// upper case letters follow lower case in iris
CompareStrings('ABC', 'abc');
// all letters follow numbers in iris
CompareStrings('abc', '123');
end;
// compare two strings, and show which is bigger than the other
procedure TUntitled.CompareStrings(const string1, string2: string);
var
result : Integer;
begin
// compare some strings
result := CompareStr(string1, string2);
if result < 0 then ShowMessage(string1+' < '+string2);
if result = 0 then ShowMessage(string1+' = '+string2);
if result > 0 then ShowMessage(string1+' > '+string2);
end;
32.5.3. Result HELLO < WORLD
Hi 2 you = Hi 2 you
ABC > abc
abc > 123
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 53 of 366
33. CompareText - Compare two strings for equality, ignoring case
33.1. Unit
SysUtils
33.2. Type
Function
33.3. Description
The CompareText function compares String1 and String2 for equality, ignoring case. It
returns these values : String1 < String2 : -ve numberString1 = String2 : 0String1 > String2 : +ve number The comparison is not affected by length - it is carried out on a letter by letter
basis. But a longer string is greater than a shorter, otherwise matching string.
33.4. Syntax function CompareText(const String1, String2 : string) : Integer;
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 54 of 366
33.5. Example
33.5.1. Name
Compare various strings
33.5.2. Code // remember to declare the procedure at type using the following line
// procedure comparestrings(const string1, string2: string);
begin
// compare two obviously different strings
CompareStrings('HELLO', 'WORLD');
// compare identical strings
CompareStrings('Hi 2 you', 'Hi 2 you');
// ansicomparetext treats upper and lower case identically
CompareStrings('ABCdef', 'abcDEF');
// all letters follow numbers in iris
CompareStrings('abc', '123');
end;
// compare two strings, and show which is bigger than the other
procedure TUntitled.CompareStrings(const string1, string2: string);
var
result : Integer;
begin
// compare some strings
result := CompareText(string1, string2);
if result < 0 then ShowMessage(string1+' < '+string2);
if result = 0 then ShowMessage(string1+' = '+string2);
if result > 0 then ShowMessage(string1+' > '+string2);
end;
33.5.3. Result HELLO < WORLD
Hi 2 you = Hi 2 you
ABCdef = abcDEF
abc > 123
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 55 of 366
34. CompareValue - Compare numeric values with a tolerance
34.1. Unit
Math
34.2. Type
Function
34.3. Description
CompareValue allows floating point numbers to be compared in a tolerant way. if the two
numbers are close enough together, they are deemed to be equal. The delta value is the permitted tolerance. There seems no point to the author in providing the Integer version of
this function with no delta. TValueRelationship supports the following values: LessThanValue
-1EqualsValue 0GreaterThanValue 1
34.4. Syntax function CompareValue (const A, B : Single|Double|Extended; delta : Single|Double|Extended) : TValueRelationship;
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 56 of 366
34.5. Example
34.5.1. Name
Comparing floating point numbers
34.5.2. Code var
A : Single;
B : Single;
C : Single;
begin
A := 23.0;
B := 23.0;
C := 23.1;
// compare 2 equal floats
case CompareValue(A, B, 0) of
LessThanValue : ShowMessage('A < B');
EqualsValue : ShowMessage('A = B');
GreaterThanValue : ShowMessage('A > B');
end;
// compare 2 unequal floats
case CompareValue(A, C, 0) of
LessThanValue : ShowMessage('A < C');
EqualsValue : ShowMessage('A = C');
GreaterThanValue : ShowMessage('A > C');
end;
// compare 2 unequal floats - but allow for a difference of up to +/- 0.2
case CompareValue(A, C, 0.2) of
LessThanValue : ShowMessage('A < C');
EqualsValue : ShowMessage('A = C');
GreaterThanValue : ShowMessage('A > C');
end;
end;
34.5.3. Result A = B
A < C
A = C
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 57 of 366
35. Const - Starts the definition of fixed data values
35.1. Unit
Iris Standard
35.2. Type
Keyword
35.3. Description
The const keyword is used to start a section of constant definitions. The section is terminated
by the next keyword in a program. Within the section, one or more constants may be
defined.
35.4. Syntax const Name1 = Expression1;
35.5. Example
35.5.1. Name
Illustrating the different constant types
35.5.2. Code const
MAX_LINES = 3;
CRUDE_PI = 22/7;
HELLO = 'Hello World';
var
i : Integer;
begin
// display our crude value of pi
ShowMessage('Crude Pi = '+FloatToStr(CRUDE_PI));
// say hello to the world
ShowMessage(HELLO);
// display max_lines of data
for i := 1 to MAX_LINES do
ShowMessage(Chr(i+64));
end;
35.5.3. Result Crude Pi = 3.14285714285714
Hello World
A
B
C
Script Language Reference
Error! Use the Home tab to apply Kop 1 to the text that you want to appear here.Error! Use the Home tab to apply Kop 1
to the text that you want to appear here.
Page 58 of 366
36. Continue - Forces a jump to the next iteration of a loop
36.1. Unit
System
36.2. Type
Procedure
36.3. Description
The Continue procedure forces a jump past the remaining statements within a loop, back to
the next loop iteration. Like the goto statement, it should be used with caution. It is
important to note that the Continue statement only jumps to the start of the current loop - not out of any nested loops above it. The goto statement can.
36.4. Syntax procedure Continue;
36.5. Example
36.5.1. Name
Skipping loop processing for certain loop values
36.5.2. Code var
i : Integer;
s : string;
begin
s := '';
// a big loop
for i := 1 to 9 do
begin
// skip loop processing for certain values of i
if (i = 3) or (i = 7) the