• trying to skip record but forgetting how

    From dream master@21:1/163 to All on Wednesday, June 13, 2018 00:41:02
    ok as some of you know i had a stroke in 2011 and i'm working on m
    y onlinereditor in mpl and everything works fine but one thi
    ng. i'm trying to remove arecord from the oneliner and regen
    erating the file. the part work but whenthe record number m
    atched the one that needs to be removed. when it gets tothe
    matching record it chokes. this is part if the codep
    rocedure kill_line;varfptr : file;ti :
    onelinerec;zz : byte;beginidx :=1;
    zz :=1;fclose(of);fassign(of, cfgdatapath + '1li ner.dat',66);freset(of);fassign(fptr, cfgdat
    apath + '1line.xxx',66);frewrite(fptr);while
    not feof(of) dobeginif idx = idx2 then
    beginfreadrec(of,oi);idx: = idx+1e
    nd elsefreadrec(fptr,oi);ti.text := oi.from;
    ti.from := oi.from;do you think it's the begin and end th
    at its looping some how in?as you know the oneliner.d
    at record is:TypeOneLineRec = Record
    Text : String[79];From : String[30];End;i
    use idx for record number to read. idx :=1 and it ge
    ts incremented as it goes. this is the only thing stumpingm
    e..úùDream Ma
    sterùú.øùúùøøù
    úùøDoRE!ACiDiC!
    Demonic[dreamland.darktech.org
    ]
    --- Mystic BBS v1.12 A39 2018/04/21 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From xqtr@21:1/111 to dream master on Wednesday, June 13, 2018 19:23:42
    I haven't "studied" the code but in a quick look, something is off. See
    remarks below.

    procedure kill_line;
    var
    fptr : file;
    ti : onelinerec;
    zz : byte;
    begin
    idx :=1;
    zz :=1;
    fclose(of);
    ^^^^^^^^^^^^^^^^^^ This is not needed. In FPC would raise an exception.
    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
    ^^^^^^^^^^^^^^^^^^^^^^^ What is idx2, its not declared above.
    begin
    freadrec(of,oi);
    idx: = idx+1
    end else
    freadrec(fptr,oi);
    ti.text := oi.from;
    ti.from := oi.from;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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?

    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;

    This will copy each record except the one to be deleted (Index).

    Hope, i helped... :)

    .----- --- -- -
    | Another Droid BBS
    : Telnet : andr01d.zapto.org:9999 [UTC 11:00 - 20:00]
    . Contact : xqtr@gmx.com

    --- Mystic BBS v1.12 A39 2018/04/21 (Raspberry Pi/32)
    * Origin: Another Droid BBS (21:1/111)
  • From dream master@21:1/163 to xqtr on Wednesday, June 13, 2018 10:39:22
    On 06/13/18, xqtr said the following...
    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.

    but the file is already open and i wanted to make sure if i used freset()
    there would be no issues

    freset(of);
    if idx = idx2 then
    ^^^^^^^^^^^^^^^^^^^^^^^ What is idx2, its not declared above.
    begin
    freadrec(of,oi);
    idx: = idx+1
    end else

    that is the number of the record index passes as you use [] to go back and forth of the record

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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?

    no that's where the issues in the code. the reset it correct. after if idx=idx2 then
    begin
    in here is where it keeps going to.
    end

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A39 2018/04/21 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From dream master@21:1/163 to xqtr on Wednesday, June 13, 2018 12:45:56
    On 06/13/18, xqtr said the following...
    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;

    it still locks in and writes the record not to write to. i have to disconnect, kill windows and call back in. here is the whole thing

    procedure kill_line;
    var
    fptr : file;
    ti : onelinerec;
    zz : byte;
    begin
    idx :=1;
    zz :=1;
    fassign(of, cfgdatapath + '1liner.dat',66);
    freset(of);
    fassign(fptr, cfgdatapath + '1line.xxx',66);
    frewrite(fptr);
    while not feof(of) do
    if idx <> idx2 then
    begin
    freadrec(fptr,oi);
    ti.text := oi.text;
    ti.from := oi.from;
    fseek(fptr,(zz-1)*sizeof(ti));
    fwriterec(fptr,ti);
    idx := idx+1;
    zz := zz+1;
    end
    fclose(of);
    fclose(fptr);
    fileerase(cfgdatapath + '1liner.dat');
    filecopy(cfgdatapath + '1liner.xxx','1liner.dat');
    end

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A39 2018/04/21 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From xqtr@21:1/111 to dream master on Thursday, June 14, 2018 10:37:09
    but the file is already open and i wanted to make sure if i used freset() there would be no issues
    Its 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?

    .----- --- -- -
    | Another Droid BBS
    : Telnet : andr01d.zapto.org:9999 [UTC 11:00 - 20:00]
    . Contact : xqtr@gmx.com

    --- Mystic BBS v1.12 A39 2018/04/21 (Raspberry Pi/32)
    * Origin: Another Droid BBS (21:1/111)
  • From dream master@21:1/163 to xqtr on Thursday, June 14, 2018 11:36:33
    On 06/14/18, xqtr said the following...
    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

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A39 2018/04/21 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From xqtr@21:1/111 to dream master on Thursday, June 14, 2018 19:24:45
    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?

    .----- --- -- -
    | Another Droid BBS
    : Telnet : andr01d.zapto.org:9999 [UTC 11:00 - 20:00]
    . Contact : xqtr@gmx.com

    --- Mystic BBS v1.12 A39 2018/04/21 (Raspberry Pi/32)
    * Origin: Another Droid BBS (21:1/111)
  • From dream master@21:1/163 to xqtr on Friday, June 15, 2018 12:33:03
    On 06/14/18, xqtr said the following...
    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?

    i have not released it yet what is an email? this is the only thing keeping
    me from releasing it

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A39 2018/04/21 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From Gryphon@21:1/120 to dream master on Wednesday, June 20, 2018 07:34:42
    On 06/13/18, dream master said the following...

    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 code

    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?

    --- Mystic BBS v1.12 A39 2018/04/21 (Linux/64)
    * Origin: Cyberia BBS | cyberia.darktech.org | San Jose, CA (21:1/120)
  • From dream master@21:1/163 to Gryphon on Wednesday, June 20, 2018 11:23:59
    On 06/20/18, Gryphon said the following...
    Should the 'end else' be 'end else begin' with an 'end' after the stanza?

    i got it working it's done. just waiting on a screen

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A39 2018/04/21 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)