DELPHI CODE Flashcards
ffcurrency
formats the value with the currency included
ffexponent
formats the value in scientific notain
fffixed
formats the value with the number of decimals as specified
string
address:=inputbox(‘address’,’enter the address’,’ ‘);
example using ffcurrency
redoutput.lines.add(‘final amount’+#9+floattostr(rfinalamount,ffsurrency,6,2));
ffgeneral
general number format. Includes decima;s oly when required
ffnumber
corresponds to fffixed , but uses thousands separator
integer
icount:= strtoint(iputbox(‘amount’,’enter the amount’,’ ‘);
real
rsales:=strtoint(inputbox(‘sales’, ‘please enter the sales figure’ ,’ ‘));
char
cclass:= inputbox(‘class’ , ‘ please enter the class ‘ , ‘ ‘)[1];
general structure of the if statement
if <conditions> then
begin</conditions>
<statements> ;
end
else
begin
<statements> ;
end;
</statements></statements>
case statement example
if imark>=80 then
csymbol:=’A’;
else
if imark>=70 then
csymbol:=’B’’;
else
if imark>=80 then
csymbol:=’A’;
the while loop
var
isum , inumber :integer;
begin
isum:= 0;
inumber:= 1;
while inumber <10 do
begin
isum:=isum +inumber ;
inumber := inumber +2 ;
end ;
redoutput.lines.add(inttostr(isum));
declaring an array
var
frmarray:tfrmarrays;
rrnumber:array[1..100] of integer;
icount: integer ;
load numbers from a textfile into an array
var
tf:textfile;
stemp: string ;
begin
icount := 0;
assignfile(tf, ‘numbers.txt’);
reset (tf);
while not eof(tf) do
begin icount:= icount+1 ;
readln (tf,stemp );
arrnumbers [icount]:= strtoint(stemp ) ; end ;
closefile (tf) ;
end ;