Command |
data
type |
Notes |
showmessage('hello
world'); |
|
displays
a standard dialog (with an ok button) and your message |
messagedlg('hello
world',messagetype, [buttons],1 ); |
word |
message
types include mtWarning, mtError, mtInformation, mtConfirmation;
buttons include mbYes, mbNo, mbOk, mbCancel, mbHelp, mbAbort, mbRetry,
mbIgnore; return types match the buttons and take the form mrYes,
mrNo and so on.
You can test what button was pressed:
if messagedlg('whaddyoureckon?',mtConfirmation, [mbYes,mbNo],1)
= mrYes
then {do something} |
inputbox
('title','prompt','default value') |
string |
Displays
a diaglog box on the screen with 'title' in ot's title bar, 'prompt'
above an edit box and 'default value' displayed inside the edit
box. Used to harvest a value from the user in a controlled
way. Usually used as part of an assignment statement like:
xstring := inputbox('Data Entry','Please enter a test score','0');
{to harvest a string value or}
x := strtoint(inputbox('Data Entry','Please enter a test score','0'));
{more risky if the user doesn't type a number} |
inttostr(x) |
string |
converts
a whole number (integer) into text - necessary if displaying integers
in labels, edit boxes and other text displays |
strtoint('42') |
integer |
converts
strings to integers - crashes if the conversion is not possible
|
strtointDef('42',-1) |
integer |
converts
the string to an integer IF POSSIBLE, if not, returns the default
numeric that is the second parameter (-1 in the supplied example)
|
floattostr(y) |
string |
converts
a floating point decimal number (real) into string |
strtofloat('4.5') |
real |
converts
a string into a real, crashing if not possible |
floattostrF(thing,
ffcurrency,7,2);
floattostrF(thing, fffixed,7,2);
|
string |
floattostrF:
the formatted conversion builtin function where
- thing:
the floating point variable being converted into currency display
- ffcurrency:
the builtin currency format (includes the decimal point and
a $ sign at the start of the number); fffixed lets you control
the decimal places without inserting a $
- fffixed
allows you to determine the number of decimal places without
also preceding the number with a $ sign
- 7:
a value indicating it is a single precision real currently
- 2:
the number of relevant decimal places
|
strtofloatdef(thing, defaultvalue); |
real |
converts the string to an real number IF POSSIBLE, if not, returns the default numeric that is the second parameter |
trunc(x) |
integer |
tears
the decimal off a real number leaving a whole number |
p
mod q |
integer |
delivers
the REMAINDER of the division (eg. 9 mod 7 = 2) |
p
div q |
integer |
returns
the whole answer to the division p/q (eg 9 div 7 = 1) |
ord(x) |
integer/byte |
turns
a character into it's corresponding ASCII number |
char(y) |
char |
converts
a number into the corresponding character from the ASCII table |
thing
as objecttype
eg: sender as TImage |
|
one
way of typecasting an unknown sender as a recognisable data
type (and therefore playing with it's properties) |
thing
is objecttype
if sender is TImage
then ... |
boolean |
a
way of testing the datatype of an unknown object - used in a test,
usually (an if..then) |
random(x) |
numeric |
used to create a random number (in
the range 0..x-1). Usually used in assignment statements like:
dice := random(6)+1 |
randomize |
|
used to 'seed' the random number generator
ensuring a different sequence of random digits each time the random
function is called |
PlaySound('file.wav',0,0) |
uses mmsystem |
plays the WAV file directly from your
project (as an excusive process) |
SndPlaySound('file.wav',snd_async); |
uses mmsystem |
plays the WAV file directly from your
project (with other processes active also) |
length(stringvariable) |
byte |
function returns the number of characters in the nominated string - a little like the expression ord(stringvariable[0]) |
pos(substring,superstring) |
byte |
returns the character position of the first character of the nominated substring in the superstring. Returns 0 if not found - important to test for this. |
delete(sourcestring, startingchar, numchars); |
string |
surgically removes a piece from a nominated sourcestring, starting at a nominated startingchar number, removing the nominated numchars. The sourcestring "heals" itsef around teh removal, becoming shorter. |
insert(substring, destinationstring, position); |
string |
surgically inserts the substring into the destinationstring at the mominated position - pushing all subsequent characters along to make room. |
WinExec('filename',SW_SHOWNORMAL); |
|
runs the named program - you need to include a path if the exe is not in the folder of the current applicaiton |
|
|
|
|
|
|
|
|
|