PDA

View Full Version : Program Closes After Procedure is Run [Solved Myself]



DarknessX
06-05-2007, 10:57 PM
System: WinXP
Compiler/IDE: FPC
Libraries/API: None.

[Well, I solved it myself.

{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';


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.

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.

JernejL
07-05-2007, 07:16 AM
will: the code highlighter is broken on that code, the string coloring broke on >>''<<.

DarknessX
07-05-2007, 10:48 AM
Fixed it :)

JernejL
07-05-2007, 10:54 AM
oh, i thought it was a bug in forum code highlighter.

WILL
07-05-2007, 01:53 PM
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.

DarknessX
07-05-2007, 07:28 PM
I just removed the '' and turned it into a '.