mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2022
Posts: 15
F
fusion9 Offline OP
Pikka bird
OP Offline
Pikka bird
F
Joined: Jan 2022
Posts: 15
I want to use a timer to write this to a text file. When I run this, I get the same dates, times and user counts each time. I've been kicking my own butt for a while now.

This echos perfectly:

Code
//echo -s $eval($date) $+ ,  $+ $eval($time) $+  , $+ $eval($nick(#mychan,0),1)

It gives me: 11/02/2023,15:37:04,140

//timerUserCount 0 3600 //write -N1 usercounts.csv $eval($date) $+ , $+ $eval($time) $+ , $+ $eval($nick(#mychan,0))

I've tried using $!time, etc, and I get the literal "$!time" written to the text file.

This sure looks like a "this should be really simple, but" question.

Thanks in advance!

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
In your first post, you were given a link into the wikichip site that had documentation for the things you were using there. Well the same site has documentation for this stuff too. The $+ does work if you use it correctly. When a script is created, the command placed into it is evaluated as it's created, and each time it's executed it tries to do the same thing. You should also be sure to click on the link in the right margin about MSL INJECTION, because that shows how it can be dangerous to put $1- into a timer if it contains a string that some other nick created. So if you create it like

//timerfoo 5 1 echo -a $time | timerfoo

that creates a string containing the time when the timer was created, and echoes it 5 different times. And the /timername command shows the command placed into the timer. Using $!identifier prevents the identifier from evaluating right now, and the '!' is removed from the command. However if that leaves behind something that's a valid identifier, that creates a command that evaluates each time the timer is triggered:

//timerfoo 5 1 echo -a $!time or $eval($time,0) | timerfoo

If you want the timer to echo the 5 letter word that begins with the dollar, then you need to create a string that won't evaluate then:

//timerfoo 5 1 echo -a $!!time or $!eval($time,0) but not $eval($time,0) | timerfoo

If you want to avoid a lot of complexity, it can be simpler to just create a custom alias, and then use

//timerfoo 5 1 aliasname

alias aliasname {
echo -a $time or $!time or $!!time | timerfoo
}


... and since this can't be identified, you can put normal type commands and identifiers inside the alias. And if you need to have parameters, you can pass them on the command line, as long as none of them will be other than a constant number of 'words' which would make it unpredictable what the alias sees $3 to be.

As I demonstrated above, you can immediately echo your timer's command line, with a shorter time interval, so you can see what's being created, which gives clues about why something isn't working right.

//timerUserCount 5 1 echo -s write -N1 usercounts.csv $!date $!+ , $!+ $!time $!+ , $!+ $!nick(#mychan,0) | timerusercount

A good test can be to find a network that lets you join a channel that's the length 1 string # to see how your scripts interact with it while your active channel is something else, due to the fact that # and $chan are the same thing. If you want to echo the # symbol, you don't want it echoing the active channel at the time you created the timer, and you don't want it to use the active channel at the time the timer executes, either:

//var -s %var $chr(35) | timerfoo 5 1 echo -a $eval(%var,0) vs %var vs $unsafe( %var ) | timerfoo

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Hello, using $eval($identifier) is the same as evaluating it one time, which is the normal thing to do with normal command, such as echo.

//echo -sg $date == $eval($date) $!date == $eval($!date)

Using $eval() without parameter or with 1 evaluation is just redudant.

Now in timer, using the $!ident format is actually correct:

//.timertest 3 1 echo -sg $!time

will display a different time every time, not sure what you did.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2022
Posts: 15
F
fusion9 Offline OP
Pikka bird
OP Offline
Pikka bird
F
Joined: Jan 2022
Posts: 15
How silly..

I realized the easy way to do this is to simply write a quick alias to write the into to the file, and have the timer call the alias.

Code
alias writeusers {
  if $me ison #mychan {
    //write -N1 usercounts.csv $date $+ ,  $+ $time $+  , $+ $nick(#mychan,0)
  }
}

The nice thing about this is that if I notice a user peak, I can simply type /writeusers to record it.


Link Copied to Clipboard