Triggering below a certain number?

Posted by Zeno on Sat 11 Oct 2003 06:07 PM — 5 posts, 17,428 views.

USA #0
If my HP drops below a certain amount, lets say 1000, is there a way to use a trigger to send a result, or would I have to use scripting? Either way, could I get some ideas how to get this set up?
USA #1
depends on what your prompt is...
but, for the hp youd use:
\d{1,3}
(this is as a regular expression)
that would match on 1 to 3 digits, which would be from 1-999

More info can be found at this thread (at the end it talks about not using scripting, just a regexp)

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=702
USA #2
What if the variable has a comma in it? Would that be treated as a extra digit?

Alright, I get this error:

Error number: -2146827838
Event:        Execution of line 1 column 1
Description:  Wrong number of arguments or invalid property assignment: 'CLng'
Line in error: 

Called by:    Immediate execution


Its:

if CLng (%1) < 5000 then
  Send "down"
end if

%1 is the first * in the trigger, which is HP.

[EDIT2] Hmm, looks like its having trouble with commas. How would I get this to work if the variable (HP) has commas?
Amended on Sun 12 Oct 2003 02:35 AM by Zeno
USA #3
Try:

if clng(replace("%1",",","")) > 5000 then

You have to place "" around things like %1 in commands used with 'send to script'. This is because VBScript would interpret the following like so:

%1 = Fred

becomes>

if Fred = "Fred" then ...

In other words the %1 directly substitutes in the script and VB thinks you are asking it to compare a VB 'variable' called Fred, not the value. In your case you are probably getting something like:

HP: 1,000

which VB turns into:

if Clng(1,000) < 5000 then

This 'would' work without the comma, since it is a number, but it isn't a good idea to get into the habit of expecting it to work. ;)
USA #4
Ah, yeah, just needed to allow it to see commas, I see. I got it working how I wanted it to, thanks.