Position command and comma??

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
andrewbarbour
Newbie
Posts: 14
Joined: Thu Aug 26, 2010 7:09 pm

Position command and comma??

Post by andrewbarbour » Thu Feb 14, 2013 5:43 pm

I am trying to find the position of a substring in a string.

I am looking to find the position of the "close bracket comma space" i.e"), "

Let>strLine=blah blah blah), A. Fitzsimons (XX), C. Gannage (YYY)
Position>), ,strLine,X,dPos,FALSE

I get an "error in position command". It would seem like the comma is giving me greif.... any ideas??

thanks
Andrew

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Thu Feb 14, 2013 6:36 pm

Try

Code: Select all

Let>strLine=blah blah blah), A. Fitzsimons (XX), C. Gannage (YYY)
Position>),%strLine%,1,dPos,FALSE
mdl>dPos

User avatar
andrewbarbour
Newbie
Posts: 14
Joined: Thu Aug 26, 2010 7:09 pm

Thanks!

Post by andrewbarbour » Thu Feb 14, 2013 7:26 pm

That works! Thanks
Rain wrote:Try

Code: Select all

Let>strLine=blah blah blah), A. Fitzsimons (XX), C. Gannage (YYY)
Position>),%strLine%,1,dPos,FALSE
mdl>dPos

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Re: Position command and comma??

Post by jpuziano » Thu Feb 14, 2013 8:50 pm

Hi andrewbarbour,

It seems to work because yes... the % chars around %strLine% mean that the comma ' chars within your string are no longer being confused as parameter separators in the Position> command... however you said...
andrewbarbour wrote:I am looking to find the position of the "close bracket comma space" i.e."), "
...but that is not what is being found. You are only finding the position of the first ) char in your string. To prove that, run the code below:

Code: Select all

Let>strLine=b)lah blah blah), A. Fitzsimons (XX), C. Gannage (YYY)
Position>),%strLine%,1,dPos,FALSE
MDL>dPos
I added a ) char as the second char in your string and you will see the result is 2.

If you really want to find the position of the "close bracket comma space" i.e."), " then you need to use that as your search string however since the comma will be mistaken as a parameter separator, you have to use the same trick there too... run the following code and you will see that this will actually return the position value correctly:

Code: Select all

Let>strLine=b)lah blah blah), A. Fitzsimons (XX), C. Gannage (YYY)
Let>search_string=),%SPACE%
Position>search_string,%strLine%,1,dPos,FALSE
MDL>dPos
User Tip about any variable that ends in a space char:
Note the following line:

Let>search_string=),%SPACE%

Yes instead of %SPACE% I could have just typed an actual space char there however I prefer the above for two reasons:
  1. It is easy to SEE verses a real space which is invisible unless you have the cursor blinking there are the actual very end of the line.
  2. When you save your macro, Macro Scheduler "notices" all lines that end with a space and offers to clean them up for you by deleting the space. Normally you would say Yes and it would be fine however in this case, if it removed the space char, it would change the operation of your macro... so why take the risk?
i.e. take advantage of the %SPACE% system variable like I have above

Take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sat Feb 16, 2013 2:46 pm

Another invaluable tip there jpuziano Thank you.

[Runs to scripts to replace all spaces with %SPACE%]
Phil Pendlebury - Linktree

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