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
Position command and comma??
Moderators: Dorian (MJT support), JRL
Try
Code: Select all
Let>strLine=blah blah blah), A. Fitzsimons (XX), C. Gannage (YYY)
Position>),%strLine%,1,dPos,FALSE
mdl>dPos
- andrewbarbour
- Newbie
- Posts: 14
- Joined: Thu Aug 26, 2010 7:09 pm
Thanks!
That works! Thanks
Rain wrote:TryCode: Select all
Let>strLine=blah blah blah), A. Fitzsimons (XX), C. Gannage (YYY) Position>),%strLine%,1,dPos,FALSE mdl>dPos
Re: Position command and comma??
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...
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:
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:
Take care
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...
...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:andrewbarbour wrote:I am looking to find the position of the "close bracket comma space" i.e."), "
Code: Select all
Let>strLine=b)lah blah blah), A. Fitzsimons (XX), C. Gannage (YYY)
Position>),%strLine%,1,dPos,FALSE
MDL>dPos
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
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:
- 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.
- 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?
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 -
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 -
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Another invaluable tip there jpuziano Thank you.
[Runs to scripts to replace all spaces with %SPACE%]
[Runs to scripts to replace all spaces with %SPACE%]
Phil Pendlebury - Linktree