|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
I'm working on something that needs to enter items into a hash table if something else is busy. I've been just writing the que to a file and having the file just delete the first line once the que is used. But I figured I'd start trying out hash tables thanks to someone showing me how they actually work. hashtable is quetest If the @window is open, add item to the quetest table by number (found out that can't happen so i decided to try que"number". Once the @window is closed, it then reads the quetest hash table for the next text if any. Below is just a sample of getting it to work, im using @window because in the script i'm actually working on will be a picture window and the %text will be used with drawtext. The window will popup show the text then close after a certain amount of time, when closed it runs the command again to check if there are any ques, if so it sends the que to the text and pops the window up again. But I dunno how to accompish this with hash tables. I suppose what I need is a way to resort teh hash table once the first item is always deleted but I read on here on several posts that sorting hash tables is impossible. Example:
alias quetest {
var %text
if ($window(@quetest)) {
;write quetest.txt $1-
hadd -ms quetest que $+ $calc($hget(quetest,0).item +1) $1-
halt
}
if (!$window(@quetest)) {
if ($hget(quetest,0).item != 0) {
;%text = $read(quetest.txt,1) | write -dl1 quetest.txt
%text = $hget(quetest,que"numofoldestentry") | hdel -s quetest que"numofoldestentry"
}
else { %text = $1- }
}
if (%text) {
window -k0 @quetest 2 2 200 200
aline @quetest test %text
timerwincloseqt 1 4 window -c @quetest
timerchkquetest 1 5 quetest
}
}
I hope that I explained what I'm wanting it to do, but my luck I probably confused everyone heh. Any help appreciated, thanks in advance.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
I suppose what I need is a way to resort teh hash table once the first item is always deleted but I read on here on several posts that sorting hash tables is impossible. You can not sort a hashtable at all, its not designed to be sorted be it on itemname or data or entery insertion date. You can create what is essentially a sorted list of the hashtable, but this requieres hsaving to files and filtering that info using a sort then back refrencing it to the orgina hashtable, and this lasts for only as long as you do not alter the hashtable. However what you want is alot simplier, you just need to keep a record of the start and end of the queue. Example: alias quetest {
var %text
if ($window(@quetest)) {
;write quetest.txt $1-
var %queEND = $calc(1 + $hget(quetest,queEND))
hadd -sm quetest que $+ %queEND $1-
hadd -sm quetest queEND %queEND
;^ Pull in the END of queue pos and add 1 to it, then save the data into this location and save the new END pos of the queue
;
return
}
if (!$window(@quetest)) {
if ($calc($hget(quetest,queDONE)) < $calc($hget(quetest,queEND))) {
;^ if the last DONE queue pos is less than the END of queue pos there must be something in the queue, so deal to it
;
;%text = $read(quetest.txt,1) | write -dl1 quetest.txt
var %queDONE = $calc(1 + $hget(quetest,queDONE))
var %text = $hget(quetest,que $+ %queDONE)
hdel -s quetest que $+ %queDONE
;*2
hadd -sm quetest queDONE %queDONE
;^ Pull in the last DONE queue pos and add 1 to it, then pull that data out, and delete it from the queue and save the new last DONE pos in the queue
;
}
else { %text = $1- }
;^ *1
}
if (%text) {
window -k0 @quetest 2 2 200 200
aline @quetest test %text
timerwincloseqt 1 4 window -c @quetest
timerchkquetest 1 5 quetest
}
} *1 Im not so sure if your logic is correct with the *1 point of your script, i would have thought if some text is passed as $1 it would have been needed to be added to the end of the querue and the first queue entery be removed and used?, this is outside the scope of making your queue work of course, so yuou well know better if that is the case or not. I just thought id mention it as something that looked a bit odd. *2 the script never bothers to reset the queue DONE and END counters, when the queue expires (no entries), i always thought that extra code was worth little to nothing, since mirc can use huge number in there so why reset it. However if your one of them ones that always like the queue to restart from 1 when it has expired then add the following line at *2 if ($calc($hget(quetest,queDONE)) >= $calc($hget(quetest,queEND))) { var %queDONE = 0 | hadd -sm quetest queEND %queDONE } On a sidde note.... You might notice i use $calc() around some things, i have done this becuase of the why mirc deals with $null (which might be if queDONE or queEND dont exist) this is just to create a value of zero rather than null ie: //if ($null > 1) echo $true : $v1 : $v2 | else echo $false : $v1 : $v2 $false : : 1 //if ($null = 1) echo $true | else echo $false $false : : 1 //if ($null > 1) echo $true | else echo $false $false : : 1 verses //if($calc($null) < 1) echo $true : $v1 : $v2 | else echo $false : $v1 : $v2 $true : 0 : 1
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
You can not sort a hashtable at all, its not designed to be sorted be it on itemname or data or entery insertion date. You can create what is essentially a sorted list of the hashtable, but this requieres hsaving to files and filtering that info using a sort then back refrencing it to the orgina hashtable, and this lasts for only as long as you do not alter the hashtable. Hrm, might just keep using write and read then. Seem like my easiest best options.
alias quetest {
var %text
if ($window(@quetest)) {
write quetest.txt $1-
echo -ag window open que text to file
;hadd -ms quetest que $+ $calc($hget(quetest,0).item +1) $1-
halt
}
if (!$window(@quetest)) {
if ($lines(quetest.txt)) {
%text = $read(quetest.txt,1) | write -dl1 quetest.txt
;%text = $hget(quetest,que"numofoldestentry") | hdel -s quetest que"numofoldestentry"
}
else { %text = $1- }
}
if (%text) {
window -dopk0 @quetest 2 2 200 200
drawtext -r @quetest $rgb(255,255,255) Tahoma 11 2 2 test %text
timerwincloseqt 1 4 window -c @quetest
timerchkquetest 1 5 quetest
}
}
This shows what im trying to accomplish, using the txt file method works everytime. In mirc use this type: /quetest this is a test wait for it to happen and finish then type /quetest this is a test when the window comes up do it again while its up then wait when the window goes off teh que finds an entry in the text file and shows that entry. I'm sure this can be done using hash, but if first saving to a file then rehashing the info every time. I guess it's best to stick with just flat file. *1 Im not so sure if your logic is correct with the *1 point of your script, i would have thought if some text is passed as $1 it would have been needed to be added to the end of the querue and the first queue entery be removed and used?, this is outside the scope of making your queue work of course, so yuou well know better if that is the case or not. I just thought id mention it as something that looked a bit odd. Ill explain each line using the text method. alias quetest { var %text set variable so i dont have to var myself to death if ($window(@quetest)) { if window @quetest is open write quetest.txt $1- write $1- to quetest.txt echo -ag window open que text to file echo back etc... ;hadd -ms quetest que $+ $calc($hget(quetest,0).item +1) $1- halt halt it cuz its already running } if (!$window(@quetest)) { if the window @quetest is not open if ($lines(quetest.txt)) { if quetest.txt has lines %text = $read(quetest.txt,1) | write -dl1 quetest.txt update %text with the first line of the quetest.txt file and then delete the first line so it wont be read again which bumps anything under it up to becoming the first line ;%text = $hget(quetest,que"numofoldestentry") | hdel -s quetest que"numofoldestentry" } else { %text = $1- } else if quetest.txt has no lines just update %text with $1- } if (%text) { if %text is not null window -dopk0 @quetest 2 2 200 200 drawtext -r @quetest $rgb(255,255,255) Tahoma 11 2 2 test %text timerwincloseqt 1 4 window -c @quetest timerchkquetest 1 5 quetest etc... } } I think i have somewhat of an idea what your talking about using END and DONE. Though I tryed what you created and nothing seemed to happen.  Yeah I use calc alot to for the exact same reason. Thanks for your help.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Hrm I might of been able to pull off what I wanted easily if hash tables didn't add stuff randomly.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
i showed you code that did it.
And Hash tables dont stuff randomly they add it based on a specific hashing of the itemname, I know this becuase i have a script that takes multiple responces from fileservers and packages up the responces i need to send them, since replying to all at once is gonna cause me to flood, i have them loaded into a hash table using $nick as the item name, then on a timer i take action, always accessing $hget(hashtable,1).item untill there isnt any left, What i notice is the first nick processed is always the same one, which i assume means his nick hashes down to #1 slot in the table.
All that however is little use to u, but i felt the code i gave you (if it worked i never tested it i must admit) would have done exactly what you wanted (i folowed the remarked lines for what you were trying to do)
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
window open que text to file * Made hash table 'quetest' (100) * Added item 'que1' to hash table 'quetest' window open que text to file * Added item 'que2' to hash table 'quetest' window open que text to file * Added item 'que3' to hash table 'quetest' returns in this order: starting with $hget(quetest,1) - 3 que2 que3 que1 the info is out of order. * Added item 'que4' to hash table 'quetest' * Added item 'que5' to hash table 'quetest' which the hash table now has que1-5 added in 1-5 order returns: starting with 1-5 que2 que5 que4 que3 que1 And Hash tables dont stuff randomly they add it based on a specific hashing of the itemname, I know this becuase i have a script that takes multiple responces from fileservers and packages up the responces i need to send them, since replying to all at once is gonna cause me to flood, i have them loaded into a hash table using $nick as the item name, then on a timer i take action, always accessing $hget(hashtable,1).item untill there isnt any left, What i notice is the first nick processed is always the same one, which i assume means his nick hashes down to #1 slot in the table.
That looks semi random to me  You know that because you've scripted something? I'm sure hundreds have scripted something using hash tables, that possibly do the same thing you showed me. But it didn't work when I tried it and i'm not that fimilar with hash tables enough to try and solve the code myself. That's a long run-on sentance  . Hash tables do add randomly. Random not meaning it picks out a slot on it's own, just the first free one. Hash tables are stored in system memory correct? The RAM? RAM stands for Random access memory. When available slots open in the ram area the data goes in. Hash's do the same thing. Suppose you add to a hash file, the item name: apple, you hget the first entry and it's apple. Then you add: orange, it may be the second entry. Add: banana it could now be the third entry. you remove orange from the hash table, that slot in the hash is freed. Doesn't seem very ordered  . Items stored in any free slot inside of 100 slots given no order to their storage = random. I do appreciate the help, an maybe what you showed me will benifit me later on. But I do think that for the time being i'll use something that I know is solid and that's writing text files and reading from them. Thanks again.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Made this to test just how much order is going on into hash tables.
alias htabletest {
if ($hget(htabletest)) { hfree -s htabletest }
hmake -s htabletest 100
var %createentries = 10
var %i = 1
while (%i <= %createentries) {
hadd -s htabletest que $+ $calc($hget(htabletest,0).item +1)
inc %i
}
echo -ag Done creating %createentries entries in htabletest
%i = 1
var %hashentries = $hget(htabletest,0).item
while (%i <= %hashentries) {
echo -ag Entry %i == $hget(htabletest,%i).item
inc %i
}
}
This is what it returns: * Added item 'que1' to hash table 'htabletest' * Added item 'que2' to hash table 'htabletest' * Added item 'que3' to hash table 'htabletest' * Added item 'que4' to hash table 'htabletest' * Added item 'que5' to hash table 'htabletest' * Added item 'que6' to hash table 'htabletest' * Added item 'que7' to hash table 'htabletest' * Added item 'que8' to hash table 'htabletest' * Added item 'que9' to hash table 'htabletest' * Added item 'que10' to hash table 'htabletest' Done creating 10 entries in htabletest Entry 1 == que6 Entry 2 == que7 Entry 3 == que4 Entry 4 == que5 Entry 5 == que2 Entry 6 == que3 Entry 7 == que1 Entry 8 == que8 Entry 9 == que9 Entry 10 == que10 Does that seem like order?  Even tried it with 20 entries: * Added item 'que1' to hash table 'htabletest' * Added item 'que2' to hash table 'htabletest' * Added item 'que3' to hash table 'htabletest' * Added item 'que4' to hash table 'htabletest' * Added item 'que5' to hash table 'htabletest' * Added item 'que6' to hash table 'htabletest' * Added item 'que7' to hash table 'htabletest' * Added item 'que8' to hash table 'htabletest' * Added item 'que9' to hash table 'htabletest' * Added item 'que10' to hash table 'htabletest' * Added item 'que11' to hash table 'htabletest' * Added item 'que12' to hash table 'htabletest' * Added item 'que13' to hash table 'htabletest' * Added item 'que14' to hash table 'htabletest' * Added item 'que15' to hash table 'htabletest' * Added item 'que16' to hash table 'htabletest' * Added item 'que17' to hash table 'htabletest' * Added item 'que18' to hash table 'htabletest' * Added item 'que19' to hash table 'htabletest' * Added item 'que20' to hash table 'htabletest' Done creating 20 entries in htabletest Entry 1 == que6 Entry 2 == que7 Entry 3 == que4 Entry 4 == que5 Entry 5 == que2 Entry 6 == que3 Entry 7 == que1 Entry 8 == que8 Entry 9 == que9 Entry 10 == que18 Entry 11 == que19 Entry 12 == que20 Entry 13 == que16 Entry 14 == que17 Entry 15 == que14 Entry 16 == que15 Entry 17 == que12 Entry 18 == que13 Entry 19 == que10 Entry 20 == que11
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Hash tables indeed have no order to them, but they are not random. The data is placed (somewhere) in RAM according to a reproducable algorithm, aka the hash. The data is not necessarily in order within RAM, but a specific item can be retrieved whenever it is necessary. What you have created by writing to a file and then reading the first item over and over again is called a FIFO (First In First Out) buffer. Hash tables do this well enough, but the only catch is that you have to do some of the work that is done by built-in code when you use the write-to-file method. Some code somewhere keeps track of the beginning and end of the text file so that you can read the first line and write the last line. Since hash tables don't have that ability, you have to create it yourself. I have created a buffer script that acts as a FIFO. It may need some modifications to suit your needs, but it should be suitable for the most part. https://forums.mirc.com/s...true#Post144909 (Use the code near the bottom with the blue edits). -genius_at_work
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Ouch, lots of lines for such an easy method using write and read. Appreciate your comments and suggestions. But I'm still sticking with write and $read as it seems less code. I was just wanting to avoid having to use a file for the temporary data or using more than 1 hash table, but seems it's going to have to use a file or another hash table, so I might as well just use the smaller of the 2.
I still say hash is random. Or well more unorganized way of storing data. (Not the random that many think when the word random is said, but random meaning inserted anywhere there is a free slot.) RAM Random Access Memory. Hash goes into ram, it must be a random thing.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Dec 2004
Posts: 66
Babel fish
|
Babel fish
Joined: Dec 2004
Posts: 66 |
Maybe put the que in a hidden custom window? alias QueWin.Input {
if (!$1) return
if (!$window(@QueWin)) window -h @QueWin
aline @QueWin $1-
}
alias QueWin.Get {
var %QueLines = $line(@QueWin,0)
if (!%QueLines) return
var %Content = $line(@QueWin,1)
if (%QueLines == 1) window -c @QueWin
else dline @QueWin 1
return %Content
}
alias QueWin.Display {
if ($window(@QueWin)) window -aw @QueWin
else echo -ag The Que window is empty
}
alias QueWin.Hide {
if ($window(@QueWin)) window -h @QueWin
}
alias QueWin.Test {
clear -s
window -c @QueWin
QueWin.Input One blah
QueWin.Input Two blah
QueWin.Input Three blah blah
if ($QueWin.get) echo -s $v1
QueWin.Input Four blah
QueWin.Input Five blah
QueWin.Input Six blah
QueWin.Input Seven blah last blah
while ($QueWin.get) {
echo -s $v1
}
echo -s QueWin.Test finished
}
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
It may be that hash tables aren't the best option for what you are trying to do. Sorting just isn't really that great for hash tables. However, as DaveC mentioned, you can save the hash table to a file and /filter it, then back reference it to the hash table. This really isn't too difficult to accomplish and the code is somewhere in this forum if you search for it back 1-2 years or so for something like "sorting hash tables". In fact, I think DaveC may have been the one who posted the code.
Basically how that will work is you save the items only and include line numbers. Then filter it by whatever column you need (usually column 2 because column 1 is the line number and column 2 is the item). This lets you sort it by item name (give the items names that can be sorted in the way you want, such as que### (where ### is a number)). After sorting them, you call up the hash table using the line number.
Example:
Unsorted: Line# Item 1 que4 2 que3 3 que5 4 que1 5 que2
Sorted: Line# Item 4 que1 5 que2 2 que3 1 que4 3 que5
When you use $hget and the line number for the first item in the sorted list, you'll be looking up $hget(table,4) and you'll get que1's data.
Yes, it's extra work and it does require writing to a file and sorting it that way. So, for this case, using $read and /write may just be easier for what you're trying to accomplish.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Yeah i think i might have posted it.
What i find wierd is that i showed him how to fifo from a hashtable, and all it took was extra commands to retrieve/save the header and tail pointers. His write to file was replaced with 3 commands, whcih could have been 2 if i hadnt bothered to preallocate a variable a value i was using. His retrieve & delete from file (2 cmds), were replaced with 4, again one being a creating a var to use in the others,
So his 1 cmd became 2, and his 2 became 3, aka 1 extra command (namely the updating of the fifo pointers) hardly a taunting task to incoperate.
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
After closing my mirc and restarting it, it seemed to start working like the 3rd time. I don't know why this is, ever since i installed 6.2 lots of strange things keep happening. Even a buddy of mine is having trouble with an error "/write unable to open file, txtfile.txt" in some other script. When we've even checked that that file does exist in the right location surrounded by "'s. I try the script out on my machine (same mirc's) and it works fine but shows that error to his. Anyway, that bit of code did work eventually, however, when i merged it with the main project it's for, the que hash still thinks theres some entries and it continues to popup my window over and over until i manually type /hfree. I'd like to know where a good place would be to put in an hfree. using //echo -ag $hget(balloonque,0).item showed 2 items still existed in the que, those 2 are queEND and queDONE. here is the actual snippet of the actual project:
if ($window(@balloonnotice)) {
if ($ballooncfg(enableque) == 1) {
;write $balloonquefile $1-
var %queEND = $calc(1 + $hget(balloonque,queEND))
hadd -sm balloonque que $+ %queEND $1-
hadd -sm balloonque queEND %queEND
halt
}
}
if (!$window(@balloonnotice)) {
if ($calc($hget(balloonque,queDONE)) < $calc($hget(balloonque,queEND))) {
var %queDONE = $calc(1 + $hget(balloonque,queDONE))
var %balltitmess = $hget(balloonque,que $+ %queDONE)
hdel -s balloonque que $+ %queDONE
hadd -sm balloonque queDONE %queDONE
}
;if ($lines($balloonquefile)) { var %balltitmess = $read($balloonquefile,1) | ;write -dl1 $balloonquefile }
else { var %balltitmess = [ [ $1- ] ] }
;moves on to display the window show the info, then closes to run this again checking if anything still exists
I'm thinking if both equal each other then that should be the hfree part right? Edit: yeah adding the equals each other thing to hfree works, it works great. Thanks sorry I ever complained about your code.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
returns in this order: starting with $hget(quetest,1) - 3 I think you meant $hget(quetest,1).ITEM ,since there is no itemname "1" "2" or "3" created with in my code i doubt there would be any results. That looks semi random to me  You know that because you've scripted something? I'm sure hundreds have scripted something using hash tables, that possibly do the same thing you showed me. But it didn't work when I tried it and i'm not that fimilar with hash tables enough to try and solve the code myself. That's a long run-on sentance  . It might look random to you but they are being inserted into a table at specific points based apon there itemname and any previous entries that were inserted into the same slot based on there itemname before them. That is not random, it is a caluclated method, designed to allow the quick retrieval of them when there itemname is placed in the $hget(table,itemname). And I know this not only becuase my script shows the result of it, but also becuase i understand how the hashtable works, I have used hashing to index into records possably before you used a pc. you yourself admit you are not familar with them, which kinda shows up in your incorrect assumptions below. Hash tables do add randomly. they dont Random not meaning it picks out a slot on it's own, it does do that just the first free one. it doesnt do this Hash tables are stored in system memory correct? The RAM? RAM stands for Random access memory. Close enough to correct When available slots open in the ram area the data goes in. ram is not allocated in this fashion Hash's do the same thing. no they dont Suppose you add to a hash file, the item name: apple, you hget the first entry and it's apple. Then you add: orange, it may be the second entry. Add: banana it could now be the third entry. you remove orange from the hash table, that slot in the hash is freed. Doesn't seem very ordered  . Items stored in any free slot inside of 100 slots given no order to their storage = random. Sorry but your assumptions are wrong. Ok im going to show you how it actually works. /hmake ex 100101 slot table created slot numbers from 0 to 100 /hadd ex apple xitemname "apple" inserts into slot 97, $hget(ex,1).item = "apple" due to no other slots before 97 in use. /hadd ex orange xitemname "orange" inserts into slot 89, $hget(ex,1).item = "orange" ,2 = "apple" due to no other slots in use. /hadd ex banana xitemname "banana" inserts into slot 4, $hget(ex,1).item = "banana" ,2 = "orange" ,3 = "apple" due to no other slots in use. /hadd ex peach xitemname "peach" inserts into slot 38, $hget(ex,1).item = ,"banana" ,2 = "peach" ,3 = orange" ,4 = "apple" due to no other slots in use. This can be shown in this set of commands. //tokenize 32 apple orange banana peach | hfree -w ex | hmake ex 100 | hadd ex $1 1st | hadd ex $2 2nd | hadd ex $3 3rd | hadd ex $4 4th | echo -a $hget(ex,1).item : $hget(ex,2).item : $hget(ex,3).item : $hget(ex,4).itembanana : peach : orange : appleor using any combination such as peach apple banana orange the result well be the same. Now some people may ask what happens if two different itemnames happen to hash down to he same slot, well the slot is detected as having an entery in it already however each slot appears to infact be a linked list of entries, so any number of itemnames can appear in any one slot. How they are physically mapped into memory i have a feeling might be using uid's but as to the hashtable they appear in the order of the slot they are hashed too, followed by the order of items added to the slot. PS: the slot numbers mentioned above are the actual slot numbers of those itemnames, i didnt just make that up.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
//echo -ag $hget(balloonque,0).item showed 2 items still existed in the que, those 2 are queEND and queDONE. As it should thats the last DONE and END of queue markers, the values in them should have matched and the window stopped displaying. Is it possable something else in your script is adjusting these values., remeber the hashtable well/should always have these values, however the code below should alos remove them when they match.
if ($window(@balloonnotice)) {
if ($ballooncfg(enableque) == 1) {
;write $balloonquefile $1-
var %queEND = $calc(1 + $hget(balloonque,queEND))
hadd -sm balloonque que $+ %queEND $1-
hadd -sm balloonque queEND %queEND
halt
}
}
if (!$window(@balloonnotice)) {
if ($calc($hget(balloonque,queDONE)) < $calc($hget(balloonque,queEND))) {
var %queDONE = $calc(1 + $hget(balloonque,queDONE))
var %balltitmess = $hget(balloonque,que $+ %queDONE)
hdel -s balloonque que $+ %queDONE
hadd -sm balloonque queDONE %queDONE
if (%queDONE >= $calc($hget(balloonque,queEND))) { hfree -w balloonque | hmake balloonque 100 }
}
;if ($lines($balloonquefile)) { var %balltitmess = $read($balloonquefile,1) | ;write -dl1 $balloonquefile }
else { var %balltitmess = [ [ $1- ] ] }
;moves on to display the window show the info, then closes to run this again checking if anything still exists
Doh! just saw your last line ok so you dont it already!
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
OP
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Man, chill out. Dude, calm down. You have proved a point, I'm completely wrong. I do not know anything, you are smarter than I am. Come to think about it, you are since you know hash tables  . It's threads like this, that remind me why I continue to use mIRC. Yeah 92 was a good year to start pcing. Thanks again. So start flaming this post please cuz I'm not going to respond to it anymore. You helped me out, I thanked you. You got upset, and that's not what I wanted. If me continuing to post is going to upset you further I'm not going to continue. Again, sorry I doubted you.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
No i must aplogise to you, I had not had coffe before that post, not that that is an excuse, rather just the cause of my bad reply. I also didnt really form the reply overly well, as i was doing other things at the time, and wrote it over maybe an hour, I honestly read it now and would have replied to myself with "F U 2 Mr DaveC, U obnoxius git." Just as a matter of interest incase someone has opne this is how i worked out what slot things went into alias ex {
var %size = 100
hfree -sw ex | hmake -s ex %size
var %i = $calc(%size * 100) | while (%i) { hadd ex $+(itemname,%i) %i | dec %i }
exc
var %i = 1, %m = $calc(%size * 100), %s = 0, %l = 0, %c
while (%i <= %m) {
var %c = $line(@ex,%i) | if (%c < %l) { inc %s }
hadd ex $+(itemname,%c) $+(itemname,%c) $+(Slot,%s)
var %l = %c
inc %i
}
exc
}
alias exc { hsave -sn ex ex.txt | window -c @ex | window -e @ex | loadbuf @ex ex.txt } First run /EX this might take a second or two, the resulting @EX window shows the itemnameN on the itemnames and the slot they are in. Next you simple do a /hadd ex itemname_of_your_own itemname_of_your_own using itemdata the same as the itemname ie: /hadd ex apple apple Lastely run /EXC this makes a new @EX window find the itemname_of_your_own in the list and its the slot listed on the line above. * all it does is throw a big pile of itemname1 to N into a hashtable, then saves the data to a file, then to a window, it then works its way down that window baing the increment of the slot number loosly on the princible that the last number in the current slot well be higher than the first number in the next slot ie: ... slot0 - 123 slot0 - 567 slot0 - 999 slot1 - 256 slot1 - 333 etc All the /exc does is redisplay the window with the "APPLE" entery also in it stuck at the end of what ever slot it fell into.
|
|
|
|
|