procedure kill_line;^^^^^^^^^^^^^^^^^^ This is not needed. In FPC would raise an exception.
var
fptr : file;
ti : onelinerec;
zz : byte;
begin
idx :=1;
zz :=1;
fclose(of);
fassign(of, cfgdatapath + '1liner.dat',66);^^^^^^^^^^^^^^^^^^^^^^^ What is idx2, its not declared above.
freset(of);
fassign(fptr, cfgdatapath + '1line.xxx',66);
frewrite(fptr);
while not feof(of) do
begin
if idx = idx2 then
begin^^^^^^^^^^^^^^^^^^^^^^^^^^^ You just created an empty file and i don't see anywhere writing to it. How do you read it (freadrec(fptr,oi)), when its empty?
freadrec(of,oi);
idx: = idx+1
end else
freadrec(fptr,oi);
ti.text := oi.from;
ti.from := oi.from;
I haven't "studied" the code but in a quick look, something is off. See remarks below.
fclose(of);^^^^^^^^^^^^^^^^^^ This is not needed. In FPC would raise an exception.
freset(of);^^^^^^^^^^^^^^^^^^^^^^^ What is idx2, its not declared above.
if idx = idx2 then
begin
freadrec(of,oi);
idx: = idx+1
end else
^^^^^^^^^^^^^^^^^^^^^^^^^^^ You just created an empty file and i don't
see anywhere writing to it. How do you read it (freadrec(fptr,oi)), when its empty?
I haven't "studied" the code but in a quick look, something is off. See remarks below.
In pseudocode, you could do this:
i:=0;
while not feof(fp) do begin
if i<>Index then do begin
freadrec(fp,record);
fwriterec(fnew,record);
end;
i:=i+1;
end;
but the file is already open and i wanted to make sure if i used freset() there would be no issuesIts not a good practice to open files somewhere and close them in an entire different procedure. Its not wrong or forbidden, but it helps in debugging. I only saw the code you gave us, so i didn't know you had opened the file at another place of the code.
no that's where the issues in the code. the reset it correct. after if idx=idx2 then
begin
You created a file with frewrite and then you try to read from it. When you create the file is empty, how you do the reading?
im not reading from the rewrite im reading from the 1line.dat and
writing to the 1line.xxx
i echoes some things to the screen and it would write till the number i didnt want or it would do all and lock depending on what i played with. 1liner.dat is a copy of the oneliner.dat and it recreates the file when you exit to the 1line.dat so others can try the demo. everything works minus the delete function. goto my board and /M from main menu and A
you will see what is going on option #2
I would gladly take a look at the code and fix the error. Making guesses like this is not helpful for both of us :) Is the code available? or can you email it to me? to take a look?
ok as some of you know i had a stroke in 2011 and i'm working on my online editor in mpl and everything works fine but one thing. i'm trying to remov record from the oneliner and regenerating the file. the part work but whe the record number matched the one that needs to be removed. when it gets the matching record it chokes. this is part if the codeShould the 'end else' be 'end else begin' with an 'end' after the stanza?
procedure kill_line;
var
fptr : file;
ti : onelinerec;
zz : byte;
begin
idx :=1;
zz :=1;
fclose(of);
fassign(of, cfgdatapath + '1liner.dat',66);
freset(of);
fassign(fptr, cfgdatapath + '1line.xxx',66);
frewrite(fptr);
while not feof(of) do
begin
if idx = idx2 then
begin
freadrec(of,oi);
idx: = idx+1
end else
freadrec(fptr,oi);
ti.text := oi.from;
ti.from := oi.from;
Should the 'end else' be 'end else begin' with an 'end' after the stanza?
Sysop: | sneaky |
---|---|
Location: | Ashburton,NZ |
Users: | 31 |
Nodes: | 8 (0 / 8) |
Uptime: | 132:06:28 |
Calls: | 2,073 |
Files: | 11,136 |
Messages: | 947,545 |