You are on page 1of 68

FastScript 1.

9
Scripting library
Developer's manual
Copyright (c) 1998-2005 by Fast Reports Inc.
Author A!e"an#er $%yganen&o
e-'ai! t%()ast-report.co'
ho'e page http**+++.)astreport.ru
http**+++.)ast-report.co'
Introduction
What is FastScript
Quick start
Features and missing features
Language reference
Script structure
Data types
Classes
Functions
Events
Enumerations and sets
Arrays
What is FastScript
Fast,cript is a scripting !ibrary. It is use)u! )or the progra''ers +ho +ant to a##
scripting abi!ity to their pro-ects. Fast,cript is +ritten on 100. /b-ect 0asca! an# can be
insta!!e# in 1or!an# 2e!phi 3-45 C661ui!#er 3-7 an# 8y!i" 1-9.
:ni;ue )eature o) Fast,cript is abi!ity to use se<era! !anguages (0asca!,cript, C66,cript,
=,cript an# 1asic,cript)5 so you can +rite scripts using your )a<ourite !anguage.
Fast,cript #oesn>t use ?icroso)t ,cripting @ost5 so it can be use# in Ain#o+s an# Binu"
en<iron'ent.
Fast,cript co'bines cross-p!at)or' scripting5 )ast co#e e"ecution5 s'a!! )ootprint5 rich
set o) )eatures an# a sp!en#i# sca!abi!ity. ?a&e your app!ications the 'ost )!e"ib!e an#
po+er)u! ones +ith Fast,criptC
Quick start
@ere is a sa'p!e co#e +hich #e'onstrates the easiest +ay o) using Fast,cript. For the
correct +or& o) the e"a'p!e put the co'ponents )s,cript1 $)s,cript an# )s0asca!1
$)s0asca! on the )or' .
uses FS_iInterpreter;
procedure TForm1.Button1Click(Sender: TObject);
bein
!sScript1.Cle"r; ## do t$is i! %ou runnin m"n% scripts !rom one
component
!sScript1.&ines.Te't :( )bein S$o*+ess"e()),ello-))) end.);
!sScript1.."rent :( !s/lob"l0nit; ## use st"nd"rd cl"sses "nd met$ods
!sScript1.S%nt"'T%pe :( )."sc"lScript);
i! !sScript1.Compile t$en
!sScript1.1'ecute else
S$o*+ess"e(!sScript1.1rror+s);
end;
As you can see5 there is nothing #i))icu!t here. At )irst +e )i!! in the )s,cript1.Bines
property +ith the script te"t. For using stan#ar# types an# )unctions +e set 0arent
property to the )sD!oba!:nit. $hen +e co'pi!e the script using 0asca!,cript !anguage
(you can use C66,cript5 1asic,cript5 =,cript as +e!!). I) co'pi!ation is success)u!
Co'pi!e 'etho# returns $rue an# +e can E"ecute the script. /ther+ise the error 'essage
is sho+n.
Features and missing features
Features
- ?u!ti-!anguage architecture a!!o+s you to use a nu'ber o) !anguages (at present
'o'ent 0asca!,cript5 C66,cript5 1asic,cript5 =,cript). Fou can a## any proce#ura!
!anguage (!anguage gra''ar is store# in G?B )or'at).
- ,tan#ar# !anguage set <ariab!es5 constants5 proce#ures5 )unctions (neste# )unctions
a!!o+e#) +ith <ar*const*#e)au!t para'eters5 a!! the stan#ar# operators an# state'ents
(inc!u#ing case5 try*)ina!!y*e"cept5 +ith)5 types (int5 )!oat5 boo!5 char5 string5 'u!ti-
#i'ensiona! array5 enu'5 <ariant)5 c!asses (+ith 'etho#s5 e<ents5 properties5 in#ices an#
#e)au!t properties).
- $ypes co'patibi!ity chec&ing.
- Access to any ob-ect insi#e your app!ication. ,tan#ar# !ibraries )or the access to the
base c!asses5 contro!s5 )or's an# 12. Easi!y e"pan#ab!e !ibrary architecture.
- ,'a!! )ootprint - 90-1508b #epen#ing on use# 'o#u!es.
- Can be use# in 'u!ti-threa# en<iron'ent.
Missing features
- Ho type #ec!arations (recor#s5 c!asses) in the scriptI no recor#s5 no pointers5 no sets
(but you can use >IH> operator - Ja in K>a>..>c>5>#>LJ)5 no shortstrings5 no D/$/ state'ent.
- C66,cript no octa! constantsI no >brea&> in the ,AI$C@ operator (,AI$C@ +or&s !i&e
0asca! CA,E)I >66> an# >--> operators are possib!e on!y a)ter the <ariab!es5 that is >66i> is
not a!!o+e#I >-->5 >66> an# >M> operators #o not return a <a!ue5 that is >i)(i66)> is not a!!o+e#I
a!! the i#enti)iers are case-insensiti<eI H:BB constant is the 0asca! Hu!! - use ni! instea#
o) H:BB.
=,cript an# 1asic,cript see synta" #iagra's.
Language reference
PascalScript syntax
.ror"m 23 4.5O/56+ Ident );)7
40sesCl"use7
Block ).)
0sesCl"use 23 0S1S (Strin#8)... );)
Block 23 49eclSection7...
CompoundStmt
9eclSection 23 ConstSection
23 :"rSection
23 .rocedure9eclSection
ConstSection 23 CO;ST (Const"nt9ecl)...
Const"nt9ecl 23 Ident )() 1'pression );)
:"rSection 23 :65 (:"r&ist );))...
:"r&ist 23 Ident#)8)... ):) T%peIdent 4Init:"lue7
T%peIdent 23 Ident
23 6rr"%
6rr"% 23 6556< )4) 6rr"%9im#)8)... )7) OF Ident
6rr"%9im 23 1'pression..1'pression
23 1'pression
Init:"lue 23 )() 1'pression
1'pression 23 Simple1'pression 45elOp Simple1'pression7...
Simple1'pression 23 4)2)7 Term 46ddOp Term7...
Term 23 F"ctor 4+ulOp F"ctor7...
F"ctor 23 9esin"tor
23 0nsined;umber
23 Strin
23 )() 1'pression )))
23 ;OT F"ctor
23 )4) SetConstructor )7)
SetConstructor 23 Set;ode#)8)...
Set;ode 23 1'pression 4)..) 1'pression7
5elOp 23 )3)
23 )=)
23 )=()
23 )3()
23 )=3)
23 )()
23 I;
23 IS
6ddOp 23 )>)
23 )2)
23 O5
23 ?O5
+ulOp 23 )@)
23 )#)
23 9I:
23 +O9
23 6;9
23 S,&
23 S,5
9esin"tor 23 4)A)7 Ident 4).) Ident B )4) 1'pr&ist )7) B )() 1'pr&ist
)))7...
1'pr&ist 23 1'pression#)8)...
St"tement 23 4SimpleSt"tement B StructStmt7
Stmt&ist 23 St"tement#);)...
SimpleSt"tement 23 9esin"tor
23 9esin"tor ):() 1'pression
23 B516C B CO;TI;01 B 1?IT
StructStmt 23 CompoundStmt
23 Condition"lStmt
23 &oopStmt
23 Tr%Stmt
23 Dit$Stmt
CompoundStmt 23 B1/I; Stmt&ist 1;9
Condition"lStmt 23 I!Stmt
23 C"seStmt
I!Stmt 23 IF 1'pression T,1; St"tement 41&S1 St"tement7
C"seStmt 23 C6S1 1'pression OF C"seSelector#);)... 41&S1 St"tement7
4);)7 1;9
C"seSelector 23 SetConstructor ):) St"tement
&oopStmt 23 5epe"tStmt
23 D$ileStmt
23 ForStmt
5epe"tStmt 23 51.16T Stmt&ist 0;TI& 1'pression
D$ileStmt 23 D,I&1 1'pression 9O St"tement
ForStmt 23 FO5 Ident ):() 1'pression To9o*nto 1'pression 9O St"tement
To9o*nto 23 (TO B 9OD;TO)
Tr%Stmt 23 T5< Stmt&ist (FI;6&&< B 1?C1.T) Stmt&ist 1;9
Dit$Stmt 23 DIT, (9esin"tor#8..) 9O St"tement
.rocedure9eclSection 23 .rocedure9ecl
23 Function9ecl
.rocedure9ecl 23 .rocedure,e"din );)
Block );)
.rocedure,e"din 23 .5OC19051 Ident 4Form"l."r"meters7
Function9ecl 23 Function,e"din );)
Block );)
Function,e"din 23 F0;CTIO; Ident 4Form"l."r"meters7 ):) Ident
Form"l."r"meters 23 )() Form"l."r"m#);)... )))
Form"l."rm 23 4:65 B CO;ST7 :"r&ist
!""Script syntax
.ror"m 23 40sesCl"use7
49eclSection7...
CompoundStmt
0sesCl"use 23 )E) I;C&091 (Strin#8)...
9eclSection 23 ConstSection
23 .rocedure9eclSection
23 :"rStmt );)
ConstSection 23 )E) 91FI;1 Const"nt9ecl
Const"nt9ecl 23 Ident 1'pression
:"rStmt 23 Ident Ident 46rr"%7 4Init:"lue7 #)8)...
6rr"%9e! 23 )4) 6rr"%9im#)8)... )7)
6rr"%9im 23 1'pression
Init:"lue 23 )() 1'pression
1'pression 23 Simple1'pression 45elOp Simple1'pression7...
Simple1'pression 23 4)2)7 Term 46ddOp Term7...
Term 23 F"ctor 4+ulOp F"ctor7...
F"ctor 23 9esin"tor
23 0nsined;umber
23 Strin
23 )() 1'pression )))
23 )-) F"ctor
23 )4) SetConstructor )7)
23 ;e*Oper"tor
SetConstructor 23 Set;ode#)8)...
Set;ode 23 1'pression 4)..) 1'pression7
;e*Oper"tor 23 ;1D 9esin"tor
5elOp 23 )3)
23 )=)
23 )=()
23 )3()
23 )-()
23 )(()
23 I;
23 IS
6ddOp 23 )>)
23 )2)
23 )BB)
23 )F)
+ulOp 23 )@)
23 )#)
23 )G)
23 )HH)
23 )==)
23 )33)
9esin"tor 23 4)H)7 Ident 4).) Ident B )4) 1'pr&ist )7) B )() 1'pr&ist
)))7...
1'pr&ist 23 1'pression#)8)...
St"tement 23 4SimpleSt"tement );) B StructStmt B 1mpt%Stmt7
1mpt%Stmt 23 );)
Stmt&ist 23 (St"tement...)
SimpleSt"tement 23 9eleteStmt
23 6ssinStmt
23 :"rStmt
23 C"llStmt
23 5eturnStmt
23 (B516C B CO;TI;01 B 1?IT)
9eleteStmt 23 91&1T1 9esin"tor
6ssinStmt 23 9esin"tor 4)>)B)2)B)@)B)#)7)() 1'pression
C"llStmt 23 9esin"tor 4)>))>)B)2))2)7
5eturnStmt 23 51T05; 41'pression7
StructStmt 23 CompoundStmt
23 Condition"lStmt
23 &oopStmt
23 Tr%Stmt
CompoundStmt 23 )I) 4Stmt&ist7 )J)
Condition"lStmt 23 I!Stmt
23 C"seStmt
I!Stmt 23 IF )() 1'pression ))) St"tement 41&S1 St"tement7
C"seStmt 23 SDITC, )() 1'pression ))) )I) (C"seSelector)... 491F60&T ):)
St"tement7 )J)
C"seSelector 23 C6S1 SetConstructor ):) St"tement
&oopStmt 23 5epe"tStmt
23 D$ileStmt
23 ForStmt
5epe"tStmt 23 9O St"tement 4);)7 D,I&1 )() 1'pression ))) );)
D$ileStmt 23 D,I&1 )() 1'pression ))) St"tement
ForStmt 23 FO5 )() ForStmtItem );) 1'pression );) ForStmtItem )))
St"tement
ForStmtItem 23 6ssinStmt
23 :"rStmt
23 C"llStmt
23 1mpt%
Tr%Stmt 23 T5< CompoundStmt (FI;6&&< B 1?C1.T) CompoundStmt
Function9ecl 23 Function,e"din CompoundStmt
Function,e"din 23 Ident Ident 4Form"l."r"meters7
Form"l."r"meters 23 )() 4Form"l."r"m#);)...7 )))
Form"l."r"m 23 T%peIdent (4)H)7 Ident 4Init:"lue7#)8))...
#Script syntax
.ror"m 23 St"tements
St"tements 23 St"tement...
Block 23 )I) St"tements )J)
ImportStmt 23 I+.O5T (Strin#8)...
:"rStmt 23 :65 (:"r9ecl#)8))...
:"r9ecl 23 Ident 46rr"%7 4Init:"lue7
6rr"% 23 )4) (6rr"%9im#)8))... )7)
6rr"%9im 23 1'pression
Init:"lue 23 )() 1'pression
1'pression 23 Simple1'pression 45elOp Simple1'pression7...
Simple1'pression 23 4)2)7 Term 46ddOp Term7...
Term 23 F"ctor 4+ulOp F"ctor7...
F"ctor 23 9esin"tor
23 0nsined;umber
23 Strin
23 )() 1'pression )))
23 )-) F"ctor
23 )4) SetConstructor )7)
23 ;e*Oper"tor
23 )=) F5Strin )3)
SetConstructor 23 Set;ode#)8)...
Set;ode 23 1'pression 4)..) 1'pression7
;e*Oper"tor 23 ;1D 9esin"tor
5elOp 23 )3)
23 )=)
23 )=()
23 )3()
23 )-()
23 )(()
23 I;
23 IS
6ddOp 23 )>)
23 )2)
23 )BB)
23 )F)
+ulOp 23 )@)
23 )#)
23 )G)
23 )HH)
23 )==)
23 )33)
9esin"tor 23 4)H)7 Ident 4).) Ident B )4) 1'pr&ist )7) B )() 41'pr&ist7
)))7...
1'pr&ist 23 1'pression#)8)...
St"tement 23 (6ssinStmt B C"llStmt B Bre"kStmt B ContinueStmt B
9eleteStmt B 9oD$ileStmt B ForStmt B FunctionStmt B
I!Stmt B ImportStmt B 5eturnStmt B S*itc$Stmt B
:"rStmt B D$ileStmt B Dit$Stmt B Block) 4);)7
Bre"kStmt 23 B516C
ContinueStmt 23 CO;TI;01
9eleteStmt 23 91&1T1 9esin"tor
6ssinStmt 23 9esin"tor 4)>)B)2)B)@)B)#)7)() 1'pression
C"llStmt 23 9esin"tor 4)>))>)B)2))2)7
5eturnStmt 23 51T05; 41'pression7
I!Stmt 23 IF )() 1'pression ))) St"tement 41&S1 St"tement7
S*itc$Stmt 23 SDITC, )() 1'pression ))) )I) (C"seSelector)... 491F60&T
):) St"tement7 )J)
C"seSelector 23 C6S1 SetConstructor ):) St"tement
9oD$ileStmt 23 9O St"tement 4);)7 D,I&1 )() 1'pression ))) );)
D$ileStmt 23 D,I&1 )() 1'pression ))) St"tement
ForStmt 23 FO5 )() ForStmtItem );) 1'pression );) ForStmtItem )))
St"tement
ForStmtItem 23 6ssinStmt
23 C"llStmt
23 :"rStmt
23 1mpt%
Tr%Stmt 23 T5< CompoundStmt (FI;6&&< B 1?C1.T) CompoundStmt
FunctionStmt 23 Function,e"din Block
Function,e"din 23 F0;CTIO; Ident Form"l."r"meters
Form"l."r"meters 23 )() 4Form"l."r"m#)8)...7 )))
Form"l."r"m 23 4)H)7 Ident
Dit$Stmt 23 DIT, )() 9esin"tor ))) St"tement
$asicScript syntax
.ror"m 23 St"tements
St"tements 23 (1O& B St"tement&ist 1O&)...
St"tement&ist 23 St"tement#):)...
ImportStmt 23 I+.O5TS (Strin#8)...
9imStmt 23 9I+ (:"r9ecl#)8))...
:"r9ecl 23 Ident 46rr"%7 46sCl"use7 4Init:"lue7
6sCl"use 23 6S Ident

6rr"% 23 )4) 6rr"%9im#)8)... )7)
6rr"%9im 23 1'pression
Init:"lue 23 )() 1'pression
1'pression 23 Simple1'pression 45elOp Simple1'pression7...
Simple1'pression 23 4)2)7 Term 46ddOp Term7...
Term 23 F"ctor 4+ulOp F"ctor7...
F"ctor 23 9esin"tor
23 0nsined;umber
23 Strin
23 )() 1'pression )))
23 ;OT F"ctor
23 ;e*Oper"tor
23 )=) F5Strin )3)
SetConstructor 23 Set;ode#)8)...
Set;ode 23 1'pression 4)..) 1'pression7
;e*Oper"tor 23 ;1D 9esin"tor
5elOp 23 )3)
23 )=)
23 )=()
23 )3()
23 )=3)
23 )()
23 I;
23 IS
6ddOp 23 )>)
23 )2)
23 )H)
23 O5
23 ?O5
+ulOp 23 )@)
23 )#)
23 )K)
23 +O9
23 6;9
9esin"tor 23 469951SSOF7 Ident 4).) Ident B )4) 1'pr&ist )7) B )()
41'pr&ist7 )))7...
1'pr&ist 23 1'pression#)8)...
St"tement 23 Bre"kStmt
23 C"seStmt
23 ContinueStmt
23 9eleteStmt
23 9imStmt
23 9oStmt
23 1'itStmt
23 ForStmt
23 FuncStmt
23 I!Stmt
23 ImportStmt
23 .rocStmt
23 5eturnStmt
23 SetStmt
23 Tr%Stmt
23 D$ileStmt
23 Dit$Stmt
23 6ssinStmt
23 C"llStmt
Bre"kStmt 23 B516C
ContinueStmt 23 CO;TI;01

1'itStmt 23 1?IT

9eleteStmt 23 91&1T1 9esin"tor
SetStmt 23 S1T 6ssinStmt
6ssinStmt 23 9esin"tor 4)>)B)2)B)@)B)#)7)() 1'pression
C"llStmt 23 9esin"tor 4)>))>)B)2))2)7
5eturnStmt 23 51T05; 41'pression7
I!Stmt 23 IF 1'pression T,1; T$enStmt
T$enStmt 23 1O& 4St"tements7 41lseI!Stmt B 1lseStmt7 1;9 IF
23 St"tement&ist
1lseI!Stmt 23 1&S1IF 1'pression T,1;
(1O& 4St"tements7 41lseI!Stmt B 1lseStmt7 B St"tement)

1lseStmt 23 1&S1 (1O& 4St"tements7 B St"tement)

C"seStmt 23 S1&1CT C6S1 1'pression 1O&
(C"seSelector...) 4C6S1 1&S1 ):) St"tements7 1;9 S1&1CT
C"seSelector 23 C6S1 SetConstructor ):) St"tements
9oStmt 23 9O 4St"tements7 &OO. (0;TI& B D,I&1) 1'pression
D$ileStmt 23 D,I&1 1'pression 4St"tements7 D1;9
ForStmt 23 FO5 Ident )() 1'pression TO 1'pression 4ST1. 1'pression7 1O&
4St"tements7 ;1?T
Tr%Stmt 23 T5< St"tements (FI;6&&< B C6TC,) 4St"tements7 1;9 T5<
Dit$Stmt 23 DIT, 9esin"tor 1O& St"tements 1;9 DIT,
.rocStmt 23 S0B Ident 4Form"l."r"meters7 1O& 4St"tements7 1;9 S0B
FuncStmt 23 F0;CTIO; Ident 4Form"l."r"meters7 46sCl"use7 1O&
4St"tements7 1;9 F0;CTIO;
Form"l."r"meters 23 )() (Form"l."r"m#)8))... )))
Form"l."rm 23 4B<51F B B<:6&7 :"r&ist
Script structure
$he 0asca!,cript structure is the sa'e as in /b-ect 0asca! !anguage
El"nu"e ."sc"lScript ## t$is is option"l
pror"m +%.ror"m; ## t$is is option"l
uses )unit1.p"s)8 )unitL.p"s);
## uses section 2 must be be!ore "n% ot$er sections
## M1.L c$"nes: *"rnin- t$e included units "re not inserted into t$e
m"in unit te't. So it c"n $"Me
## )pror"m)8 )uses) sections "nd must $"Me t$e )m"in procedure)
section.
M"r ## M"r section
i8 j: Inteer;
const ## const section
pi ( N.1O1PQ;
procedure p1; ## procedures "nd !unction
M"r
i: Inteer;
procedure pL; ## nested procedure
bein
end;
bein
end;
bein ## m"in procedure t$"t *ill be e'ecuted.
end.
$he C66,cript structure is
El"nu"e C>>Script ## t$is is option"l
Einclude Runit1.cppR8 RunitL.cppR
## uses section 2 must be be!ore "n% ot$er sections
int i8 j; ## M"r section
E91FI;1 pi ( N.1O1PQ ## const section
Moid p1() ## procedures "nd !unction
I ## t$ere is no nested procedures in C>>Script
J
I ## m"in procedure t$"t *ill be e'ecuted.
J
$he =,cript structure is
El"nu"e SScript ## t$is is option"l
import Runit1.jsR8 RunitL.jsR
## import section 2 must be be!ore "n% ot$er sections
M"r i8 j ( T; ## M"r section
!unction p1() ## procedures "nd !unction
I ##
J
## m"in procedure t$"t *ill be e'ecuted.
p1();
!or (i ( T; i = 1T; i>>) j>>;
$he 1asic,cript structure is
El"nu"e B"sicScript ## t$is is option"l
imports Runit1.MbR8 RunitL.MbR
## imports section 2 must be be!ore "n% ot$er sections
dim i8 j ( T ## M"r section
!unction !1() ## procedures "nd !unction
end !unction ##
sub p1()
end sub
## m"in procedure t$"t *ill be e'ecuted.
!or i ( T to 1T
p1()
ne't
Data types
Interna!!y Fast,cript operates +ith the Nariant type an# is base# on it. He<erthe!ess5 you
can use the )o!!o+ing pre#eter'ine# types in your scripts
B%te B S"me "s Inteer t%pe
Dord B
Inteer B
&onint B
C"rdin"l B
TColor B
Boole"n B Boole"n t%pe
5e"l B S"me "s 1'tended t%pe
Sinle B
9ouble B
1'tended B
T9"te B
TTime B
T9"teTime B
C$"r B C$"r t%pe
Strin B Strin t%pe
:"ri"nt B S"me "s :"ri"nt t%pe
.ointer B
6rr"% B 6rr"% t%pe
C66,cript 'aps so'e types to stan#ar# types
int5 !ong M Integer
<oi# M Integer
boo! M 1oo!ean
)!oat M E"ten#e#
=,cript has no types5 a!! types are <ariants. 1asic,cript 'ay ha<e types ()or e"a'p!e5
#i' i as Integer)5 or 'ay ha<e no types an# e<en no <ariab!e #ec!aration. In this case a
<ariab!e +i!! ha<e Nariant type.
Hot a!! o) these types can be assign-co'patib!e. Bi&e in /b-ect 0asca!5 you can>t assign
E"ten#e# or ,tring to an Integer. /n!y one type - the Nariant - can be assigne# to a!! the
types an# can get <a!ue )ro' any type.
E"cept the bui!t-in types you can use the enu'erate# types #e)ine# in your app!ication
or in a##-in 'o#u!es ()or e"a'p!e a)ter a##ing the $)sDraphicsR$$I co'ponent you can
use $0en?o#e5 $Font,ty!es an# other types).
Classes
Fou cannot #e)ine a c!ass insi#e the script5 but you can use the e"terna! c!asses #e)ine#
in a##-in 'o#u!es or your app!ication. $his is an e"a'p!e )ro' the 2E?/,O?ain #e'o
M"r
!: TForm;
b: TButton;
procedure ButtonClick(Sender: TButton);
bein
S$o*+ess"e(Sender.;"me);
!.+od"l5esult :( mrOk;
end;
## t$ere is no need to use "ll t$e p"r"meters in eMent $"ndlers
## bec"use no t%pe c$eckin is per!ormed $ere
procedure Button+ouse+oMe(Sender: TButton);
bein
b.C"ption :( )moMed oMer);
end;
bein
! :( TForm.Cre"te(nil);
!.C"ption :( )Test it-);
!.BorderSt%le :( bs9i"lo;
!..osition :( poScreenCenter;
b :( TButton.Cre"te(!);
b.;"me :( )Button1);
b.."rent :( !;
b.SetBounds(1T8 1T8 UP8 LP);
b.C"ption :( )Test);
b.OnClick :( AButtonClick; I s"me "s b.OnClick :( )ButtonClick) J
b.On+ouse+oMe :( AButton+ouse+oMe;
!.S$o*+od"l;
!.Free;
end.
As you can see there is no #i))erence bet+een 0asca!,cript an# 2e!phi co#e. Fou can
access any property (si'p!e5 in#e"e# or #e)au!t) or 'etho#. A!! the ob-ect>s pub!ishe#
properties are accessib!e )ro' the script by #e)au!t. 0ub!ic properties an# 'etho#s nee#
the i'p!e'entation co#e - that>s +hy you can access it partia!!y ()or e"a'p!e5 you cannot
access the $For'.0rint 'etho# or $For'.Can<as property because they are not
i'p!e'ente#).
Fou can a## your o+n c!asses - see J,criptingJ chapter )or #etai!s.
Functions
$here is a rich set o) stan#ar# )unctions +hich can be use# in a script. $o get an access
to these )unctions5 pass the )sD!oba!:nit re)erence to the $)s,cript.0arent property.
!unction IntToStr(i: Inteer): Strin
!unction Flo"tToStr(e: 1'tended): Strin
!unction 9"teToStr(e: 1'tended): Strin
!unction TimeToStr(e: 1'tended): Strin
!unction 9"teTimeToStr(e: 1'tended): Strin
!unction :"rToStr(M: :"ri"nt): Strin
!unction StrToInt(s: Strin): Inteer
!unction StrToFlo"t(s: Strin): 1'tended
!unction StrTo9"te(s: Strin): 1'tended
!unction StrToTime(s: Strin): 1'tended
!unction StrTo9"teTime(s: Strin): 1'tended
!unction Form"t(Fmt: Strin; 6rs: "rr"%): Strin
!unction Form"tFlo"t(Fmt: Strin; :"lue: 1'tended): Strin
!unction Form"t9"teTime(Fmt: Strin; 9"teTime: T9"teTime): Strin
!unction Form"t+"skTe't(1dit+"sk: strin; :"lue: strin): strin
!unction 1ncode9"te(<e"r8 +ont$8 9"%: Dord): T9"teTime
procedure 9ecode9"te(9"te: T9"teTime; M"r <e"r8 +ont$8 9"%: Dord)
!unction 1ncodeTime(,our8 +in8 Sec8 +Sec: Dord): T9"teTime
procedure 9ecodeTime(Time: T9"teTime; M"r ,our8 +in8 Sec8 +Sec: Dord)
!unction 9"te: T9"teTime
!unction Time: T9"teTime
!unction ;o*: T9"teTime
!unction 9"%O!Deek("9"te: 9"teTime): Inteer
!unction Is&e"p<e"r(<e"r: Dord): Boole"n
!unction 9"%sIn+ont$(n<e"r8 n+ont$: Inteer): Inteer
!unction &ent$(s: Strin): Inteer
!unction Cop%(s: Strin; !rom8 count: Inteer): Strin
!unction .os(substr8 s: Strin): Inteer
procedure 9elete(M"r s: Strin; !rom8 count: Inteer): Strin
procedure Insert(s: Strin; M"r sL: Strin; pos: Inteer): Strin
!unction 0pperc"se(s: Strin): Strin
!unction &o*erc"se(s: Strin): Strin
!unction Trim(s: Strin): Strin
!unction ;"meC"se(s: Strin): Strin
!unction Comp"reTe't(s8 s1: Strin): Inteer
!unction C$r(i: Inteer): C$"r
!unction Ord(c$: C$"r): Inteer
procedure Set&ent$(M"r S: Strin; &: Inteer)
!unction 5ound(e: 1'tended): Inteer
!unction Trunc(e: 1'tended): Inteer
!unction Int(e: 1'tended): Inteer
!unction Fr"c(?: 1'tended): 1'tended
!unction SVrt(e: 1'tended): 1'tended
!unction 6bs(e: 1'tended): 1'tended
!unction Sin(e: 1'tended): 1'tended
!unction Cos(e: 1'tended): 1'tended
!unction 6rcT"n(?: 1'tended): 1'tended
!unction T"n(?: 1'tended): 1'tended
!unction 1'p(?: 1'tended): 1'tended
!unction &n(?: 1'tended): 1'tended
!unction .i: 1'tended
procedure Inc(M"r i: Inteer; incr: Inteer ( 1)
procedure 9ec(M"r i: Inteer; decr: Inteer ( 1)
procedure 5"ise1'ception(."r"m: Strin)
procedure S$o*+ess"e(+s: :"ri"nt)
procedure 5"ndomiWe
!unction 5"ndom: 1'tended
!unction :"lidInt(cInt: Strin): Boole"n
!unction :"lidFlo"t(cFlt: Strin): Boole"n
!unction :"lid9"te(c9"te: Strin): Boole"n
!unction Cre"teOleObject(Cl"ss;"me: Strin): :"ri"nt
!unction :"r6rr"%Cre"te(Bounds: 6rr"%; T%p: Inteer): :"ri"nt
As you can see5 so'e )unctions*proce#ure ha<e #e)au!t para'eters. Fou can ca!! it -ust
!i&e in 2e!phi
Inc(");
Inc(b8 L);
Fou can connect o+n )unction*proce#ure to a script - see J,criptingJ chapter )or #etai!s.
Events
Fou can use e<ent han#!ers in the script. :n!i&e the 2e!phi e<ent han#!er5 script e<ent
han#!ers are not the methods of the object. $he )o!!o+ing e"a'p!e sho+s ho+ to
connect an e<ent han#!er to the $1utton./nC!ic& e<ent
M"r
b: TButton;
Form1: TForm;
procedure ButtonClick(Sender: TButton);
bein
S$o*+ess"e(Sender.;"me);
end;
bein
b :( TButton.Cre"te(Form1);
b.."rent :( Form1;
b.OnClick :( AButtonClick; ## s"me "s b.OnClick :( )ButtonClick)
b.OnClick :( nil; ## cle"r t$e eMent
end.
$here are so'e pre#e)ine# e<ents a<ai!ab!e in F,PiE<ents unit
T!s;oti!%1Ment
T!s+ouse1Ment
T!s+ouse+oMe1Ment
T!sCe%1Ment
T!sCe%.ress1Ment
T!sClose1Ment
T!sCloseXuer%1Ment
T!sC"n5esiWe1Ment
,ee the J$)sFor'sR$$$I co'ponentJ5 J$)sE"tCtr!sR$$I co'ponentJ an#
J$)s21Ctr!sR$$I co'ponentJ chapters )or a !ist o) the a<ai!ab!e e<ents.
Enumerations and Sets
Fast,cript supports enu'erations. Fou can +rite in a script
Form1.BorderSt%le :( bs9i"lo;
,ets are not supporte#. @o+e<er5 you can use set constants in the )o!!o+ing +ay
Font.St%le :( !sBold; ## Font.St%le :( 4!sBold7 in 9elp$i
Font.St%le :( !sBold > !sIt"lic; ## Font.St%le :( 4!sBold8 !sIt"lic7
Font.St%le :( T; ## Font.St%le :( 47
Arrays
Fast,cript supports a!! &in# o) arrays static (one- an# 'u!ti-#i'esiona!)5 #yna'ic5
<ariant arrays. $here is an e"a'p!e o) script that uses a!! array types
M"r
"r1: "rr"%4T..L7 o! Inteer;
"rL: "rr"% o! Inteer;
"rN: :"ri"nt;
Set&ent$("rL8 N);
"rN :( :"r6rr"%Cre"te(4T8 L78 M"rInteer);
"r14T7 :( 1;
"rL4T7 :( 1;
"rN4T7 :( 1;
FastScript component
palette
Delphi component palette
!fsScript component
!fsClasses"!!# component
!fs$raphics"!!# component
!fsForms"!!# component
!fsE%tCtrls"!!# component
!fsDialogs"!!# component
!fsD&"!!# component
!fsD&Ctrls"!!# component
!fs&DE"!!# component
!fsAD'"!!# component
!fs#&("!!# component
!fsChart"!!# component
Delphi component palette
A)ter the Fast,cript insta!!ing the JFast,criptJ tab +i!! be create# in the 2e!phi * C6
61ui!#er. $his tab contains the 'ain Fast,cript co'ponents such as $)s,cript5
$)sC!assesR$$I5 etc.
TfsScript component the main scripting component

$his is a 'ain scripting co'ponent.
Properties:
SyntaxType: String;
$he type o) the script !anguage. 1y #e)au!t )our types o) scripts are supporte#
J0asca!,criptJ5 JC66,criptJ5 J1asic,criptJ5 J=,criptJ. AarningC $he property has the
string type an# it is easy to 'a&e a 'ista&e in the synta" type in#ication. $he <a!ue by
#e)au!t is PascalScript.
Lines: TStrings;
A script te"t. Contains strings o) the script.
Methods:
function Compile: Boolean;
Co'pi!es the source co#e. ,ource co#e 'ust be p!ace# in the $)s,cript.Bines property
be)ore you ca!! the Co'pi!e 'etho#.
procedure Execute;
E"ecute script a)ter co'pi!ing.
function un: booleanI
Co'pi!e an# e"ecute script. Returns true i) co'pi!e +as success)u!. $his 'etho# is the
ana!ogue to the Compile 6 Execute.
Examples of use:
Example1.
2e!phi*8y!i" I2E. Boa#s script )i!e ?y$est,cript.pas an# e"ecute it.
!sScript1.&ines.&o"dFromFile(Y+%TestScript.p"sZ);
if !sScript1.Compile then
!sScript1.1'ecute
else
S$o*+ess"e(YScript compil"tion error-Z);
Example2.
2e!phi*8y!i" I2E. 0ressing the 1utton1 gi<es the strings )ro' )s,ynta"?e'o1
co'ponent to )s,cript1.Bines an# e"ecute script.
procedure TForm1.Button1Click(Sender: TObject);
begin
!sScript1.&ines :( !sS%nt"'+emo1.&ines;
if not !sScript1.5un then
S$o*+ess"e(YScript compil"tion error-Z);
end;
Example3.
2e!phi*8y!i" I2E. Boa#s QC66,criptR )ro' ?y$est,cript.cpp )i!e an# e"ecute it.
!sScript1.&ines.&o"dFromFile(Y+%TestScript.cppZ);
!sScript1.S%nt"'T%pe :( YC>>ScriptZ;
if !sScript1.Compile then
!sScript1.1'ecute
else
S$o*+ess"e(YScript compil"tion error-Z);
Example4.
S661ui!#er I2E. Boa#s QC66,criptR )ro' ?y$est,cript.cpp )i!e an# e"ecute it.
!sScript123&ines23&o"dFromFile(Y+%TestScript.cppZ);
!sScript123S%nt"'T%pe ( [C>>Script\;
if (!sScript123Compile())
!sScript1231'ecute();
else
S$o*+ess"e([Script compil"tion error-\);
TfsSynta!"emo script editor #ith synta! highlighting
A specia! a#<ance# $?e'o is a#apte# )or Fast,cript +ith support o) C66 an# 0asca!
synta" high!ighting.
Available in FastScript for VC onl!. "t#s a $bon%s$ component an& is not s%pporte& at
present time.
Properties:
SyntaxType: TSyntaxType;
$ype o) synta" high!ighting.
0ossib!e <a!ues
st!ascal - )or 0asca!5
stCpp - )or C665
stS"L - )or ,TB5
stText - a si'p!e te"t (+ithout high!ighting).
2e)au!t <a!ue st!ascal.
Lines: TStrings;
$he e#it te"t.
Sho#$ooter: Boolean;
,ho+s the )ooter +ith a cursor position5 etc.
Sho#%utter: Boolean;
,ho+s the in)o in the !e)t part o) a te"t +ith boo&'ar&s5 current step position5 etc.
Bloc&Color: TColor;
1ac&groun# co!or o) the se!ecte# te"t.
Bloc&$ontColor: TColor;
Co!or o) the se!ecte# te"t.
Comment'ttr: T$ont;
Attributes o) the co''ent )ont.
(ey#ord'ttr: T$ont;
Attributes o) &ey+or# )ont.
String'ttr: T$ont;
Attributes o) the string <a!ues )ont.
Text'ttr: T$ont;
Attributes o) a si'p!e te"t )ont.
)odified: Boolean;
$rue i) the te"t +as 'o#i)ie#.

SelText: String;
Contains a se!ecte# te"t.
Methods:
procedure CopyToClipboard;
Copies a se!ecte# te"t to the c!ipboar#.
procedure CutToClipboard;
?o<es a se!ecte# te"t to the c!ipboar#.
procedure !aste$romClipboard;
Inserts a te"t )ro' the c!ipboar# to the cursor position.
procedure Set!os*x+ y: ,nteger-;
,ets the cursor position in the te"t. Bine an# positions nu'bering begins )ro' 0. ,ee the
%et!os 'etho#.
function %et!os: T!oint;
Returns the current cursor position. ,ee Set!os.
procedure Sho#)essage*s: String-;
,ho+s a 'essage in the )ooter.
procedure .ndo;
Cance!s the !ast change.
function $ind*Text: String-: boolean;
,earches a te"t )ro' a current cursor position.
function ,sBoo&mar&*Line : integer-: integer;
Return the boo&'ar& nu'ber )or the !ine +ith the Line nu'ber. Returns -1 i) the
boo&'ar& is not set. ,ee 'ddBoo&mar& 'etho#.
procedure 'ddBoo&mar&*Line+ /umber : integer-;
A##s the boo&'ar& nu'ber )or the !ine Line +ith the nu'ber /umber. ,upports 10
boo&'ar&s +ith nu'bers )ro' 0 to 9. ,ee 0eleteBoo&mar&+ %otoBoo&mar& 'etho#s.
procedure 0eleteBoo&mar&*/umber : integer-;
2e!etes the boo&'ar& +ith the nu'ber /umber. ,ee 'ddBoo&mar& 'etho#.
procedure %otoBoo&mar&*/umber : integer-;
,ets the cursor position to the !ine +ith the boo&'ar& +ith the nu'ber /umber. ,ee
'ddBoo&mar& 'etho#.
procedure Set'cti1eLine*Line : ,nteger-;
,ets the acti<e !ine high!ighting ()or use +ith the #ebugger). Line is the acti<e !ine
nu'ber. $he high!ighting is #isab!e# i) Line is set to -1. ,ee the %et'cti1eLine 'etho#.
function %et'cti1eLine: ,nteger;
Returns the acti<e !ine nu'ber. I) there is no acti<e !ines it returns -1. ,ee Set'cti1eLine
'etho#.
Hot keys.
(ey 'ction
Cursor arro+ Cursor 'o<ing
0g:p5 0g2n5 0age :p * 0age 2o+n
Ctr!60g:p ?o<e to the begin o) te"t
Ctr!60g2n ?o<e to the en# o) te"t
@o'e ?o<e to the begin o) !ine
En# ?o<e to the en# o) !ine
Enter ?o<e to the ne"t !ine
2e!ete 2e!ete sy'bo! at right or se!ecte# te"t
1ac&space 2e!ete sy'bo! at !e)t
Ctr!6F 2e!ete current !ine
Ctr!6U :n#o !ast change
,hi)t6SVWXYZ[ Z\W]^W_ ,e!ect the te"t b!oc&
Ctr!6A ,e!ect a!! te"t
Ctr!6: :nin#ent se!ecte# b!oc&
Ctr!6I In#ent se!ecte# b!oc&
Ctr!6C5 Ctr!6Insert Copy to c!ipboar#
Ctr!6N5 ,hi)t6Insert 0aste )ro' c!ipboar#
Ctr!6G5 ,hi)t62e!ete Cut to c!ipboar#
Ctr!6,hi)t6`a[bW_c ,et boo&'ar&
Ctr!6`a[bW_c Doto boo&'ar&
Ctr!6F ,earch te"t
F9 Continue search
TfsTree classes and functions treevie#
,ho+s a<ai!ab!e c!asses an# )unctions in a tree.
"t#s a $bon%s$ component an& is not s%pporte& at present time.
Properties:
property Script: TfsScript;
$)s,cript re)erence.
property Syntax)emo: TfsSyntax)emo; for 2CL
property Syntax)emo: T)emo; for CL3
?e'o re)erence.
property Sho#Classes: Boolean;
$he )unction tree is sho+n.
property Sho#$unctions: Boolean;
A!! the tree no#es are sho+n .
property Expanded: Boolean;
E"pan# a!! tree no#es.
property ExpandLe1el: integer;
$he !e<e! o) the un)o!#e# tree no#es. 2 by #e)au!t.
TfsClasses$TT% component
:se this co'ponent i) you +ant to get access to C!asses.pas stu)) in your app!ication.
$his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TObject
constructor TObject.Cre"te
procedure TObject.Free
T.ersistent
procedure T.ersistent.6ssin(Source: T.ersistent)
T&ist
!unction T&ist.6dd(Item: TObject): Inteer
procedure T&ist.Cle"r
procedure T&ist.9elete(Inde': Inteer)
!unction T&ist.Inde'O!(Item: TObject): Inteer
procedure T&ist.Insert(Inde': Inteer; Item: TObject)
!unction T&ist.5emoMe(Item: TObject): Inteer
propert% T&ist.Count
propert% T&ist.Items
TStrins
!unction TStrins.6dd(const S: strin): Inteer
!unction TStrins.6ddObject(const S: strin; 6Object: TObject): Inteer
procedure TStrins.Cle"r
procedure TStrins.9elete(Inde': Inteer)
!unction TStrins.Inde'O!(const S: strin): Inteer
!unction TStrins.Inde'O!;"me(const ;"me: strin): Inteer
!unction TStrins.Inde'O!Object(6Object: TObject): Inteer
procedure TStrins.Insert(Inde': Inteer; const S: strin)
procedure TStrins.InsertObject(Inde': Inteer; const S: strin;
6Object: TObject)
procedure TStrins.&o"dFromFile(const File;"me: strin)
procedure TStrins.&o"dFromStre"m(Stre"m: TStre"m)
procedure TStrins.S"MeToFile(const File;"me: strin)
procedure TStrins.S"MeToStre"m(Stre"m: TStre"m)
propert% TStrins.Comm"Te't
propert% TStrins.Count
propert% TStrins.;"mes
propert% TStrins.Objects
propert% TStrins.:"lues
propert% TStrins.Strins
propert% TStrins.Te't
TStrin&ist
!unction TStrin&ist.Find(s: Strin; M"r Inde': Inteer): Boole"n
procedure TStrin&ist.Sort
propert% TStrin&ist.9uplic"tes
propert% TStrin&ist.Sorted
TStre"m
!unction TStre"m.5e"d(Bu!!er: strin; Count: &onint): &onint
!unction TStre"m.Drite(Bu!!er: strin; Count: &onint): &onint
!unction TStre"m.Seek(O!!set: &onint; Oriin: Dord): &onint
!unction TStre"m.Cop%From(Source: TStre"m; Count: &onint): &onint
propert% TStre"m..osition
propert% TStre"m.SiWe
TFileStre"m
constructor TFileStre"m.Cre"te(Filen"me: Strin; +ode: Dord)
T+emor%Stre"m
procedure T+emor%Stre"m.Cle"r
procedure T+emor%Stre"m.&o"dFromStre"m(Stre"m: TStre"m)
procedure T+emor%Stre"m.&o"dFromFile(Filen"me: Strin)
procedure T+emor%Stre"m.S"MeToStre"m(Stre"m: TStre"m)
procedure T+emor%Stre"m.S"MeToFile(Filen"me: Strin)
TComponent
constructor TComponent.Cre"te(6O*ner: TComponent)
propert% TComponent.O*ner
T!s?+&Item
constructor T!s?+&Item.Cre"te
procedure T!s?+&Item.6ddItem(Item: T!s?+&Item)
procedure T!s?+&Item.Cle"r
procedure T!s?+&Item.InsertItem(Inde': Inteer; Item: T!s?+&Item)
!unction T!s?+&Item.6dd: T!s?+&Item
!unction T!s?+&Item.Find(const ;"me: Strin): Inteer
!unction T!s?+&Item.FindItem(const ;"me: Strin): T!s?+&Item
!unction T!s?+&Item..rop(const ;"me: Strin): Strin
!unction T!s?+&Item.5oot: T!s?+&Item
propert% T!s?+&Item.9"t"
propert% T!s?+&Item.Count
propert% T!s?+&Item.Items
propert% T!s?+&Item.;"me
propert% T!s?+&Item.."rent
propert% T!s?+&Item.Te't
T!s?+&9ocument
constructor T!s?+&9ocument.Cre"te
procedure T!s?+&9ocument.S"MeToStre"m(Stre"m: TStre"m)
procedure T!s?+&9ocument.&o"dFromStre"m(Stre"m: TStre"m)
procedure T!s?+&9ocument.S"MeToFile(const File;"me: Strin)
procedure T!s?+&9ocument.&o"dFromFile(const File;"me: Strin)
propert% T!s?+&9ocument.5oot
const !mCre"te
const !mOpen5e"d
const !mOpenDrite
const !mOpen5e"dDrite
const !mS$"re1'clusiMe
const !mS$"re9en%Drite
const !mS$"re9en%;one
const soFromBeinnin
const soFromCurrent
const soFrom1nd
t%pe T9uplic"tes
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,PiC!assesR$$IJ unit to the JusesJ c!ause.
Tfs&raphics$TT% component
:se this co'ponent i) you +ant to get an access to Draphics.pas stu)) in your
app!ication. $his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TFont
T.en
TBrus$
TC"nM"s
procedure TC"nM"s.9r"*(?8 <: Inteer; /r"p$ic: T/r"p$ic)
procedure TC"nM"s.1llipse(?18 <18 ?L8 <L: Inteer)
procedure TC"nM"s.&ineTo(?8 <: Inteer)
procedure TC"nM"s.+oMeTo(?8 <: Inteer)
procedure TC"nM"s.5ect"nle(?18 <18 ?L8 <L: Inteer)
procedure TC"nM"s.5ound5ect(?18 <18 ?L8 <L8 ?N8 <N: Inteer)
procedure TC"nM"s.Stretc$9r"*(?18 <18 ?L8 <L: Inteer; /r"p$ic:
T/r"p$ic)
!unction TC"nM"s.Te't,ei$t(const Te't: strin): Inteer
procedure TC"nM"s.Te'tOut(?8 <: Inteer; const Te't: strin)
!unction TC"nM"s.Te'tDidt$(const Te't: strin): Inteer
propert% TC"nM"s..i'els
T/r"p$ic
procedure T/r"p$ic.&o"dFromFile(const Filen"me: strin)
procedure T/r"p$ic.S"MeToFile(const Filen"me: strin)
propert% T/r"p$ic.,ei$t
propert% T/r"p$ic.Didt$
T+et"!ile
T+et"!ileC"nM"s
TBitm"p
propert% TBitm"p.C"nM"s
t%pe TFontSt%les
t%pe TFont.itc$
t%pe T.enSt%le
t%pe T.en+ode
t%pe TBrus$St%le
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,PiDraphicsR$$IJ unit to the JusesJ c!ause.
TfsForms$TT% component
:se this co'ponent i) you +ant to get an access to ,t#Ctr!s.pas an# For's.pas stu)) in
your app!ication. $his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a
script
TControl
propert% TControl.."rent
procedure TControl.,ide
procedure TControl.S$o*
procedure TControl.SetBounds(6&e!t8 6Top8 6Didt$8 6,ei$t: Inteer)
eMent TControl.OnC"n5esiWe
eMent TControl.OnClick
eMent TControl.On9blClick
eMent TControl.On+ouse9o*n
eMent TControl.On+ouse+oMe
eMent TControl.On+ouse0p
eMent TControl.On5esiWe
TDinControl
procedure TDinControl.SetFocus
eMent TDinControl.On1nter
eMent TDinControl.On1'it
eMent TDinControl.OnCe%9o*n
eMent TDinControl.OnCe%.ress
eMent TDinControl.OnCe%0p
TCustomControl
T/r"p$icControl
T/roupBo'
T&"bel
T1dit
T+emo
TCustomComboBo'
propert% TCustomComboBo'.9ropped9o*n
propert% TCustomComboBo'.ItemInde'
TComboBo'
TButton
TC$eckBo'
T5"dioButton
TCustom&istBo'
propert% TCustom&istBo'.ItemInde'
propert% TCustom&istBo'.SelCount
propert% TCustom&istBo'.Selected
T&istBo'
TControlScrollB"r
TScrollinDinControl
TScrollBo'
TCustomForm
procedure TCustomForm.Close
procedure TCustomForm.,ide
procedure TCustomForm.S$o*
!unction TCustomForm.S$o*+od"l: Inteer
eMent TCustomForm.On6ctiM"te
eMent TCustomForm.OnClose
eMent TCustomForm.OnCloseXuer%
eMent TCustomForm.OnCre"te
eMent TCustomForm.On9estro%
eMent TCustomForm.On9e"ctiM"te
eMent TCustomForm.On,ide
eMent TCustomForm.On."int
eMent TCustomForm.OnS$o*
propert% TCustomForm.+od"l5esult
TForm
t%pe T+od"l5esult
t%pe TCursor
t%pe TS$i!tSt"te
t%pe T6linment
t%pe T6lin
t%pe T+ouseButton
t%pe T6nc$ors
t%pe TBeMelCut
t%pe TTe't&"%out
t%pe T1ditC$"rC"se
t%pe TScrollSt%le
t%pe TComboBo'St%le
t%pe TC$eckBo'St"te
t%pe T&istBo'St%le
t%pe TFormBorderSt%le
t%pe TDindo*St"te
t%pe TFormSt%le
t%pe TBorderIcons
t%pe T.osition
t%pe TClose6ction
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,PiFor'sR$$IJ unit to the JusesJ c!ause.
TfsE!tCtrls$TT% component
:se this co'ponent i) you +ant to get an access to E"tCtr!s.pas stu)) in your
app!ication. $his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TS$"pe
T."intBo'
eMent T."intBo'.On."int
TIm"e
TBeMel
TTimer
eMent TTimer.OnTimer
T."nel
TSplitter
TBitBtn
TSpeedButton
TC$eck&istBo'
propert% TC$eck&istBo'.C$ecked
TT"bControl
TT"bS$eet
T."eControl
procedure T."eControl.Select;e't."e(/oFor*"rd: Boole"n)
propert% T."eControl.."eCount
propert% T."eControl.."es
TSt"tus."nel
TSt"tus."nels
!unction TSt"tus."nels.6dd: TSt"tus."nel
propert% TSt"tus."nels.Items
TSt"tusB"r
TTree;ode
procedure TTree;ode.9elete
!unction TTree;ode.1ditTe't: Boole"n
propert% TTree;ode.Count
propert% TTree;ode.9"t"
propert% TTree;ode.Im"eInde'
propert% TTree;ode.SelectedInde'
propert% TTree;ode.St"teInde'
propert% TTree;ode.Te't
TTree;odes
!unction TTree;odes.6dd(;ode: TTree;ode; const S: strin): TTree;ode
!unction TTree;odes.6ddC$ild(;ode: TTree;ode; const S: strin):
TTree;ode
procedure TTree;odes.Bein0pd"te
procedure TTree;odes.Cle"r
procedure TTree;odes.9elete(;ode: TTree;ode)
procedure TTree;odes.1nd0pd"te
propert% TTree;odes.Count
propert% TTree;odes.Item
TTree:ie*
procedure TTree:ie*.FullColl"pse
procedure TTree:ie*.Full1'p"nd
propert% TTree:ie*.Selected
propert% TTree:ie*.TopItem
TTr"ckB"r
T.roressB"r
T&istColumn
T&istColumns
!unction T&istColumns.6dd: T&istColumn
propert% T&istColumns.Items
T&istItem
procedure T&istItem.9elete
!unction T&istItem.1ditC"ption: Boole"n
propert% T&istItem.C"ption
propert% T&istItem.C$ecked
propert% T&istItem.9"t"
propert% T&istItem.Im"eInde'
propert% T&istItem.Selected
propert% T&istItem.St"teInde'
propert% T&istItem.SubItems
T&istItems
!unction T&istItems.6dd: T&istItem
procedure T&istItems.Bein0pd"te
procedure T&istItems.Cle"r
procedure T&istItems.9elete(Inde': Inteer)
procedure T&istItems.1nd0pd"te
propert% T&istItems.Count
propert% T&istItems.Item
TIconOptions
T&ist:ie*
TToolButton
TToolB"r
T+ont$C"lColors
T9"teTime.icker
T+ont$C"lend"r
t%pe TS$"peT%pe
t%pe TBeMelSt%le
t%pe TBeMelS$"pe
t%pe T5esiWeSt%le
t%pe TButton&"%out
t%pe TButtonSt"te
t%pe TButtonSt%le
t%pe TBitBtnCind
t%pe T;um/l%p$s
t%pe TT"b.osition
t%pe TT"bSt%le
t%pe TSt"tus."nelSt%le
t%pe TSt"tus."nelBeMel
t%pe TSortT%pe
t%pe TTr"ckB"rOrient"tion
t%pe TTick+"rk
t%pe TTickSt%le
t%pe T.roressB"rOrient"tion
t%pe TIcon6rr"nement
t%pe T&ist6rr"nement
t%pe T:ie*St%le
t%pe TToolButtonSt%le
t%pe T9"teTimeCind
t%pe T9T9"te+ode
t%pe T9T9"teForm"t
t%pe T9TC"l6linment
t%pe TC"l9"%O!Deek
Fou get an access to a!! the pub!ishe# properties o) these c!asses an# the access to so'e
pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,PiE"tCtr!sR$$IJ unit to the JusesJ c!ause.
TfsDialogs$TT% component
:se this co'ponent i) you +ant to get an access to 2ia!ogs.pas stu)) in your
app!ication. $his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TCommon9i"lo
!unction TCommon9i"lo.1'ecute: Boole"n
TOpen9i"lo
TS"Me9i"lo
TColor9i"lo
TFont9i"lo
T.rint9i"lo
T.rinterSetup9i"lo
t%pe TOpenOptions
t%pe TFile1ditSt%le
t%pe TColor9i"loOptions
t%pe TFont9i"loOptions
t%pe TFont9i"lo9eMice
t%pe T.rint5"ne
t%pe T.rint9i"loOptions
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,Pi2ia!ogsR$$IJ unit to the JusesJ c!ause.
TfsD'$TT% component
:se this co'ponent i) you +ant to get an access to 21.pas stu)) in your app!ication.
$his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TField
propert% TField.6sBoole"n
propert% TField.6sCurrenc%
propert% TField.6s9"teTime
propert% TField.6sFlo"t
propert% TField.6sInteer
propert% TField.6s9"te
propert% TField.6sTime
propert% TField.6sStrin
propert% TField.6s:"ri"nt
propert% TField.9"t"T%pe
propert% TField.9ispl"%;"me
propert% TField.9ispl"%Te't
propert% TField.Is;ull
propert% TField.SiWe
propert% TField.:"lue
TFields
propert% TFields.Fields
TStrinField
T;umericField
TInteerField
TSm"llIntField
TDordField
T6utoIncField
TFlo"tField
TCurrenc%Field
TBoole"nField
T9"teTimeField
T9"teField
TTimeField
TBin"r%Field
TB%tesField
T:"rB%tesField
TBC9Field
TBlobField
procedure TBlobField.&o"dFromFile(const File;"me: Strin)
procedure TBlobField.&o"dFromStre"m(Stre"m: TStre"m)
procedure TBlobField.S"MeToFile(const File;"me: Strin)
procedure TBlobField.S"MeToStre"m(Stre"m: TStre"m)
T+emoField
T/r"p$icField
TField9e!
TField9e!s
propert% TField9e!s.Items
T9"t"Source
t%pe TBookm"rk
T9"t"Set
procedure T9"t"Set.Open
procedure T9"t"Set.Close
procedure T9"t"Set.First
procedure T9"t"Set.&"st
procedure T9"t"Set.;e't
procedure T9"t"Set..rior
procedure T9"t"Set.C"ncel
procedure T9"t"Set.9elete
procedure T9"t"Set..ost
procedure T9"t"Set.6ppend
procedure T9"t"Set.Insert
procedure T9"t"Set.1dit
!unction T9"t"Set.FieldB%;"me(const Field;"me: strin): TField
procedure T9"t"Set./etField;"mes(&ist: TStrins)
!unction T9"t"Set.FindFirst: Boole"n
!unction T9"t"Set.Find&"st: Boole"n
!unction T9"t"Set.Find;e't: Boole"n
!unction T9"t"Set.Find.rior: Boole"n
procedure T9"t"Set.FreeBookm"rk(Bookm"rk: TBookm"rk)
!unction T9"t"Set./etBookm"rk: TBookm"rk
procedure T9"t"Set./otoBookm"rk(Bookm"rk: TBookm"rk)
!unction T9"t"Set.&oc"te(const Ce%Fields: strin; const Ce%:"lues:
:"ri"nt; Options: T&oc"teOptions): Boole"n
!unction T9"t"Set.Is1mpt%: Boole"n
propert% T9"t"Set.Bo!
propert% T9"t"Set.1o!
propert% T9"t"Set.FieldCount
propert% T9"t"Set.Field9e!s
propert% T9"t"Set.Fields
propert% T9"t"Set.Filter
propert% T9"t"Set.Filtered
propert% T9"t"Set.FilterOptions
propert% T9"t"Set.6ctiMe
T."r"m
procedure T."r"m.Cle"r
propert% T."r"m.Bound
propert% T."r"m.Is;ull
propert% T."r"m.Te't
propert% T."r"m.6sBoole"n
propert% T."r"m.6sCurrenc%
propert% T."r"m.6s9"teTime
propert% T."r"m.6sFlo"t
propert% T."r"m.6sInteer
propert% T."r"m.6s9"te
propert% T."r"m.6sTime
propert% T."r"m.6sStrin
propert% T."r"m.6s:"ri"nt
T."r"ms
!unction T."r"ms.."r"mB%;"me(const :"lue: strin): T."r"m
!unction T."r"ms.Find."r"m(const :"lue: strin): T."r"m
propert% T."r"ms.Items
t%pe TFieldT%pe
t%pe TBlobStre"m+ode
t%pe T&oc"teOptions
t%pe TFilterOptions
t%pe T."r"mT%pe
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,Pi21R$$IJ unit to the JusesJ c!ause.
TfsD'Ctrls$TT% component

:se this co'ponent i) you +ant to get an access to 21Ctr!s.pas stu)) in your
app!ication. $his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
T9B1dit
T9BTe't
T9BC$eckBo'
propert% T9BC$eckBo'.C$ecked
T9BComboBo'
propert% T9BComboBo'.Te't
T9B&istBo'
T9B5"dio/roup
propert% T9B5"dio/roup.ItemInde'
propert% T9B5"dio/roup.:"lue
T9B+emo
T9BIm"e
T9B;"Mi"tor
T9B&ookupControl
propert% T9B&ookupControl.Ce%:"lue
T9B&ookup&istBo'
propert% T9B&ookup&istBo'.SelectedItem
T9B&ookupComboBo'
propert% T9B&ookupComboBo'.Te't
TColumnTitle
TColumn
T9B/ridColumns
!unction T9B/ridColumns.6dd: TColumn
propert% T9B/ridColumns.Items
T9B/rid
t%pe TButtonSet
t%pe TColumnButtonSt%le
t%pe T9B/ridOptions
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,Pi21Ctr!sR$$IJ unit to the JusesJ c!ause.
Tfs'DE$TT% component
:se this co'ponent i) you +ant to get an access to 12E stu)) in your app!ication. $his
co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TSession
T9"t"b"se
TB919"t"Set
T9B9"t"Set
TT"ble
procedure TT"ble.Cre"teT"ble
procedure TT"ble.9eleteT"ble
procedure TT"ble.1mpt%T"ble
!unction TT"ble.FindCe%(const Ce%:"lues: "rr"%): Boole"n
procedure TT"ble.Find;e"rest(const Ce%:"lues: "rr"%)
procedure TT"ble.5en"meT"ble(const ;e*T"ble;"me: strin)
TXuer%
procedure TXuer%.1'ecSX&
!unction TXuer%.."r"mB%;"me(const :"lue: strin): T."r"m
procedure TXuer%..rep"re
propert% TXuer%.."r"mCount
TStored.roc
procedure TStored.roc.1'ec.roc
!unction TStored.roc.."r"mB%;"me(const :"lue: strin): T."r"m
procedure TStored.roc..rep"re
propert% TStored.roc.."r"mCount
t%pe TT"bleT%pe
t%pe T."r"mBind+ode
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,Pi12ER$$IJ unit to the JusesJ c!ause.
TfsAD($TT% component
:se this co'ponent i) you +ant to get an access to A2/ stu)) in your app!ication. $his
co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
T69OConnection
T."r"meter
T."r"meters
propert% T."r"meters.Items
TCustom69O9"t"Set
T69OT"ble
T69OXuer%
procedure T69OXuer%.1'ecSX&
T69OStored.roc
procedure T69OStored.roc.1'ec.roc
t%pe T9"t"T%pe
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,PiA2/R$$IJ unit to the JusesJ c!ause.
Tfs%')$TT% component
:se this co'ponent i) you +ant to get an access to I1G stu)) in your app!ication. $his
co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TIB9"t"B"se
TIBTr"ns"ction
TIBCustom9"t"Set
TIBT"ble
TIBXuer%
procedure TIBXuer%.1'ecSX&
TIBStored.roc
procedure TIBStored.roc.1'ec.roc
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,PiI1GR$$IJ unit to the JusesJ c!ause.
TfsChart$TT% component

:se this co'ponent i) you +ant to get an access to $eeChart stu)) in your app!ication.
$his co'ponent a!!o+s you to access the )o!!o+ing c!asses insi#e a script
TC$"rt:"lue&ist
TC$"rt6'isTitle
TC$"rt6'is
TCustomC$"rt&eend
TC$"rt&eend
TSeries+"rks
TC$"rt/r"dient
TC$"rtD"ll
TC$"rtBrus$
TC$"rtTitle
TC$"rtSeries
procedure TC$"rtSeries.Cle"r
procedure TC$"rtSeries.6dd(const 6:"lue: 9ouble; const 6&"bel: Strin;
6Color: TColor)
TSeries.ointer
TCustomSeries
T&ineSeries
T.ointSeries
T6re"Series
TCustomB"rSeries
TB"rSeries
T,oriWB"rSeries
TCircledSeries
T.ieSeries
TF"st&ineSeries
TCustomC$"rt
TC$"rt
t%pe TC$"rt:"lue
t%pe T&eendSt%le
t%pe T&eend6linment
t%pe T&eendTe'tSt%le
t%pe TC$"rt&istOrder
t%pe T/r"dient9irection
t%pe TSeries+"rksSt%le
t%pe T6'is&"belSt%le
t%pe T,oriW6'is
t%pe T:ert6'is
t%pe TTeeB"ckIm"e+ode
t%pe T."nnin+ode
t%pe TSeries.ointerSt%le
t%pe T+ulti6re"
t%pe T+ultiB"r
t%pe TB"rSt%le
Fou ha<e an access to a!! the pub!ishe# properties o) these c!asses an# an access to
so'e pub!ic properties an# 'etho#s.
Hote $his is a J)a&eJ co'ponent. It is nee#e# on!y )or auto'atic inc!usion o) the
JF,PiChartR$$IJ unit to the JusesJ c!ause.
Scripting
!he simplest e%ample of scripting
$etting the list of the supported languages
Displaying the detail info a)out the synta% error
De)ugging the the script
Adding a procedure to the script
Adding a function to the script
Adding a function *ith var and default
parameters
Adding a function *ith class parameters
Adding a function *hich returns value of class
type
Adding a constant to the script
Adding a varia)le to the script
Adding an o)+ect varia)le to the script
Adding a type to the script
Adding an enumeration to the script
Adding a set type to the script
Adding a class to the script
#mplementing pu)lic properties and methods of
the class
#mplementing the event handler
#mplementing nonstandard event handler
Accessing script varia)les from the Delphi code
Calling a script function from the Delphi code
Calling a script function *ith var parameters
Calculation of the e%pressions
Saving and loading of the precompiled code
Script tutorials
The simplest e!ample of scripting
@ere is a sa'p!e co#e +hich #e'onstrates the easiest +ay o) using Fast,cript. =ust put
the $)s,cript, $)s0asca! an# $1utton co'ponents onto your )or' an# +rite the )o!!o+ing
co#e in the button./nC!ic& e<ent,
procedure TForm1.Button1Click(Sender: TObject);
bein
!sScript1.Cle"r;
!sScript1.&ines.Te't :( )bein S$o*+ess"e()),ello-))) end.);
!sScript1.."rent :( !s/lob"l0nit;
!sScript1.S%nt"'T%pe :( )."sc"lScript);
i! not !sScript1.5un t$en
S$o*+ess"e(!sScript1.1rror+s);
end;
- C!ear the script. It is necessary i) you use one co'ponent to run 'any scripts.
- Fi!! the Bines property by the script co#eI
- $o use stan#ar# types an# )unctions pass the )sD!oba!:nit to the 0arent property.
- Run the script using the 0asca!,cript !anguage. I) co'pi!ation +as success)u!5 Run
'etho# returns $rue. /ther+ise an error 'essage is sho+n.
Another +ay to use $)s,cript +ithout )sD!oba!:nit ()or e"a'p!e5 in 'u!ti-threa#
en<iron'ent)
procedure TForm1.Button1Click(Sender: TObject);
bein
!sScript1.Cle"r;
!sScript1.6dd5TTI;
!sScript1.&ines.Te't :( )bein S$o*+ess"e()),ello-))) end.);
!sScript1.S%nt"'T%pe :( )."sc"lScript);
i! not !sScript1.5un t$en
S$o*+ess"e(!sScript1.1rror+s);
end;
&etting the list of the supported languages
$o get the !ist o) the supporte# !anguages ca!! the )sDetBanguageBist(!ist $,trings)
proce#ure5 #e)ine# in the F,Pi$oo!s unit.
uses FS_iTools;
!s/et&"nu"e&ist(&"nComboBo'.Items);
Displaying the detail info a*out the synta! error
uses FS_iInterpreter8 FS_iTools;
bein
i! not !sScript1.Compile t$en
bein
I s$o* t$e error mess"e "nd position in t$e st"tus b"r J
St"tusB"r1.Te't :( !sScript1.1rror+s > ) "t ) > !sScript1.1rror.os;
1'it;
end
else
!sScript1.1'ecute;
end;
De*ugging the script
:se /nRunBine. For e"a'p!e
procedure TForm1.On5un&ine(Sender: T!sScript; const 0nit;"me8 Source.os:
Strin);
M"r
pt: T.oint;
bein
## loc"te t$e unit *it$ 0nit;"me n"me
...
## loc"te t$e line *it$ pt.< number
pt :( !s.osTo.oint(Source.os);

FStopped :( True;
*$ile FStopped do
6pplic"tion..rocess+ess"es;
end;
E"a'ine the #e'o !ocate# in the 2E?/,O?ain )o!#er.
Adding a procedure to the script
$o a## a proce#ure*)unction to a script5 per)or' the )o!!o+ing steps
- Create a 'etho# han#!er - )unction o) the $)sCa!!?etho#E<ent type.
- Ca!! $)s,cript.A##?etho# 'etho#. $he )irst para'eter is a )unction synta"5 the secon#
is a !in& to the han#!er o) $)sCa!!?etho#E<ent type.
I t$e !unction itsel! J
procedure TForm1.9elp$iFunc(s: Strin; i: Inteer);
bein
S$o*+ess"e(s > )8 ) > IntToStr(i));
end;
I t$e met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss; const
+et$od;"me: Strin;
M"r ."r"ms: :"ri"nt): :"ri"nt;
bein
9elp$iFunc(."r"ms4T78 ."r"ms417);
end;
procedure TForm1.Button1Click(Sender: TObject);
bein
I cle"r "ll items J
!sScript1.Cle"r;
I script te't J
!sScript1.&ines :( +emo1.&ines;
I !r/lob"l0nit cont"ins st"nd"rd t%pes "nd !unctions J
!sScript1.."rent :( !s/lob"l0nit;
I m"ke 9elp$iFunc procedure Misible to " script J
!sScript1.6dd+et$od()procedure 9elp$iFunc(s: Strin; i: Inteer))8
C"ll+et$od);
I compile t$e script J
i! !sScript1.Compile t$en
!sScript1.1'ecute else I e'ecute i! compil"tion *"s succes!ull J
S$o*+ess"e(!sScript1.1rror+s); I s$o* "n error mess"e J
end;
I) you +ant to a## se<era! 'etho#s5 you can #o it using one 'etho# han#!er
.ro.6dd+et$od()procedure 9elp$iFunc(s: Strin; i: Inteer))8
C"ll+et$od);
.ro.6dd+et$od()procedure 9elp$iFuncL(s: Strin))8 C"ll+et$od);
I t$e met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss; const
+et$od;"me: Strin;
M"r ."r"ms: :"ri"nt): :"ri"nt;
bein
I disp"tc$ t$e met$od c"ll J
i! +et$od;"me ( )91&.,IF0;C) t$en
9elp$iFunc(."r"ms4T78 ."r"ms417)
else i! +et$od;"me ( )91&.,IF0;CL) t$en
9elp$iFuncL(."r"ms4T7);
end;
Adding a function to the script
$he sa'e as a##ing a proce#ure.
!sScript1.6dd+et$od()!unction 9elp$iFuncL(s: Strin): Boole"n)8
C"ll+et$od);
I t$e met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss; const
+et$od;"me: Strin;
M"r ."r"ms: :"ri"nt): :"ri"nt;
bein
5esult :( 9elp$iFunc(."r"ms4T7);
end;
Adding a function #ith var and default parameters
Fou #on>t nee# to care about #e)au!t para'eters - they are substitute# auto'atica!!y by
Fast,cript. Nar para'eters 'ust be han#!e# by you.
!sScript1.6dd+et$od()!unction 9elp$iFunc(M"r s: Strin; i: Inteer (
T): Boole"n)8 C"ll+et$od);
I t$e met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss; const
+et$od;"me: Strin;
M"r ."r"ms: :"ri"nt): :"ri"nt;
M"r
s: Strin;
bein
s :( ."r"ms4T7;
5esult :( 9elp$iFunc(s8 ."r"ms417);
."r"ms4T7 :( s;
end;
Adding a function #ith the class parameter
,ince a!! the para'eters are represente# as the Nariant array type5 you nee# to con<ert
the' to ob-ects.
.ro.6dd+et$od()procedure ,ideButton(Button: TButton))8 C"ll+et$od);
I t$e met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss; const
+et$od;"me: Strin;
M"r ."r"ms: :"ri"nt): :"ri"nt;
bein
TButton(Inteer(."r"ms4T7)).,ide;
end;
Adding a function #hich returns a value of the class type
,ince the <a!ues returne# by the 'etho# han#!er is the array o) theNariant type5 you
nee# to con<ert the resu!ts o) the$/b-ect type to the Nariant.
!sScript1.6dd+et$od()!unction +"inForm: TForm)8 C"ll+et$od);
I t$e met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss; const
+et$od;"me: Strin;
M"r ."r"ms: :"ri"nt): :"ri"nt;
bein
5esult :( Inteer(Form1);
end;
Adding a constant to the script
$o a## a constant to a script5 ca!! the $)s,cript.A##Const 'etho#. $he )irst para'eter
is the na'e o) the constant5 the secon# one is the type (it 'ust be one o) the stan#ar#
types)5 the thir# one is a <a!ue.
!sScript1.6ddConst()pi)8 )1'tended)8 N.1O1PQ);
Adding a varia*le to the script
$o a## a <ariab!e to a script5 ca!! the $)s,cript.A##Nariab!e 'etho#. It is si'i!ar to
A##Const 'etho#5 e"cept that )act that you can change the <a!ue o) a <ariab!e in a script.
Hote that the actua! 2e!phi <ariab!e is not change# a)ter the script e"ecution.
!sScript1.6dd:"ri"ble()i)8 )Inteer)8 i);
Adding an o*+ect to the script
$o a## an ob-ect to a script5 ca!! the $)s,cript.A##/b-ect 'etho#. $he )irst para'eter
is the na'e o) the ob-ect5 the secon# one is the ob-ect itse!).
!sScript1.6ddObject()Button1)8 Button1);
I) ob-ect has an unregistere# type5 you ha<e to register it be)ore ca!!ing A##/b-ect
!sScript1.6ddCl"ss(TForm18 )TForm));
!sScript1.6ddObject()Form1)8 Form1);
Fou can a!so use )sD!oba!:nit.A##For' 'etho# to a## a )or' or #ata'o#u!e +ith a!!
its chi!# co'ponents
!s/lob"l0nit.6ddForm(Form1);
In this case you #on>t nee# to register the )or' c!ass by A##C!ass 'etho#. Ho+ you can
access a )or' e!e'ent in the script
Form1.Button1.C"ption :( )...)
Adding a type to the script
$o a## the o+n type to a script5 ca!! the $)s,cript.A##$ype 'etho#. $he )irst
para'eter is the na'e o) the type5 the secon# one is the one o) the supporte# types
T!s:"rT%pe ( (!MtInt8 !MtBool8 !MtFlo"t8 !MtC$"r8 !MtStrin8 !MtCl"ss8
!Mt6rr"%8 !Mt:"ri"nt8 !Mt1num);
!sScript1.6ddT%pe()TCursor)8 !MtInt);
Adding an enumeration to the script
$o a## an enu'eration type to the script5 ca!! the $)s,cript.A##Enu' 'etho#. $he )irst
para'eter is the na'e o) the type5 the secon# one is the type <a!ues separate# by
co''as.
!sScript1.6dd1num()T.rinterOrient"tion)8 )po.ortr"it8 po&"ndsc"pe));
Adding a set to the script
$o a## a set type to a script5 ca!! the $)s,cript.A##Enu',et 'etho#. $he )irst
para'eter is the na'e o) the type5 the secon# one is the type <a!ues separate# by
co''as.
!sScript1.6dd1numSet()TFontSt%les)8 )!sBold8 !sIt"lic8 !s0nderline8
!sStrikeOut));
Adding a class to the script
$o a## a c!ass to a script5 ca!! the $)s,cript.A##C!ass 'etho#. $he )irst para'eter is
the c!ass type5 the secon# one is the na'e o) the parent c!ass.
t%pe
T+%Cl"ss ( cl"ss(TObject)
...
end;
!sScript1.6ddCl"ss(T+%Cl"ss8 )TObject));
$his +i!! 'a&e a!! the pub!ishe# properies o) this c!ass a<ai!ab!e. I) you +ant to 'a&e
this c!ass a<ai!ab!e )or a!! the scripts5 it is reco''en#e# to a## this c!ass to the
)sD!oba!:nit +hich is a g!oba! ancestor o) a!! the scripts.
%mplementing pu*lic properties and methods of the class
$he A##C!ass 'etho# auto'atica!!y a##s a!! the pub!ishe# properties o) the c!ass.
0ub!ic properties an# 'etho#s re;uire an e"tra +or&. $he )o!!o+ing e"a'p!e sho+s ho+
to a## a pub!ic 'etho# to a c!ass. Fou nee# to create the 'etho# han#!er ()unction o) type
$)sCa!!?etho#).
bein
...
I "dd ne* cl"ss in$erited !rom TObject J
*it$ !sScript1.6ddCl"ss(T&ist8 )TObject)) do
bein
I "dd public met$ods J
6dd+et$od()!unction 6dd(Item: TObject): Inteer)8 C"ll+et$od);
6dd+et$od()procedure Cle"r)8 C"ll+et$od);
end;
...
end;
I met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss;
const +et$od;"me: Strin; M"r ."r"ms: :"ri"nt): :"ri"nt;
bein
5esult :( T;
i! +et$od;"me ( )699) t$en
I conMert :"ri"nt p"r"meter to .ointer t%pe "nd p"ss it to 6dd
met$od J
T&ist(Inst"nce).6dd(.ointer(Inteer(."r"ms4T7)))
else i! +et$od;"me ( )C&165) t$en
T&ist(Inst"nce).Cle"r
end;
$o i'p!e'ent a property you nee# to create a 'etho# han#!er an# t+o types property
han#!ers $)sDetNa!ueE<ent an# $)s,etNa!ueE<ent
T!s/et:"lue1Ment ( !unction(Inst"nce: TObject; Cl"ssT%pe: TCl"ss;
const .rop;"me: Strin): :"ri"nt o! object;
T!sSet:"lue1Ment ( procedure(Inst"nce: TObject; Cl"ssT%pe: TCl"ss;
const .rop;"me: Strin; :"lue: :"ri"nt) o! object;
In#e"e# an# #e)au!t properties are #escribe# by the 'etho# han#!er5 the or#inary
properties are han#!e# by the Det*,et property han#!ers.
bein
...
*it$ !sScript1.6ddCl"ss(TStrins8 )T.ersistent)) do
bein
I propert% Comm"Te't: Strin J
6dd.ropert%()Comm"Te't)8 )strin)8 /et.rop8 Set.rop);
I propert% Count: Inteer re"donl%8 second $"ndler is nil J
6dd.ropert%()Count)8 )Inteer)8 /et.rop8 nil);
I inde' propert% Objects4Inde': Inteer7: TObject J
6ddInde'.ropert%()Objects)8 )Inteer)8 )TObject)8 C"ll+et$od);
I de!"ult propert% Strins4Inde': Inteer7: Strin J
6dd9e!"ult.ropert%()Strins)8 )Inteer)8 )strin)8 C"ll+et$od);
end;
...
end;
I met$od $"ndler J
!unction TForm1.C"ll+et$od(Inst"nce: TObject; Cl"ssT%pe: TCl"ss;
const +et$od;"me: Strin; M"r ."r"ms: :"ri"nt): :"ri"nt;
bein
5esult :( T;
i! +et$od;"me ( )OBS1CTS./1T) t$en
5esult :( Inteer(TStrins(Inst"nce).Objects4."r"ms4T77)
else i! +et$od;"me ( )OBS1CTS.S1T) t$en
TStrins(Inst"nce).Objects4."r"ms4T77 :( TObject(Inteer(."r"ms417))
else i! +et$od;"me ( )ST5I;/S./1T) t$en
5esult :( TStrins(Inst"nce).Strins4."r"ms4T77
else i! +et$od;"me ( )ST5I;/S.S1T) t$en
TStrins(Inst"nce).Strins4."r"ms4T77 :( ."r"ms417
end;
I propert% $"ndler J
!unction TForm1./et.rop(Inst"nce: TObject; Cl"ssT%pe: TCl"ss;
const .rop;"me: Strin): :"ri"nt;
bein
5esult :( T;
i! .rop;"me ( )CO++6T1?T) t$en
5esult :( TStrins(Inst"nce).Comm"Te't
else i! .rop;"me ( )CO0;T) t$en
5esult :( TStrins(Inst"nce).Count
end;
I propert% $"ndler J
procedure TForm1.Set.rop(Inst"nce: TObject; Cl"ssT%pe: TCl"ss;
const .rop;"me: Strin; :"lue: :"ri"nt);
bein
i! .rop;"me ( )CO++6T1?T) t$en
TStrins(Inst"nce).Comm"Te't :( :"lue
end;
%mplementing the event handler
$o a## an e<ent to the c!ass5 use the $)sC!assNariab!e.A##E<ent 'etho#. $he )irst
para'eter is the e<ent na'e5 the secon# one is the e<ent han#!er.
*it$ !sScript1.6ddCl"ss(TControl8 )TComponent)) do
6dd1Ment()OnClick)8 T!s;oti!%1Ment);
$here are so'e pre#e)ine# e<ent han#!ers a<ai!ab!e in the F,PiE<ents unit
T!s;oti!%1Ment
T!s+ouse1Ment
T!s+ouse+oMe1Ment
T!sCe%1Ment
T!sCe%.ress1Ment
T!sClose1Ment
T!sCloseXuer%1Ment
T!sC"n5esiWe1Ment
,ee the the J$)sFor'sR$$$I co'ponentJ5 J$)sE"tCtr!sR$$I co'ponentJ an#
J$)s21Ctr!sR$$I co'ponentJ chapters )or the !ist o) e<ents a<ai!ab!e in script.
%mplementing nonstandard event handler
$here are so'e pre#e)ine# e<ent han#!ers a<ai!ab!e in F,PiE<ents unit
T!s;oti!%1Ment
T!s+ouse1Ment
T!s+ouse+oMe1Ment
T!sCe%1Ment
T!sCe%.ress1Ment
T!sClose1Ment
T!sCloseXuer%1Ment
T!sC"n5esiWe1Ment
@o+e<er5 i) you nee# to +rite your o+n e<ent han#!er ha<e a !oo& at the )o!!o+ing
e"a'p!e
I e'"mple o! t*o eMent $"ndlers J
t%pe
I "n"loue o! T;oti!%1Ment J
T!s;oti!%1Ment ( cl"ss(T!sCustom1Ment)
public
procedure 9o1Ment(Sender: TObject);
!unction /et+et$od: .ointer; oMerride;
end;
I "n"loue o! TCe%.ress1Ment ( procedure(Sender: TObject; M"r Ce%:
C$"r) J
T!sCe%.ress1Ment ( cl"ss(T!sCustom1Ment)
public
procedure 9o1Ment(Sender: TObject; M"r Ce%: C$"r);
!unction /et+et$od: .ointer; oMerride;
end;
I T!s;oti!%1Ment J
procedure T!s;oti!%1Ment.9o1Ment(Sender: TObject);
bein
I C"ll,"ndler is "n intern"l met$od J
C"ll,"ndler(4Sender7);
end;
!unction T!s;oti!%1Ment./et+et$od: .ointer;
bein
5esult :( AT!s;oti!%1Ment.9o1Ment;
end;
I T!sCe%.ress1Ment J
procedure T!sCe%.ress1Ment.9o1Ment(Sender: TObject; M"r Ce%: C$"r);
bein
C"ll,"ndler(4Sender8 Ce%7);
I et M"r p"r"meter J
Ce% :( Strin(,"ndler.."r"ms417.:"lue)417;
end;
!unction T!sCe%.ress1Ment./et+et$od: .ointer;
bein
5esult :( AT!sCe%.ress1Ment.9o1Ment;
end;
Accessing script varia*les from the Delphi code
$o get*set the <a!ue o) a script <ariab!es use $)s,cript.Nariab!es property.
M"l :( !sScript1.:"ri"bles4)i)7;
!sScript1.:"ri"bles4)i)7 :( 1T;
Calling a script function from the Delphi code
$o ca!! a script )unction5 use $)s,cript.Ca!!Function 'etho#. $he )irst para'eter is the
na'e o) the ca!!e# )unction5 the secon# one is the )unction para'eters.
## c"ll to )!unction ScriptFunc(s: Strin; i: Inteer))
M"l :( !sScript1.C"llFunction()ScriptFunc)8 :"r6rr"%O!(4)$ello)8 17));
Calling a script function #ith var parameters
$he sa'e as #escribe# abo<e. :se $)s,cript.Ca!!Function1 'etho# i) your
proce#ure*)unction accepts <ar para'eters
M"r
."r"ms: :"ri"nt;
."r"ms :( :"r6rr"%O!(4)$ello)8 17);
## c"ll to )!unction ScriptFunc(M"r s: Strin; i: Inteer))
!sScript1.C"llFunction1()ScriptFunc)8 ."r"ms);
S$o*+ess"e(."r"ms4T7);
Calculation of the e!pressions
I) you +ant to ca!cu!ate an e"pression ()or e"a'p!e5 >i61>)5 ca!! the $)s,cript.E<a!uate
'etho#.
S$o*+ess"e(!sScript1.1M"lu"te()i>1)));
It is use)u! )or #ebugging purposes.
Saving and loading of the precompiled code
,o'eti'es it is necessary to sa<e co'pi!ation resu!ts an# per)or' it !ater. Fou can #o it
+ith the he!p o) the $)s,cript.DetIBCo#e an# ,etIBCo#e 'etho#s.
$he be!o+ co#e co'pi!es the source script an# p!aces the preco'pi!e# resu!ts to the
strea'
M"r
s: TStre"m;
!sScript1.&ines.Te't :( ...;
!sScript1./etI&Code(s);
A)ter this5 you can restore the preco'pi!e# co#e )ro' the strea' an# per)or' it
!sScript1.SetI&Code(s);
!sScript1.1'ecute;
,sing -uses- directive
Fou can sp!it !arge script to 'o#u!es5 !i&e in /b-ect 0asca!
Fi!e unit1.pas
uses )unitL.p"s);
bein
0nitL.roc(),ello-));
end.
Fi!e unit2.pas
procedure 0nitL.roc(s: Strin);
bein
S$o*+ess"e(s);
end;
bein
S$o*+ess"e()initi"liW"tion o! unitL...));
end.
As you can see5 you shou!# +rite 'o#u!e na'e +ith )i!e e"tension in ;uotes. $he co#e
p!ace# in begin..en# o) the inc!u#e# 'o#u!e +i!! be e"ecute# +hen you run script (this is
ana!ogue o) initia!i%ation in the 0asca!).
In this e"a'p!e you cannot use unit1 )ro' +ithin unit2. $his +i!! cause circu!ar re)erence
an# in)inity !oop +hen co'pi!ing such script. ,uch re)erences are not a!!o+e# since
Fast,cript #oes not ha<e inter)ace*i'p!e'entation sections.
:sing d!anguage #irecti<e5 you can +rite 'u!ti-!anguage scripts. For e"a'p!e5 one
'o#u!e 'ay be +ritten in 0asca!,cript5 another one - using C66,cript
Fi!e unit1.pas
uses )unitL.p"s);
bein
0nitL.roc(),ello !rom ."sc"lScript-));
end.
Fi!e unit2.pas
El"nu"e C>>Script
Moid 0nitL.roc(strin s)
I
S$o*+ess"e(s);
J
I
S$o*+ess"e(RunitL initi"liW"tion8 C>>ScriptR);
J
$he d!anguage #irecti<e 'ust be the )irst !ine o) the )i!e. I) this #irecti<e e"ists it
o<erri#es $)s,cript.,ynta"$ype setting.
Script tutorials
,cript tutoria!s are !ocate# in the 2E?/,O?ainO,a'p!es )o!#er. Co'pi!e the #e'o
!ocate# in the 2E?/,O?ain )o!#er an# open the script sa'p!es in it.

You might also like