[Pascal] Variable issue « Thread Started on Mar 4, 2006, 1:59pm »
alright, so I've been working on this program for a while, just a small game of sorts i'm trying to make, i'll probably never finish it but anyways. I have a variable issue, in my program I want to make like a secret part of it, where if you type in a specific word in the starting menu it will jump to a part of the program that wont run if you just play normally.
for my menu I use a case code, where the variable is set to be char, but that means I can't use more than 1character/number/symbol in the menu. So I need to mis the menu with another variable, but i'm not sure how to do so.
Code:
program <insert name>; uses crt; var a: char;
begin writeln('hello :o'); readln(a); case a of '1': goto <label name>; '2': goto <label2 name>; '3': goto <label3 name>; end;
end.
so in this menu I want to make it if you type "secret" it jumps to a different part of the program. I could change it all to IF codes, but it's easier to remove bugs so the program wont crash with the case menu.
Well, this is definitely late, but you should make the character variable into a string variable. A string will consist of a series of characters, like a word. Basically, change "char" to "string" and it should be good to go! But I haven't done Pascal for a couple years, so it may not be "string". I'm pretty darn sure it is, thought.
Re: [Pascal] Variable issue « Reply #2 on Aug 1, 2006, 4:13pm »
the problem by using a STRING is that it makes it alot harder to make the program error proof, so if I push the wrong key or number the program will shut down. Sorry my tiny preview didn't show this. I needed a combination of both.