Page 1 of 1

the POS function

Posted: Tue Dec 22, 2009 7:11 pm
by Rick Graham
mytext$ = "abc^"

p = pos(mytext$,"^",1)
4.03 returns 4
4.16 and newer returns 0

p = pos(mytext$,"^^",1)
4.03 returns 0
4.16 and newer returns 4

bug or new feature???

Rick Graham

Posted: Tue Dec 22, 2009 7:21 pm
by Susan Smith
Rick,

My memory (which is often faulty) tells me that there was a feature addition to the POS command that involved the "^" character in order to tell the command that it was case-sensitive vs case-insensitive. If someone else remembers the details before I find them, please post. I'm almost on my way out the door for my birthday dinner! :)

-- Susan

Posted: Tue Dec 22, 2009 7:29 pm
by Susan Smith
From the 4.2 release notes that are linked to the main page of the wiki:

POS( str1$, str2$ [, {-}start] )

If str2$ begins with ^ then the ^ is stripped and the search becomes case insensitive. A configuration statement will permit use of a flag character other than ^.


Given the new POS and SRCH use of the "^" character, to search for '^' with "let X=POS(string$,'^',5)" you will need to either turn the search character off with CONFIG SEARCH_CHAR OFF or change the search character to something else as in CONFIG SEARCH_CHAR 7E (where 7E is the hexidecimal representaion of an alternate search character).

Rick, you mentioned that the problem is manifest in versions 4.16+. The feature is listed in 4.2. So I'm not sure what's going on there. But perhaps this gives you a lead anyway.

-- Susan

Posted: Tue Dec 22, 2009 8:00 pm
by Rick Graham
Thanks the help, I use the config option to turn if off.

pos(lwrc$(mytext$),"xxx",1) has always worked fine for me, so I really don't see a need for this "enhancement" !

I need to start using the Wiki more!!!

Rick Graham

Posted: Tue Dec 22, 2009 10:15 pm
by Rick Graham
you are right 4.2 only change for the POS function
Rick Graham

Posted: Wed Dec 23, 2009 8:49 am
by John
Susan - I was hoping to quickly update the POS article and leave just a blurb behind in the release notes about the enhanced functionality of POS, but I can not find the release notes of which you speak. All release notes are linked to from the Main Page, so I looked in the 4.2 release notes and didn't see the information. Could you please provide a url for the article you mentioned?

-John

Posted: Wed Dec 23, 2009 8:51 am
by John
oh never mind I found it! It was hiding under the combobox section. I'll fix it up later toady sometime.

-john

Posted: Tue Dec 29, 2009 8:23 pm
by Gabriel
Rick Graham wrote:Thanks the help, I use the config option to turn if off.

pos(lwrc$(mytext$),"xxx",1) has always worked fine for me, so I really don't see a need for this "enhancement" !

I need to start using the Wiki more!!!

Rick Graham
I think the syntax was mainly changed for the SRCH function, because you can't do lwrc$() on an array. It was probably added to POS as well for consistancy.

Gabriel

Posted: Wed Dec 30, 2009 8:38 am
by gtisdale
This caused me some problems to start with, but I like the idea. What I did for compatability was to use the following two lines. These are from my FNSNAP routine that was initially broken by the new feature:

43714 IF POS("^","^")<1 THEN !:
LET CHAROFF=1 !:
EXECUTE "config SEARCH_CHAR OFF" ELSE !:
LET CHAROFF=0

do a bunch of stuff

43975 IF CHAROFF THEN !:
EXECUTE "CONFIG SEARCH_CHAR 5E" !:
LET CHAROFF=0

43714 tests to see if the feature is active. If it is it turns it off and sets a flag. Then the function continues as it always had. At the end of the function, if the flag is set (true) then the feature is turned back on.

I had to do this because I was searching for the "^" character that I use as a place marker for FNPFKEYLINE and FNWINBUTTONS and the new feature made the "^" invisible.
FNGeorge

Posted: Wed Dec 30, 2009 8:48 am
by Rick Graham
if you are searching for "^" with the new POS function, use "^^"

Rick Graham