mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
hello again,

i'm currently working on a small topic recover type thingy, and i'm stumped with how to handle the store file. it's a dialog based syetem, and i have been fortunate enough to come up with some good examples. however, i'm stumped on how to get the results i want..

here are the samples i have:
(these would be used in the dialog init event)
Code:
.fopen cc OPCTrecovery.dat 
      if !$ferr {
        while !$feof { 
          if $fread(cc) {  
            tokenize 124 $v1   
            did -a $dname 5 $1   
            did -a $dname 1 $2   
          } 
        } 
      }  
      .fclose cc
    }
  


and

Code:
loadbuf -o $dname 1 OPCTrecovery.dat 
 var %i = 1 
 while $did(1,%i) {  
  did -a $dname 5 $gettok($v1,1,124)  
  inc %i 
 }
  


now what i'm doing is loading the files contents into a dialog, for review and what-not. the first piece of code i posted does what i want.. which is return the line of text in split format to the appropriate boxes.. but i'm unsure on how to delete lines from the file using the first code.

the second piece of code displays the whole line instead of what i'm looking for, which is everything after the pipe(chr(124))

heres the dialog code :
Code:
dialog opc_tr {
  title Topic Recovery For: 
  size -1 -1 261 70
  option dbu
  combo 1, 7 20 246 50, hsbar drop
  button "Close", 2, 207 52 37 12, ok
  button "Delete Topic", 3, 7 51 37 12
  button "Restore Topic", 4, 59 51 37 12
  list 5, 60 6 50 10, size
  text "Last Edited On:", 6, 19 8 39 7
}
On *:TOPIC:*:{
  /write OPCTR.dat $+($asctime(mmmddyy@hh:nntt),$chr(124),$chan(#).topic) 
}
raw 332:*:{ /write OPCTR.dat $+($asctime(mmmddyy@hh:nntt),$chr(124),$3-)
}

  


i do hope i'm making some kind of sense here.. any ways could someone help with this?

thanks in advance

Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
ok, i know the the file names don't match :tongue:. but besides that.. to better explain what i'm looking to do is this:

1. load the contents into the aproprite dialog boxes
2. i know i need to tokenize the file lines using chr(124) as the delimiter to do this. the first eample code using the file handeling commands fopen and such... it does what what i want 100%, but i don't know if i can use the write command to edit the store file(to delete lines) with the way it tokenized the data. will it just delete the whole line or just part of it?
3. the second code example used loadbuff to "dump" the contents of the file into dialog box 1 and then pulls the info for dialog box 5 from box one butleaves the whole line viewable which that part is not desireable..
this is what the format of the store file looks like:
[email]Aug3005@12:12am|hello[/email] dolly!

and i'm looking to have it broken into 2 parts... the date portion i want it in one box and the text from the pipe in the other..

any help and/or suggestions will be appreciated.. thanks

Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
Instead of sending directly to the dialog during the loop in your fopen script, maybe you should have it add the data to a hash table in the format ID=$fread(cc). Where $fread(cc) is the line from the file, and ID is the line number it was taken from.

You could then design the dialog to easily retrieve/edit/remove data from the hash table instead of the file, and then write the data back to the file once you are done (click the ok button). You can easily rewrite the file at this stage by looping through the hash table in order and writing each data field entry to the next line in the file.


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
thanks for the reply Om3n,

Quote:
You could then design the dialog to easily retrieve/edit/remove data from the hash table instead of the file, and then write the data back to the file once you are done (click the ok button). You can easily rewrite the file at this stage by looping through the hash table in order and writing each data field entry to the next line in the file.


i was thinking of using a hash for the same reasons

Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
okay, i seem to be having trouble with aquiring the line number from the text..

any suggestions?


Link Copied to Clipboard