View Full Version : Pascal source problem
holocube
09-24-2003, 05:00 PM
can any1 tell me what ive written wrong in this source?
PROGRAM hehe;
VAR
NAME : String;
BEGIN
WRITE('Enter your name please: ');
READLN(NAME);
BEGIN
IF ',NAME,'='Tim' THEN
WRITELN('Why good evening sire, may i be the first to say how Incredibly dashing you do look tonight');
READLN;
END;
BEGIN
IF ',NAME,'='Seb' then WRITELN('Do make yourself at home bro, the dorritos are over there --->');
READLN;
END;
BEGIN
IF ',NAME,'='Fliss' then WRITELN('I am afraid you are not permitted, please leave now or you will be legally terminated');
READLN;
END;
END.
IF ',NAME,'='Tim' THEN
should be:
IF NAME = 'Tim' THEN
and you should place BEGIN after IF, not before it:
WRITE('Enter your name please: ');
READLN(NAME);
IF NAME = 'Tim' THEN
BEGIN
WRITELN('Why good evening sire, may i be the first to say how Incredibly dashing you do look tonight');
READLN;
END;
The same applies to the rest of IF statements.
holocube
09-28-2003, 04:54 PM
thx bro, 1 more thing, do u know how to tell it to repeat the program over and over and tell it to end the program when u type 'end' as the name? because i always get an abrupt end with this:
PROGRAM hehe;
VAR
NAME : String;
BEGIN {main}
BEGIN {1}
WRITE('Enter your name please (enter "end" to exit): ');
READLN(NAME);
WRITELN;
IF (NAME='Tim')OR(NAME='tim')OR(NAME='TIM') THEN
BEGIN
WRITELN('Why good evening sire, may i be the first to say how Incredibly dashing you do look tonight,');
WRITELN('I will send for your usual helping of hot girls immediately milord');
WRITELN;
WRITELN('PRESS ENTER');
READLN;
WRITELN;
END;
IF (NAME='seb')OR(NAME='Seb')OR(NAME='SEB')OR(NAME='woody')OR(NAME='Woody')OR(NAME='WOODY')
OR(NAME='dave')OR(NAME='Dave')OR(NAME='DAVE') THEN
BEGIN
WRITELN('Do make yourself at home bro, the dorritos are over there --->');
WRITELN;
WRITELN('PRESS ENTER');
READLN;
WRITELN;
END;
IF (NAME='fliss')OR(NAME='Fliss')OR(NAME='FLISS') THEN
BEGIN
WRITELN('I am afraid you are not permitted, please leave now or you will be legally terminated,');
WRITELN('under law section 937.732 of the criminal 2250 criminal code');
WRITELN;
WRITELN('PRESS ENTER');
READLN;
WRITELN;
END;
IF (NAME='end')OR(NAME='End')OR(NAME='END') THEN
BEGIN
END {main};
END;
END {1}.
READLN;
REPEAT {1}
one way to do it is to use a repeat/until loop, something like this:
repeat
{ code goes here }
until name = 'end';
HTH
holocube
09-30-2003, 12:38 PM
k, thx =)
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.