mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
Is there a easier way to make this work? I am trying to write a file on load
that writes up to 15 words into a text with there ID #.

I have to write this code like this for it to work

Code:
 
alias first {
  /write text.lst word1
  /write text.lst 1
  /write text.lst word2
  /write text.lst 2
  /write text.lst word3
  /write text.lst 3
  /write text.lst word4
  /write text.lst 4
  /write text.lst word5
  /write  5
}
 


it shows up in the text like this in the text

Code:
 
  word1
  1
  word2
  2
  word3
  3
  word4
  4
  word5
  5
 


When I use this code it writes the file but the file will not load in the hash table

Code:
 
alias first {
  //write text.lst $+(word1,$chr(13),1,$chr(13),word2:,$chr(13),2,$chr(13),word3,$chr(13),3,$chr(13),word4,$chr(13),4,$chr(13),word5,$chr(13),5,$chr(13))
}
 


This is what shows up in the text file

Code:
 
word11word22word33word44word55
 


This Chatitor  is $chr(13) or the hexadecimal numbers of cariage return

I am not shure why it will not load into the hash table.




Intelligence: It's better to ask a stupid question, then to prove it by not asking....
Joined: Sep 2005
Posts: 116
I
Vogon poet
Offline
Vogon poet
I
Joined: Sep 2005
Posts: 116
if u are tryin to write a hash into a file u can use

/hload -sbni <name> <filename> [section]
/hsave -sbnioau <name> <filename> [section]
Load or save a table to/from a file.

else u cna try this

[code]set %i 1
while (%i < 16) {
write text.lst $+(word,%i)
write text.lst %i
inc %i 1
}
unset %i

Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
I am trying to write the words into a text file on load so the script will load all the words from a text into a hash table

The problem I am having is when I use this command to load the hash table from the list

if $exists(words.txt) { /hload words words.txt }

What shows up in the word.txt is

word11word22word33word44word55 }

and it will not load into the hash table

Now If I use the the long format to write the text and save it using /hsave -o words words.txt it saves all the words into the format above

If it saves the words into that format it shoud load by that same format using /hsload words words.txt
From what I gather the table is made
but the lines are not loadind using this command if $exists(words.txt) { /hload words words.txt }

I have checked the file is in the mirc folder
and if I manually type the hload command it will not load those words into the hash table

I am using a hash viewer to see if the table is loaded
and all my tables show up with information but this one it will
show there is a table but there is no information load onto the
table




Intelligence: It's better to ask a stupid question, then to prove it by not asking....
Joined: Sep 2005
Posts: 116
I
Vogon poet
Offline
Vogon poet
I
Joined: Sep 2005
Posts: 116
werid maybe use a hadd on a $read for each linenuber in a while

Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
I am not sure why my hash table is not loading the words from a text file.




Intelligence: It's better to ask a stupid question, then to prove it by not asking....
Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Why don't you add directly to the hash file instead of writing to a text first and then loading to the hash table? It seems unnecessary.

Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
Because 15 words are being added to the hash table on load
then I would have to expand the script to include those 15 words plus new words that the end user may be adding as more triggers.

it is easier to save the words to a text file so the hash table can recall all words when loading the hash table




Intelligence: It's better to ask a stupid question, then to prove it by not asking....
Joined: Apr 2003
Posts: 24
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Apr 2003
Posts: 24
Why not add to the hash file and save it then just load that the next time round. If end user adds more words they could be saved to the same hash file anyway and then loaded the next time they start up.
Its got to be easier than reading from a text file and having the script then add from there. Or maybe Im just misunderstanding somethng here.

Last edited by ShavedApe; 16/05/06 01:04 AM.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
heres a litle bit of history for ya whcih might or might not be totaly correct, old typewriters used two things to get to a new line
Carriage return ( $chr(13) ) (that brought the print head back to the left edge) and then
Line feed ( $chr(10) ) (that made the paper move up one line thus the print head was on the next line)

Now when you go /write text.lst word1, it adds this to the file word1 $+ $chr(13) $+ $chr(10)

On your example when it doesnt work your only adding $chr(13)

now just to confuse the situation, when mirc hsaves a file, it doesnt save the $chr(13) it just uses the $chr(10)

So what to do, well you got two options, you can insert a $chr(10) following the $chr(13), or u can dump the $chr(13) and use $chr(10)

now for some extra choices to add to that, u can also dump using $chr(13) and $chr(10) mirc has identifiers for them $cr and $lf, and if u want both its even got $crlf

I would suggest u use this

//write text.lst $+(word1,$crlf,1,$crlf,word2:,$crlf,2,$crlf,word3,$crlf,3,$crlf,word4,$crlf,4,$crlf,word5,$crlf,5,$crlf)

only becuase some text editors pack a sad if theres only a linefeed (notepad comes to mind)


PS: on a diffetrnet subject, whats the purpose of the number, is it just something to put in the itemname (being the word)?
If so i would consider changing it so the ITEMname is 1 2 3 ect and the value is WORD1 WORD2 WORD3, you can still use the $hfind functions just use $hfind( ).data
if you did this u could use /hsave -n and /hload -n and just have the file containing the words, and no itemnames at all, a much nicer file!

Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
Thanks DaveC, The $lf worked just fine




Intelligence: It's better to ask a stupid question, then to prove it by not asking....

Link Copied to Clipboard