www.ClassicTW.com
https://mail.black-squirrel.com/

Parsing dynamic variables
https://mail.black-squirrel.com/viewtopic.php?f=15&t=17402
Page 1 of 1

Author:  Skukkukt [ Thu Jun 15, 2006 7:22 pm ]
Post subject: 

I'm trying to write a twx script to send different commands base on a variable. Like this:

setvar $action "n1*yy"
send $twx_burst $action

The problem is, the $twx_burst command doesn't seem to translate the "*" as carriage-return. So it ends up sending just "n1yy".

Anybody know if it is possible to send a properly parsed text string to $twx_burst?

Skukkukt

Author:  Singularity [ Thu Jun 15, 2006 8:15 pm ]
Post subject: 

TWX doesn't have pipeline type constructs. $twx_burst, in the situation above, would be nothing more than a variable. In reality twx burst is nothing more than a send command wrapped in $b.

Just do this:
send "n1*yy"

If you need to embed a carriage return use #42.

Example:

if ($key = 1)
setVar $bursty "n1" & #42 & "yy"
else
setVar $bursty "n2" & #42 & "yy"
end
send $bursty

Author:  Skukkukt [ Thu Jun 15, 2006 9:08 pm ]
Post subject: 

The trouble seem to stem from the use of a dynamic variable. If the variable is set at compile time, the * char is translated into CR. But if the variable is set within script execution, that's when it doesn't work.

This works:

getInput $trigger "Enter trigger string "
setVar $action "qql10*c"
SetTextLineTrigger 1 :bang $trigger
pause
:bang
send $action

But this does not:

getInput $trigger "Enter trigger string "
getInput $action "Enter command to send "
SetTextLineTrigger 1 :bang $trigger
pause
:bang
send $action


Skukkukt

Author:  Skukkukt [ Thu Jun 15, 2006 9:43 pm ]
Post subject: 

So anybody know how to send a dynamic variable with embedded carriage returns?

Author:  RexxCrow [ Thu Jun 15, 2006 11:10 pm ]
Post subject: 

What about including a parsing engine (maybe as a sub-routine) that reads through the entered flying-burst/macro-variable and then internally replaces a codeID you choose such as '-' (or whatever) with a new '*' or with an " & #42 & " via the 'ReplaceText' command (RpelaceText $Action "-" "*" or ReplaceText $Action "-" "& #42 &")? This is all theory at this point as I have never actually tried something like that. If you try it maybe run a test to see if either work with a few quick lines.

Either that you might just have a pre-created list to choose from that includes varables to enter for amounts, sectors, times, etc. Perhaps the '*' is translated from the scripts prompt to the variables storage internally within TWX.

Author:  RexxCrow [ Thu Jun 15, 2006 11:20 pm ]
Post subject: 

As another alternative maybe using CutText and MergeText after identifying any CodeID's that are included in the variable and then using a sub-loop to splice them back together internally that also includes the CR. that should work perfect, but would be somewhat of a pain to code as you would have to rip apart your variable and then put it back together again with the newly included CR's in-correct order. Automated cut-and-paste is fun but not for the weak and weary! [:P]

Author:  Singularity [ Fri Jun 16, 2006 1:21 am ]
Post subject: 

Skuk, I just told you how to embed a carriage return using #42 as the ascii code. The usual
for CR is ^M or some use ~, I use ^M in all my macros. You can use * too if you want. Like...

getInput $trigger "Enter trigger string "
getInput $action "Enter command to send "
replaceText $action #42 "^M"
SetTextLineTrigger 1 :bang $trigger
pause
:bang
replaceText $action "^M" #42
send $action
halt

That way you can use ^M as the internal standard. Look at my macro utilities on grimy,
all of this is covered with complete examples, including a script that does exactly
what you're trying to do (why re-invent the wheel?).

Author:  Skukkukt [ Fri Jun 16, 2006 3:37 am ]
Post subject: 

Thanks Sing! That's exactly what I was looking for! And you are right, your script already does exactly the same thing, with more options. :) But I learned a trick I can use again!

Skuk

quote:Originally posted by Singularity

Skuk, I just told you how to embed a carriage return using #42 as the ascii code. The usual
for CR is ^M or some use ~, I use ^M in all my macros. You can use * too if you want. Like...

getInput $trigger "Enter trigger string "
getInput $action "Enter command to send "
replaceText $action #42 "^M"
SetTextLineTrigger 1 :bang $trigger
pause
:bang
replaceText $action "^M" #42
send $action
halt

That way you can use ^M as the internal standard. Look at my macro utilities on grimy,
all of this is covered with complete examples, including a script that does exactly
what you're trying to do (why re-invent the wheel?).

Author:  Wildstar [ Fri Jun 16, 2006 5:41 pm ]
Post subject: 

Or do what I do. Get someone elses script and call it yours. Or maybe just forget it because it is too hard.
Both alternitives work for me.....

But seriously...

You might want to look at some open source scripts that do close to what you want to do and try to replicate the action.
Just make sure you give credit where it is due.

Thanks to Alexio, Xide, Supg and Jhereg. They helped me out more than most know.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/