mardi 24 février 2015

Delphi 7 else if statement error?


Procedure Exchangerates;
var selection:integer;
answer,GBP,USD,EUR,JPY:string;

begin
Assignfile(ERfile, 'ER.dat');
reset (ERfile);
while not eof (erfile) do
begin
read (erfile, er) ;

writeln ('Which currency do you want to convert from, euros, pounds, dollars or yen');
readln (answer);

if answer='GBP'then
begin
writeln ('GBP');
writeln ('How many pounds to you want to convert to dollars?');
readln (selection);
writeln (selection*er.usdtopound:0:2);
writeln ('How many pounds do you want to convert to euros?');
readln (selection);
writeln (selection*er.eurotopound:0:2);
writeln ('How many pounds do you want to convert to yen?');
readln (selection);
writeln (selection*er.yentopound:0:2) ;
end;
else if answer = 'EUR' then
writeln ('hi');
end;
closefile(erfile);

end;


That is the procedure form program which needs to convert between currencies, when I try running the if statement I get an error, any reason why and how can I fix it? The error is [Error] Currencyconvertor3.dpr(75): ';' not allowed before 'ELSE' , and when I remove the semi colon I get 3 more errors


[Error] Currencyconvertor3.dpr(75): 'END' expected but 'ELSE' found


[Error] Currencyconvertor3.dpr(88): Declaration expected but identifier 'closefile' found


[Error] Currencyconvertor3.dpr(90): '.' expected but ';' found


Aucun commentaire:

Enregistrer un commentaire