Advertisement

Anyone here know pascal?

Started by October 19, 2000 09:11 PM
22 comments, last by Tsu 24 years, 2 months ago
ok, for a school asignment i''m making a cheezy craps-type game (that doesnt have any graphics, but oh well), and of course, it has a main menu... since every other program in the world (maybe i''m over-exagerating a little) has a ''quit program'' function on the main menu, i decided that mine should too. this, and users would have to lose before they could ever quit the program... oh well. anyways, the textbook they gave the class is old and falling apart, and it doesn''t say anything about a command that exits a program... what i''m looking for, is a command that immediately and abruptly ends the current program and closes the window... thanks if you can help... -Tsu
Well, I''m not sure if such a command exists. Instead, you can set up your game loop and have it exit if a quit flag has been set.

I''ll try an example but unfortunately my Pascal knowledge comes from a sort of derivative (called Turing) so don''t mind if it''s really wrong (you should be able to get the gist of it at least).

var quit : int := 0;
var input : string (1);
while quit < 1 do
begin
if input = ''q'' then
quit := 1;
% Insert other game stuff here
end;
end;

I''m hoping I haven''t made a fool of myself with this attempt at Pascal code.

-Goku
Advertisement
hmm, isnt pascal a 16bit compiler? if so you could just call interrupt 21h

mov ax 4c00h
int 21h

whammo, well in pascal it''s somethin like

Procedure Exit();
Var
inregs:Registers;
Begin
inregs.ax:=4C00h;
intr($21,inregs);
End;

I think thats it anyhow...last time i used pascal was in 1994, whats wrong with your school man!!
With 5.5 I think they actually had an "EXIT" command or such. I think it may be "HALT" that immediatly quits the program. Try those and if that doesn''t work, then I will see what I can dig up from my help files

-Chris Bennett of Dwarfsoft - Site:"The Philosophers' Stone of Programming Alchemy" - IOL
The future of RPGs - Thanks to all the goblins over in our little Game Design Corner niche
          
There''s a special Unit you need to include - I think its in the same one the conio type stuff is in...

If it''s the main menu, its a loop watching for keyhits rights? what happens if you exit the loop? Shouldn''t that just end the program?

Loop
Until Keyhit=''q'';

I forget if its Exit or Halt as well
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Exit() terminates the current procedure, Halt() terminates your entire app. But it''s true that it''d be better to create a boolean flag that lets your loop terminate properly.

Tom Nuydens
Tom Nuydens delphi3d@gamedeveloper.org www.gamedeveloper.org/delphi3d
Advertisement
Well Now,

here is what I always used to use In Pascal:-

     BEGIN REPEAT   TEXTBACKGROUND(black);   CLRSCR;   TEXTCOLOR(white);   GOTOXY(2,1); WRITE(' Main Menu ');   GOTOXY(2,2); WRITE('===========');   GOTOXY(5,4); WRITE('  1. START The Game  ');   GOTOXY(5,5); WRITE('  2. VIEW Credits    ');   GOTOXY(5,6); WRITE('  3. EXIT Program    ');   GOTOXY(5,8); WRITE(' Please Enter Your Selection: ');  READLN(choice);  CASE choice OF    1:gamestart;     2:credits;    3:USERQUITS:=TRUE;  ELSE   TEXTCOLOR(red);   CLRSCR;   WRITELN; WRITELN; WRITELN; WRITELN; WRITELN; WRITELN; WRITELN;   WRITELN('                       INVALID SELECTION Please Try Again ');  DELAY(1000);  END; UNTIL USERQUITSEND.END.     


Each of the case statment parts points to a procedure higher up in the program when the main procdeure (the actual game) finishes it returns to the menu and only quits when you enter 3.

STVOY




Pyre Light Studios (Under Construction)





Edited by - STVOY on October 20, 2000 8:15:53 AM
Well Now,

Maybe I should have mentioned the variables:-

choice:INTEGER;
USERQUITS:BOOLEAN;

And it won''t work if you don''t put the procedures named above it but just change them to your own or get rid of them.

Hope that helps....

STVOY




Pyre Light Studios (Under Construction)



Don''t be sad, my school has MSV Studio Pro but they won''t let us use it ("to complicated" - an anonymous teacher) instead we got to joke around w/ tp6... (urg...)

well any of the ways above will work so no matter which you use be sure of my compassion...

I tend to use the "repeat ... until userquits:boolean" version.
IMHO it''s more elegant than halt (which I use only to stop the program after annoyingly wrong user input)
------------------------------------------------------------"To a computer, chaos is just another kind of order."
i have the smae problem at my school... we have a c++ compiler, and visual basic, but "we have to learn the basics first" they say... so we do turbo pascal... did i mention its a windows 3.1 app, and it compiles everything like a windows 3.1 app? it''s a bit annoying...

the main problem is that even if i do the repeat...until thing, the program ends, and the program just sits there and says ''finished''... i have yet to find a way to actually close the window... oh well... thanks people...

This topic is closed to new replies.

Advertisement