function Pos(Substr: string; S: string): Integer

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
esuohlluf
Junior Coder
Posts: 41
Joined: Thu Mar 23, 2006 5:33 am

function Pos(Substr: string; S: string): Integer

Post by esuohlluf » Fri Mar 24, 2006 6:54 am

Having trouble with ;function Pos(Substr: string; S: string): Integer
Could you please show an example which displays a message of the integer result.

Thank You

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 24, 2006 7:04 am

Here you go:

Let>p={pos("world","hello world")}
MessageModal>p
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

esuohlluf
Junior Coder
Posts: 41
Joined: Thu Mar 23, 2006 5:33 am

Post by esuohlluf » Fri Mar 24, 2006 7:44 am

This is the code I had written
The line of text i was testing reads 374

Let>L=7
ReadLn>c:\Documents and Settings\User\Desktop\mousemove3.txt,L,line
Let>textstring=line
Message>%textstring%
Wait>3
Let>TestForX={Pos("",%textstring%)}
IF>TestForX>0
Message>yes
ELSE
Message>no
ENDIF

I used an example in help as a guide my message shows the teststring
but after the if my message result is always no, even if I test for "3"

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 24, 2006 8:40 am

Hi,

Works for me:

Let>textstring=374
MessageModal>%textstring%
Let>TestForX={Pos("",%textstring%)}
IF>TestForX>0
MessageModal>yes
ELSE
MessageModal>no
ENDIF

The issue could just be that you are using the NON-modal message box, so it does not wait for you to press ok and a subsequent message will override it.

Try the above example anyway, and you'll see the Pos command is working fine.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

esuohlluf
Junior Coder
Posts: 41
Joined: Thu Mar 23, 2006 5:33 am

Post by esuohlluf » Fri Mar 24, 2006 4:56 pm

Yes this code does work . For some reason my code with the IF and
ENDIF always produces a 'no' result.

I press the ok on the first message box which verifies for me that I
have the proper line and text from the file I read .
Then the second message box always came up 'no'.
I thought maybe there was a problem with the substring being .
Or with my IF statement.

Seems to be no cause for it.

Thank you

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 24, 2006 4:59 pm

Which version of Macro Scheduler are you running? Please check under Help/About.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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