Character problem within a variable.

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
miles.williams
Newbie
Posts: 14
Joined: Fri May 13, 2005 8:51 am

Character problem within a variable.

Post by miles.williams » Fri May 13, 2005 9:00 am

Hi guys, maybe you can help ..?

I have a macro that assignes the following to a variable %brief% :-

CFESJC02 has reported :- /usr/var/isis 94% full

When trying to pass this and other variables to another macro I am faced with a problem :

Macro>STKcreate.scp /impact=%impact% /brief=%brief% /msgtxt=%msgtxt%


The "/" characters in the variable %brief% aren't just being treated a meaningless text. I am assuming that MS is seeing :-

Macro>STKcreate.scp /impact=4 /brief=CFESJC02 has reported :- /usr/var/isis 94% full /msgtxt=load of message text

This is giving loads of pants errors. Is there a speech mark or bracket I can put round the var ?

Cheers.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri May 13, 2005 4:58 pm

Could not find a way to make the text pass specifically but this technique might work as a workaround to the problem.

//Instead of
//Let>var=/abc /cbs /nbc
//Use
Let>var=~abc ~cbs ~nbc
deletefile>c:\grouptestmacro.scp
//then do a StringReplace in the to-be-run macro
Writeln>c:\grouptestmacro.scp,result,StringReplace>%passvar%,~,/,newpassvar
Writeln>c:\grouptestmacro.scp,result,MessageModal>%newpassvar%
Wait>2
macro>c:\grouptestmacro.scp /passvar=%var%

Hope this is helpful,
Dick

miles.williams
Newbie
Posts: 14
Joined: Fri May 13, 2005 8:51 am

Cheers

Post by miles.williams » Wed May 18, 2005 2:03 pm

Thank you for the reply, there is a little problem though, although I think you might be on to something with the string replace command. The text that I am assigning to %brief% is literally that, variable, the text is being copied from an alarm monitor and as you can imagine these alarms are different all the time. Sometimes they don't contain these characters, somethimes they do. My thought is that (another workaround) I could write the text to a file and instead of passing it to the next macro, just get the macro to read it.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed May 18, 2005 2:21 pm

Can you use the stringreplace command to remove any slashes from the variable before it is passed to the macro? Then use the stringreplace comand within the macro to put the slashes back.

Hope this was helpful,
Dick

miles.williams
Newbie
Posts: 14
Joined: Fri May 13, 2005 8:51 am

stringreplace

Post by miles.williams » Wed May 18, 2005 2:34 pm

I am doing both, your idea and mine, to see which works better, not that I think there will be much (if any) preformance issues with a line or two of text. I had never seent eh stringreplace command before, it is really helpful, there is a few macros that I am going to pop back and adjust with this new found command, thanks, I appreciate your time and thoughts.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed May 18, 2005 2:43 pm

One more thought. Not that I have anything against writing to files, if you look at some of my posts you'll see I'm actually quite a fan of that process. But a self contained script is always my first choice.

Good Luck, let us know if you have success.

Later,
Dick

miles.williams
Newbie
Posts: 14
Joined: Fri May 13, 2005 8:51 am

vars

Post by miles.williams » Wed May 18, 2005 2:52 pm

I am in agreement with your, ideally I would just be able to surround the variable with bracket or character of somesort and it be ignored as possible commands and just treated as text. The reason I posted on here is because I like my scripts to be "tidy" 8)

Thanks again for your help.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu May 19, 2005 3:52 am


See this thread to see how I solved this problem:

http://www.mjtnet.com/forum/viewtopic.p ... highlight=

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 19, 2005 1:14 pm

adroege,

In your Feb. 23, 2005 post you said:
I don't have control over the data which is being read in, so
having the "/" characters is always a possibility. The only alternative
I can think of is to try to replace "/" with something else prior to
passing it as a parameter, however there is no "safe" character to
replace it with that might not already exist in the input data.

Any ideas? Or is there a way to make this limitation go away?
I just wanted to point out that you can replace your character with a string which would make it much less likely to exist in your input data. For example the "/" could be replaced by something like "~s~l~a~s~h~". How likely it is that a given odd text string will be produced in your data can probably be evaluated and controlled by you since you understand your data.

Hope this was helpful,
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts