• Door Game Help????

    From Becky Mcmillen@1:129/305 to All on Thu Jan 17 21:42:43 2008
    Hello,

    I am having a bit of trouble with a door game I am making. I cannot for the life of me get the user data to read/write from a user.dat file. Here is a snippet of code and maybe someone can tell me where I am going wrong to search the record for a user (Using DDPLUS) for a user name, and if found pull it out. If not, create a new? Thank You In Advance!

    {$M 19456,0,655360}

    program game;
    uses crt, ddplus;


    type UserRecord = Record

    Name1 : string[30]; {first name}
    Name2 : string[30]; {last name}
    Hps : longint; {hitpoints}
    Exp : longint; {experiece}
    Score : longint; {score}
    Level : longint; {level}

    end;

    UserArray = Array [1..500] of UserRecord;
    var

    Name1, Name2: String[30];
    Hps, Exp, Score, Level: longint;
    I, X : Integer;
    CH : char;
    FOUND: BOOLEAN;
    SysOp: UserArray;
    Users: UserRecord;
    UserFile: file of UserRecord;

    {***************************************************************}

    Procedure NewPlayer;

    begin
    Assign(UserFile, 'SYSUSERS.DAT');
    {$I-}
    reset (UserFile);
    {$I+}

    X:=filesize(UserFile);
    I:=1;

    For I:=1 to X do begin
    read (UserFile, Users);

    Users.Name1 := User_First_Name;
    Users.Name2 := User_Last_Name;
    Users.Hps := 25;
    Users.Exp := 0;
    Users.Score := 0;
    Users.Level := 1;
    end;
    end;


    {***************************************************************}

    Procedure Show;
    begin
    swrite('User Name '+Users.Name1 +' '+ Users.Name2);
    end;

    {***************************************************************}

    Procedure AssignData (VAR OutData : UserRecord);

    begin
    with OutData do
    begin

    Users.Name1 := User_First_Name;
    Users.Name2 := User_Last_Name;
    Users.Hps := 25;
    Users.Exp := 0;
    Users.Score := 0;
    Users.Level := 1;

    end;
    end;


    {**************************************************************}

    Procedure Data;

    var
    UserFile : File Of UserArray;

    Begin
    assign(UserFile, 'SYSUSERS.DAT');
    { rewrite(UserFile);}
    reset(UserFile);
    read(UserFile, SysOp);
    I:=1;
    Found:= FALSE;
    While (I <=750) and (Not Found) do
    Begin
    write(I);
    with SysOp[I] do
    Found := (Users.Name1 = User_First_Name) and (Users.Name2 = User_Last_Name);
    inc(I);
    end;

    If Found = TRUE then begin
    { sclrscr; }
    swriteln('Welcome Back!');
    I:=I-1;
    writeln ('User #');
    writeln (I);
    readln;
    assigndata(SysOp[I]);
    reset(UserFile);
    write(UserFile, SysOp);
    Close(UserFile);
    end
    else begin
    { sclrscr;}
    swriteln('YOU ARE NEW!!!!!!!!!!!!!!!');
    I:=1;
    while (SysOp[I].Name1 <> '') and (I <=750) do
    inc(I);
    assigndata(SysOp[I]);
    reset(UserFile);
    write(UserFile, SysOp);
    Close(UserFile);
    end;
    end;

    {***************************************************************}



    Begin

    InitDoorDriver('GAME.CTL');
    NewPlayer;

    Data;
    AssignData(SysOp[I]);
    Show;
    readln;
    end.

    --- Renegade v12-07.7/Alpha
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)
  • From Rich Landskroener@1:129/305 to Becky Mcmillen on Sun Feb 3 12:18:16 2008
    Hello,

    I am having a bit of trouble with a door game I am making. I cannot for th life of me get the user data to read/write from a user.dat file. Here is a snippet of code and maybe someone can tell me where I am going wrong to sea the record for a user (Using DDPLUS) for a user name, and if found pull it out. If not, create a new? Thank You In Advance!

    What kinds of errors are you getting?

    --- Renegade v01-28.8/Alpha
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)