mIRC Home    About    Download    Register    News    Help

Print Thread
#118393 25/04/05 10:15 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
Code:
 alias DumpDB {
  write -c safedump.txt | set %start_time $ctime
  var %x = 1 | var %y = $lines(safedb.txt)
  while (%x <= %y) {
    write safedump.txt $read(safedb.txt,n,%x) $eval($read(safedb.txt,%x))
    echo -a unset -s $read(safedb.txt,n,%x) | unset -s $read(safedb.txt,n,%x)
    inc %x
  }
}  

And the safedb.txt is
%!next
%!time
%ask
%credits.ea
%exmode
%finish
%lag+ping
%nopsmsg
%ns.pass
%num
%nxt.qst
%oc.1
%read
%ltrivq blue lagoon
%trivia.status.cur
%tmp
%start
%time.allow
%time.between
%wins.voice
%voice
%wins.op
%counter
%querystring
%trivq
%start_time
Now only the first unset works but the write works fine and manually unsetting works
---
unset -s %!next
* Unset %!next
unset -s %!time
unset -s %ask
unset -s %credits.ea
unset -s %exmode
unset -s %finish
unset -s %lag+ping
unset -s %nopsmsg
unset -s %ns.pass
unset -s %num
unset -s %nxt.qst
unset -s %oc.1
unset -s %read
unset -s %ltrivq blue lagoon
unset -s %trivia.status.cur
unset -s %tmp
unset -s %start
unset -s %time.allow
unset -s %time.between
unset -s %wins.voice
unset -s %voice
unset -s %wins.op
unset -s %counter
unset -s %querystring
unset -s %trivq
unset -s %start_time
-
as you see the echo works but the actual unset only works once
-
Edit2: Another guy on undernet cant get any variables to unset

Last edited by Armada; 25/04/05 10:31 AM.
#118394 25/04/05 11:00 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
/unset is indeed buggy, but not because of the loop. It's because of the variable in $read(). Unlike /set, /unset is weird when you pass it an identifier that contains variables (I'm guessing it's somehow related to its ability to unset multiple variables). In your example, the variable %x inside $read() isn't even evaluated correctly. For example, this:

echo -a unset -s $read(safedb.txt,n,%x) | unset -s $read(safedb.txt,n,%asdflkjlg)

always unsets the first variable in the file. This also happens if you type it manually, outside of any loops. For some odd reason, $read(safedb.txt,n,%anythinghere) always returns the first line to /unset.

If you're interested in a solution, you can enclose $read() in [ ] to pre-evaluate it, so that /unset doesn't get to see the variable name or $read():
unset -s [ $read(safedb.txt,n,%x) ]

Edit: the reason $read() returns the first line isn't that odd after all: it's because the variable name (and not the value) is passed to $read(). When you pass $read() anything other than a number as N (in this case the string "%x"), it defaults to the first line. So /unset's problem in your case is that it doesn't evaluate %x at all.

Last edited by qwerty; 25/04/05 11:14 AM.
#118395 25/04/05 11:45 PM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
So then why does the echo itself work out?

#118396 26/04/05 01:00 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Because it's only /unset that's buggy, not /echo? :tongue:


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#118397 26/04/05 01:24 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
tooshay(sp?)
Edit:
This should go in scripts but since I have this already going
Code:
 
alias loopdb {
  var %x = 1
  var %y = $var(%*,0) {
    while (%x <= %y) {
      if ($eval($var(%*,%x),2) <= 49) {
        echo @Dump_DB $var(%*,%x) = $eval($var(%*,%x),2)
        .unset $var(%*,%x)
      }
      inc %x
    }
  }
}
 

It echos right but doesnt unset anything at all any clues why?
Edit2:
Well works now I put the [ ] around it but the if check seems to be buggy, I still have some variables that are under 50

Last edited by Armada; 26/04/05 01:45 AM.
#118398 26/04/05 01:31 AM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Quote:
tooshay(sp?)


" Touché ". smile


Link Copied to Clipboard