mIRC Home    About    Download    Register    News    Help

Print Thread
#186314 20/09/07 08:46 PM
Joined: Sep 2005
Posts: 2,630
H
hixxy Offline OP
Hoopy frood
OP Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
Create a global binary variable, one that works like ordinary variables created with /set, so that we can use them outside of the scope of the script they were created in.

hixxy #186315 20/09/07 08:55 PM
Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641
Not a bad idea. I think bvars are destroyed automatically to help mIRC manage memory, and also to avoid shadowing issues with global and local binvar namespace.. Though the memory thing would not be much different from storing binary in hash tables, so there's no reason not to have the same behaviour built into binvars.

Getting back to hash tables though.. the following is a pretty simple solution:

set: /hadd -mb bvarStore &bvarName &bvarName
get: $hget(bvarStore, &bvarName, &bvarName)

Code:
alias bsave { hadd -mb bvarStore $1 $1 }
alias bload { noop $hget(bvarStore, $1, $1) }

alias testcase {
  ; set
  bset -t &hello 1 hello world
  bsave &hello
}

alias testcase2 {
  ; get
  bload &hello
  echo -a $bvar(&hello, 1-).text
}


hixxy #186316 20/09/07 09:18 PM
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Not sure if you know this already, but binvars are actually global, ie they are available everywhere for as long as the script is running. Regardless, persistent binvars would be handy, signed.

hixxy #186477 23/09/07 06:40 AM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
(Note: I'm just replying in general, not specifically to hixxy)

Signed. Love more binvar options.
(Oh god how I wish for binvar regex/regsubex ;x)


Link Copied to Clipboard