|
Joined: Feb 2007
Posts: 234
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2007
Posts: 234 |
im trying to write a script but it is limited by windows. Can this script be converted to use hash tables so it will work properly, no matter how much information is there, ie many #channels and tons of nicks.
alias -l list_chan {
set %fii %fii <b> $+ $network ( $+ $me $+ )</b><br>
var %a = 1, %b = $chan(0)
set %fii %fii <table>
while %a <= %b {
var %c = 1, %d = $nick($chan(%a),0)
while %c <= %d {
set %fiinick %fiinick <option> $+ $nick($chan(%a),%c).pnick $+ </option>
inc %c
}
;<option> </option>
set %fii %fii <tr><td><select size="8"> $+ %fiinick $+ </select></td><td><b> $+ $chan(%a) $+ </b> $&
<br>---Topic: $&
$chan(%a).topic $+ <br>---Mode: $chan(%a).mode $+ <br>---Key: $&
$chan(%a).key $+ <br>---Limit: $chan(%a).limit $+ <br>---Users: $&
$nick($chan(%a),0,a) <b>(@: $nick($chan(%a),0,o) $+ ;%: $&
$nick($chan(%a),0,h) $+ ;+: $nick($chan(%a),0,v) $+ )</b></td></tr><tr><td> </td><td> </td></tr>
inc %a
unset %fiinick
}
set %fii %fii </table>
return %fii
}
Last edited by MTec007; 03/02/09 11:16 PM.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
Limited by windows? Where exactly is the windows limitation here? Are you referring to mIRC windows or Windows as an operating system?
Either way, the only limitation I see here is that you're trying to fill html into a variable that can only hold up to 4096 characters (and ~800 chars prior to 6.35). This is not a "windows" limitation, it's a limitation in mIRC's script interpreter... Hash tables will not solve this problem-- you probably want to write this stuff to a file.
* On a sidenote, please cut up long lines in your code snippets because it makes this page impossible to read.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jul 2006
Posts: 4,222
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,222 |
It's certainly a typo, but the limitation of ~4096 characters appears in mIRC 6.32, not 6.35
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2007
Posts: 234
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2007
Posts: 234 |
regardless, it IS a limitation. why won't a hash table work? i thought that they could hold large amounts of data.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Hash tables can hold large amounts of data, but like normal (non-binary) variables, each item in the hash table has roughly the same limitation for the number of characters.
For what the OP appears to be trying to do, I would recommend using a binary variable, as each variable can contain a lot more information.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
I'd suggest /fopen for writing html before binvars-- firstly because it would be simpler to manipulate than a binvar but moreso because whatever ends up using it won't have to reparse the data 4096 bytes at a time through a binvar loop. Also it would ease the debugging process of being able to view an html file..
It would be interesting to know what in mIRC would be processing this? If it's not meant for mIRC to use, I'd say files for sure-- if it's being passed to some HTML dialog viewer DLL then maybe it's a different story (though any HTML viewer I know can just load up a file from a filesystem real easy).
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Feb 2007
Posts: 234
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2007
Posts: 234 |
im making a html web server that implements dynamic content like connections, channels etc, as one of the features. the problem with saving the information to a file is i have to load it right back into a var and send it through a socket.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
your server doesn't support serving static content from the filesystem? doesn't sound like much of a server to me.
in any case, if you used /fopen you would rewind the file handle (/fseek fh 0) and re-read (fread into a bvar) the contents which would be nearly efficient as direct memory access.
..or you could just write to a bvar directly..
point is, hash tables will serve little use here, this is not their purpose.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Feb 2007
Posts: 234
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2007
Posts: 234 |
the server does support files but in this case, the server is parsing though the file whilst sending it, and replacing a string, %_SERVERS_CHANNELS_% with what i am trying to do here. the whole procedure string from a sockread. this is almost what happens, its very hard to process in my head to write it here:
sockread -> alias to parse the file, make the replacement -> send file to browser
|
v
an alias to return the below information
|
v
a alias to call another alias on all connections
|
v
this problem alias, returns the information I want
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
I'm not entirely sure how useful this is going to be for you, but I've converted your script to use binary variables. alias -l list_chan {
bset -t &fii 1 <b> $+ $network ( $+ $me $+ )</b><br> <table>
var %a = 1, %b = $chan(0)
while %a <= %b {
var %c = 1, %d = $nick($chan(%a),0)
while %c <= %d {
bset -t &fiinick $calc($bvar(&fiinick,0) + 1) <option> $+ $nick($chan(%a),%c).pnick $+ </option>
inc %c
}
;<option> </option>
bset -t &fii $calc($bvar(&fii,0) + 1) <tr><td><select size="8">
bcopy &fii $calc($bvar(&fii,0) + 1) &fiinick 1 -1
bset -t &fii $calc($bvar(&fii,0) + 1) </select></td><td><b> $+ $chan(%a) $+ </b> $&
<br>---Topic: $&
$chan(%a).topic $+ <br>---Mode: $chan(%a).mode $+ <br>---Key: $&
$chan(%a).key $+ <br>---Limit: $chan(%a).limit $+ <br>---Users: $&
$nick($chan(%a),0,a) <b>(@: $nick($chan(%a),0,o) $+ ;%: $&
$nick($chan(%a),0,h) $+ ;+: $nick($chan(%a),0,v) $+ )</b></td></tr><tr><td> </td><td> </td></tr>
inc %a
}
bset -t &fii $calc($bvar(&fii,0) + 1) </table>
} Now you just need to decide whether a binary variable is appropriate for what you need to do.
|
|
|
|
Joined: Feb 2007
Posts: 234
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2007
Posts: 234 |
that works well for the channels i regular in, but if i try say, freenode/##php then it fails. this is turning out to be a lot harder than i had expected.
* Line too long: $bvar
alias -l new_servers_channels { bunset &fii &fiinick var %nsc = <b>Currently Active:</b><br><b> $+ $scid($activecid).network ( $+ $scid($activecid).me $+ ): $active $+ </b><br><br> list_all -> return %nsc $bvar(&fii,1,$bvar(&fii,0)).text }
Last edited by MTec007; 04/02/09 02:05 AM.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
That's because you're trying to return the entire value of the binary variable, but the entire point of binary variables is to hold large amounts of data that mIRC commands cannot usually interpret.
Instead, you should return the name of the binary variable, and then in the command where you actually NEED to use the data (ie. writing it to a file), then you can either parse the data in chunks, or something else depending on what you do with it.
It's hard to help you without seeing where you actually use the data.
|
|
|
|
Joined: Feb 2007
Posts: 234
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2007
Posts: 234 |
this is everything i've got that has to do with this info. the info gets sent via socket here: alias -l sendfilenext { var %queuespace = $calc(16384 - $sock($sockname).sq) if ( %queuespace isnum 1- ) { bread %sendfile %sendpos %queuespace &temp if (%sendfile == $pws_htdocs $+ imggallery.html) { brepbytes &temp $+(%,_IMG_GALLERY_,%) $new_img_gallery } sockwrite $sockname &temp inc %sendpos %queuespace if ( %sendpos >= $file(%sendfile).size ) { sockmark $sockname .remove $pws_temp $+ $sockname $+ .tmp .remove $pws_temp $+ $sockname $+ _c.tmp ;unset %sendfile %sendpos .timer 1 1 sockclose $sockname unset %inuse } else { aline @pws 4 %sendpos >= $file(%sendfile).size } } else { aline @pws 4 %queuespace isnum 1- } }
alias -l new_servers_channels { bunset &fii &fiinick var %nsc = <b>Currently Active:</b><br><b> $+ $scid($activecid).network ( $+ $scid($activecid).me $+ ): $active $+ </b><br><br> list_all return %nsc $bvar(&fii,1,$bvar(&fii,0)).text }
alias -l list_all { .scon -at1 list_chan }
alias -l list_chan { bset -t &fii $calc($bvar(&fii,0) + 1) <b> $+ $network ( $+ $me $+ )</b><br> <table> var %a = 1, %b = $chan(0) while %a <= %b { var %c = 1, %d = $nick($chan(%a),0) while %c <= %d { bset -t &fiinick $calc($bvar(&fiinick,0) + 1) <option> $+ $nick($chan(%a),%c).pnick $+ </option> inc %c } bset -t &fii $calc($bvar(&fii,0) + 1) <tr><td><select size="8">
bcopy &fii $calc($bvar(&fii,0) + 1) &fiinick 1 -1
bset -t &fii $calc($bvar(&fii,0) + 1) </select></td><td><b> $+ $chan(%a) $+ </b><br>---Topic: $chan(%a).topic $+ <br>---Mode: $chan(%a).mode $+ <br>---Key: $chan(%a).key $+ <br>---Limit: $chan(%a).limit $+ <br>---Users: $nick($chan(%a),0,a) <b>(@: $nick($chan(%a),0,o) $+ ;%: $nick($chan(%a),0,h) $+ ;+: $nick($chan(%a),0,v) $+ )</b></td></tr><tr><td> </td><td> </td></tr> bunset &fiinick inc %a } bset -t &fii $calc($bvar(&fii,0) + 1) </table> }
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
sendfile? bread? you said you weren't using files...
Your problem is the line:
return %nsc $bvar(&fii,1,$bvar(&fii,0)).text
As mentioned, the point of using bvars is to never directly access the data. You either want to simply return &fii or just know to read from &fii after calling that alias (the former case being the better design choice).
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Feb 2007
Posts: 234
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2007
Posts: 234 |
the sendfile part is not the same thing. i dont know, maybe this has been a waste of my time. thanks any way.
|
|
|
|
|