I know not a lot about database things so I'll be not much help.....
However...
If 1 = 1 then
Edit1.Text := '1 equals 1';
Edit1.Text := 'Gotcha!';
When you write an If statement in Pascal then it does the next statement until it hits a ; and then continues doing the following statements. So you would end up with a 'Gotcha!'.
If you wanted it to do a bunch of statements before continuing then you would write...
If 1 = 1 then
begin
Edit1.Text := '1 equals 1';
CookBaconSandwich(BrownBread,Medium,Rare);
NuclearLaunch := True;
end;
Edit1.Text := 'Gotcha!';
When you want your If, or other, statement to do lots of other stuff before moving on you enclose the other stuff with begin and end.
In my last shoddy example things would still continue to have Edit1.Text say 'Gotcha!'. Then you get to your else...
If 1 = 1 then
begin
Edit1.Text := 'Bacon Sandwich is Cooking, Armageddon to Follow ';
CookBaconSandwich(BrownBread,Medium,Rare);
NuclearLaunch(Red);
end
else
Edit1.Text := 'Stand Down From Red Alert';
HammerHamster(Head);
Which is still rather rubbish but the important bit is you do not put a ; at the end of the end that is before the else. The other thing is the else only deals with the bit up to the next ; and the Hamster still gets its head hammered....
If NuclearRequest() = 1 then
begin
Edit1.Text := 'Bacon Sandwich is Cooking, Armageddon to Follow ';
CookBaconSandwich(BrownBread,Medium,Rare);
NuclearLaunch(Red);
end
else
begin
Edit1.Text := 'Stand Down From Red Alert';
CookBaconSandwich(BrownBread,Medium,Burnt);
HammerHamster(Tail);
end;
This time sort of as before if you want the else to do a number of things before moving on then you enclose them with begin and end.
So.... then you want an else if but Pascal does not do ElseIf as such, coz thems is rubbish,.... It's the way, I guess, the compiler does its translation.
If NuclearRequest() = 1 then
begin
Edit1.Text := 'Bacon Sandwich is Cooking, Armageddon to Follow ';
CookBaconSandwich(BrownBread,Medium,Rare);
NuclearLaunch(Red);
end
else
If NuclearRequest() = 2 then
begin
Edit1.Text := 'Stand Down From Red Alert';
CookBaconSandwich(BrownBread,Medium,Burnt);
HammerHamster(Tail);
end
else
If NuclearRequest() = 3 then
begin
Edit1.Text := 'We're Going Down The Pub';
PhonePub(Guiness,3,Pints);
PhoneTaxi(HomeAddress,PubAddress);
HammerHamster(Feed);
end;
Mind you.... it looks like you have already worked it out.
Just to be boring Pascal does not do SelectCase like Basic does. Then again I am drunk person and old and whatever. I'll assume someone will slap me but in my above rubbish NuclearRequest() is a function call that returns a number. Case statements in Pascal deal with 'ordinals'....?
Case NuclearRequest() of
1: begin
Edit1.Text := 'Bacon Sandwich is Cooking, Armageddon Follows ';
CookBaconSandwich(BrownBread,Medium,Rare);
NuclearLaunch(Red);
end;
2: begin
Edit1.Text := 'Stand Down From Red Alert';
CookBaconSandwich(BrownBread,Medium,Burnt);
HammerHamster(Tail);
end;
3: begin
Edit1.Text := 'We're Going Down The Pub';
PhonePub(Guiness,3,Pints);
PhoneTaxi(HomeAddress,PubAddress);
HammerHamster(Feed);
end;
end; {case}
There you go, I do comments as well.
Keith