: : Ok i didn't quite undestand what you ment there. Ill show you what i have and mabey you can tell me a better way orsomething but i didn't really understand what you said just there. sorry

: : thanks though dude!
: :
: :
: :
: : write('Do you have a character you can load?(y or n)');
: : readln(load);
: : if load='y' then
: : begin
: : 1:
: : writeln('Select your character(hit "0" to make a new character.');
: : writeln;
: : FindFirst('*.', Archive, DirInfo);
: : load_counter:=0;
: : while DosError = 0 do
: : begin
: : load_counter:=load_counter+1;
: : Writeln('1.',DirInfo.Name);
: : char_1:=dirinfo.name;
: : FindNext(DirInfo);
: : if doserror <> 0 then
: : goto 2;
: : load_counter:=load_counter+1;
: : Writeln('2.',DirInfo.Name);
: : char_2:=dirinfo.name;
: : FindNext(DirInfo);
: : if doserror <> 0 then
: : goto 2;
: : {****I cut some out here, it goes to 10****}
: : 2:
: : end;
: : writeln;
: : if load_counter=0 then
: : begin
: : clrscr;
: : writeln('!!!NO AVALIABLE CHARACTERS!!!');
: : readln;
: : goto 3;
: : end;
: : write('You are:');
: : readln(char_load);
: : if (char_load>load_counter) or (char_load<-1) then
: : begin
: : writeln('That is not a valid choice! Please relselect');
: : goto 1;
: : end;
: : if char_load=0 then
: : goto 3;
: : if char_load=1 then
: : name:=char_1;
: : if char_load=2 then
: : name:=char_2;
: : assign(f, name);
: : reset(f);
: : readln(f, name);
: : readln(f, password);
: : write('Password:');
: : readln(pass_check);
: : pass_counter:=0;
: : if pass_check<>password then
: : begin
: : repeat
: : begin
: : writeln('!!!Incorect!!!');
: : writeln;
: : write('Password:');
: : readln(pass_check);
: : pass_counter:=pass_counter+1;
: : end;
: : until (pass_counter=2) or (password=pass_check);
: : if pass_counter=2 then
: : goto 1;
: : end;
: : readln(f, name);
: : readln(f, race);
: : readln(f, money);
: : close(f);
: : end;
: : if load<>'y' then
: : begin
: : 3:
: : clrscr;
: : FindFirst('*.', Archive, DirInfo);
: : while DosError = 0 do
: : begin
: : char_1:=dirinfo.name;
: : FindNext(DirInfo);
: : if doserror <> 0 then
: : goto 4;
: : char_2:=dirinfo.name;
: : FindNext(DirInfo);
: : if doserror <> 0 then
: : goto 4;
: : 4:
: : end;
: : write('Enter your name:');
: : readln(name);
: : if (name=char_1)or(name=char_2)then
: : begin
: : writeln('That name is already taken. Please repick.');
: : goto 3;
: : end;
: :
: : WOW!! A lot to handle right. Anyway if you don't type in all caps you can continue on in making the guy with the same but it saves over the other save. And that sucks cuse then your guy could be erased before you beet the game. So if you know how to fix this, or know a better way id apreaciate you telling me!
: : thanks again dude!!!!!
: :
:
: Just examined your code and I'm going to make a few suggestions that you can take or leave, but will help you out in the long run.
: To start with, to fix your problem of overwriting an existing character, there are two things that can be done.
: 1) Check if the file exists and don't allow it
: 2) change the filename to something different (as described by zibadian)
:
: The first one is extremely easy to do. Built into TP is a function known as UPCASE(); Although this will only do 1 character, this can be modified. Look at this function:
:
: FUNCTION UpStr(S : String) : String;
: VAR X : Byte;
: Begin
: For X := 1 to Length(S) Do
: S[X] := UpCase(S[X]);
: UpStr := S;
: End;
:
: This will take a String variable and go through it one letter at a time and change them to uppercase. So you could then use it like this:
:
: write('Enter your name:');
: readln(name);
: name := UpStr(name); { NAME is now in all upper-case }
: if (name=UpStr(char_1))or(name=UpStr(char_2))then
: begin
: writeln('That name is already taken. Please repick.');
: goto 3;
: end;
:
:
:
: The second method is better because it will allow two different people to have the same name. You could number them, such as:
: BOB-0.
: BOB-1.
: BOB-2.
:
: or you could just have them saved as numbers like this:
: player00.sav
: player01.sav
: player02.sav
:
: This would not effect anything since the name is stored inside of the file and you could just read the name out for displaying. Here's a quick example of how to get these:
:
: PROCEDURE LoadPlayer(Num : Byte); { Num = 0-99 }
: VAR
: PNum : String);
:
: Begin
: Str(Num, PNum); { Convert Number to String }
: If Length(PNum) < 2 Then PNum := '0' + PNum; { If < 10 add 0 to front }
: assign(F, 'PLAYER'+PNum)'; Reset(F);
: {...}
: close(F);
: End;
:
:
:
: The other thing I wanted to mention is that you should not load the file names until AFTER they have entered the name to Load. That way, you can easily have more than 2 saved games and you do not have to keep them in memory. Think of it like this:
:
: You have three files: Play01, Play02 & Play03.
: If you get these names first, your program will only hold 2. Therefore if the player enters PLAY01 or PLAY02 then it will say they exist, but if they enter PLAY03 then it will think it is okay.
:
:
: Not, if you have the name, let's say PLAY06, you can just compare as you search through.
:
: Get Players Name -> PLAY06
: Find the first File (PLAY01) and compare them. PLAY01 <> PLAY06, so get next file (PLAY02) and compare them. Again, PLAY02 <> PLAY06. Repeat this until you find PLAY06 (or no other files found). PLAY06 = PLAY06 so the file will not be overwritten.
:
:
: One last thing. Labels are very hard to follow, so it is better to use PROCEDURES or else REPEAT/UNTIL DO/WHILE statements. Here is a brief use of them and the CONTINUE statement.
:
: X := 0;
: REPEAT
: X := X + 1;
: If X = 4 Then Continue;
: WriteLn(X);
: UNTIL X = 6;
:
: If you were to run this code, numbers 1,2,3,5 & 6 would be written on the screen, but 4 would be missed. The continue statement will go to the top of the Loop, skipping everything after it.
:
: Lots of info here, hope this helps. If you are still stuck or need/want any suggestions, just write back
:
: Phat Nat
:
Thanks dude. First off i usually dont use labels but i was too tired to think when i wrote that part and didnt want to think of how to do the loop so i took the easy way out.(lol) I plan on changing it, but thanks for helping with that i didn't know about the continue statemnet which is cool. I dont think i will use the saving of player01, player02 and stuff becuase it would be kinda hard to make the number go up for each save. But thanks for that uppcase. If i knew that existed i would have used that because i used that loop you had to cause the text to look like it typed out on the screen using delays and the for x:=1 to length.Thanks alot for everything, i apreaciate it!!!