conditional checking

Posted by Ignis on Thu 09 May 2013 04:46 AM — 3 posts, 20,568 views.

#0
I've been setting up triggers to paste channels to a notpad window so that if I'm busy fighting and miss a message it's in another window to find instead of having to wade through scroll back. I'm familiar with vba to a certain extent but keep running into errors. The last channel I'm trying to get to append only shows a person's name and what s/he said.


<Name> the message that was sent

the only problem with doing a match on <*> * is that's also the format for most of the other prompts in game

<[892X] [7835H 13M] [14 Blood]> 


The one thing I do know is the line for that channel will never start with <[, so I tried doing a check but I keep getting an error I don't quite follow.

Here's what I've been trying:

if len(world.replace(%1,"[","")) = len(%1) Then
world.AppendToNotepad "Trigger", %0
end if


and the error I got as this:

Execution of line 1 column 33
Immediate execution
Expected ')'
Line in error: 
if len(world.replace([Crippled] [7835H 13M] [14 Blood],"[","")) = len([Crippled] [7835H 13M] [14 Blood]) Then


I tried adding in an extra ) at the 33rd character but that also didn't fix the issue, is there a way to make this script work? Also I think another issue here is not quite understanding replace and len as I've only really used those in excel/vba/ms office, is it possible to replace characters within a script the way i'm attempting to and then calculate the length of the string?
Amended on Thu 09 May 2013 05:02 AM by Ignis
Australia Forum Administrator #1
Can you paste the whole trigger?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


Looks like this is the issue:

Template:faq=32
Please read the MUSHclient FAQ - point 32.
#2
Ah, it took me a bit to understand, but yes, that was it!

Finished version:

<triggers>
  <trigger
   enabled="y"
   group="social"
   match="&lt;*&gt;*"
   send_to="12"
   sequence="100"
  >
  <send>If (len (World.Replace ("%1","[","",1)) = len ("%1")) Then
World.AppendToNotepad "Trigger: ", "%0" &amp; vbcrlf
end If
</send>
  </trigger>
</triggers>


the "Trigger: " was to get it to paste to the same notepad window as a few triggers I have that are "send to notepad(append)" instead of "send to script". I might work on converting the others to script as well to clean it up, but the one tip really did help.