View unanswered posts | View active topics It is currently Thu Apr 30, 2026 7:55 pm



Reply to topic  [ 9 posts ] 
 Parsing dynamic variables 
Author Message
1st Sergeant

Joined: Wed Feb 28, 2001 3:00 am
Posts: 31
Unread post 
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


Thu Jun 15, 2006 7:22 pm
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 
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

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Thu Jun 15, 2006 8:15 pm
Profile ICQ WWW
1st Sergeant

Joined: Wed Feb 28, 2001 3:00 am
Posts: 31
Unread post 
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


Thu Jun 15, 2006 9:08 pm
Profile
1st Sergeant

Joined: Wed Feb 28, 2001 3:00 am
Posts: 31
Unread post 
So anybody know how to send a dynamic variable with embedded carriage returns?


Thu Jun 15, 2006 9:43 pm
Profile
Captain
User avatar

Joined: Sat Jun 18, 2005 2:00 am
Posts: 2214
Location: USA
Unread post 
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.

_________________
Your reliance upon subjective IRM's, subjugates you through utter omission, obfuscation, and distortion of fact!
Don't mess with me, I will 26 U.S.C. § 7212(a) your IRS!


Thu Jun 15, 2006 11:10 pm
Profile ICQ WWW
Captain
User avatar

Joined: Sat Jun 18, 2005 2:00 am
Posts: 2214
Location: USA
Unread post 
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]

_________________
Your reliance upon subjective IRM's, subjugates you through utter omission, obfuscation, and distortion of fact!
Don't mess with me, I will 26 U.S.C. § 7212(a) your IRS!


Thu Jun 15, 2006 11:20 pm
Profile ICQ WWW
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 
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?).

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Fri Jun 16, 2006 1:21 am
Profile ICQ WWW
1st Sergeant

Joined: Wed Feb 28, 2001 3:00 am
Posts: 31
Unread post 
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?).


Fri Jun 16, 2006 3:37 am
Profile
Lieutenant

Joined: Fri Apr 05, 2002 3:00 am
Posts: 580
Location: USA
Unread post 
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.

_________________
My scripts can be downloaded at http://www.grimytrader.com/.
Ore *****.
Even in my signature it's blocked out.


Fri Jun 16, 2006 5:41 pm
Profile ICQ YIM
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: Google [Bot] and 27 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.