Results 1 to 6 of 6

Thread: Program Closes After Procedure is Run [Solved Myself]

  1. #1

    Program Closes After Procedure is Run [Solved Myself]

    System: WinXP
    Compiler/IDE: FPC
    Libraries/API: None.

    [Well, I solved it myself.
    [pascal]
    {begin...}
    Readln(listnuma);
    isfirstrun := 'false';
    assign(f, 'config.ini');
    rewrite(f);
    writeln(f, isfirstrun);
    writeln(f, path);
    writeln(f, listnuma);
    close(f);
    @ assign(f, 'config.ini');
    @ reset(f);
    @ end;
    @ Readln(f, isfirstrun);
    @ Readln(f, path);
    @ Readln(f, listnuma);
    @ Close(f);
    until isfirstrun = 'false';
    [/pascal]

    The lines marked by '@' show where the error was...
    Before the begin.. end statement closed, it closed a file and then reopened it, but didn't do anything with it, but after the end, it tried to read from the file. This caused an error, and to make the program close.

    Well, I've had to test things to find the particular problem, but I've found that after RunTime is run, it automatically closes the program without letting me see the screen. I don't think you need any more information, but if you do, let me know. Oh, and path would be similar to:
    C:\Projects\Task Scheduler
    in case you need to know. Config.ini is 3 lines, first one is isfirstrun = 'true' or 'false', 2nd is the path to the app, 3rd is for formatting the page display system.
    [pascal]
    procedure RunTime;
    begin
    repeat
    Assign(f, 'config.ini');
    Reset(f);
    Readln(f, isfirstrun);
    Close(f);
    if isfirstrun = 'true' then
    begin
    ClrScr;
    Writeln('Welcome to ...! Before you can use the program, you must');
    Writeln('set a few options.');
    Writeln;
    Writeln('First, what is the path to the program?');
    Writeln('Example, C:\Program Files\DX\TimerX');
    Writeln('Make sure you dont include the last slash.');
    Readln(path);
    ClrScr;
    Writeln('Ok, now when the program lists the current timers,');
    Writeln('it displays a list of them all in page format. How many');
    Writeln('timers do you want displayed per page? Any number from 1-10');
    Writeln('will work, and higher will aswell, but anything higher may');
    Writeln('cause problems.');
    Readln(listnuma);
    isfirstrun := 'false';
    assign(f, 'config.ini');
    rewrite(f);
    writeln(f, isfirstrun);
    writeln(f, path);
    writeln(f, listnuma);
    close(f);
    assign(f, 'config.ini');
    reset(f);
    end;
    Readln(f, isfirstrun);
    Readln(f, path);
    Readln(f, listnuma);
    Close(f);
    until isfirstrun = 'false';

    Assign(f, 'list.txt');
    Reset(f);
    x := 1;
    repeat
    Readln(f, timer[x]);
    x := x + 1;
    until Eof(f);
    Close(f);
    X := 1;
    repeat
    Assign(f, path+'\timers\'+timer[x]+'.tmr');
    Reset(f);
    Readln(f, timer[x]);
    Readln(f, timertime[x]);
    Readln(f, TimerDay[x]);
    Readln(f, timerDate[x]);
    readln(f, AP[x]);
    Close(f);
    x := x + 1;
    until timer[x] = '';
    ClrScr;
    Writeln('Current Configuration: ');
    Writeln('Program Path: ', path);
    Writeln('Items to Display per Page: ', listnuma);
    Delay(8000);
    ClrScr;
    Exit;
    end;

    procedure CommandCheck;
    begin
    ClrScr;
    if exx = 'quit' then
    begin
    quit := true;
    end;

    if exx = 'list timers' then
    begin
    ListItems;
    end;

    if exx = 'add timer' then
    begin
    AddItem;
    end;

    if exx = 'remove timer' then
    begin
    RemoveItem;
    end;
    end;

    begin
    RunTime;
    repeat
    if keypressed then
    begin
    readln(exx);
    if exx <> '' then
    begin
    CommandCheck;
    exx := '';
    end;
    end;
    RunTime;
    readln;
    until quit = true;
    end.
    [/pascal]
    --MagicRPG--

  2. #2

    Program Closes After Procedure is Run [Solved Myself]

    will: the code highlighter is broken on that code, the string coloring broke on >>''<<.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  3. #3

    Program Closes After Procedure is Run [Solved Myself]

    Fixed it
    --MagicRPG--

  4. #4

    Program Closes After Procedure is Run [Solved Myself]

    oh, i thought it was a bug in forum code highlighter.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Program Closes After Procedure is Run [Solved Myself]

    [size=9px]The Pascal code highlighter is unfortunately not as smart as that used in either Delphi or SynEdit. Some highlighting errors may occur from time to time.[/size]
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #6

    Program Closes After Procedure is Run [Solved Myself]

    I just removed the '' and turned it into a '.
    --MagicRPG--

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •