the POS function

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Post Reply
Rick Graham
Posts: 45
Joined: Sun Jun 07, 2009 10:50 pm

the POS function

Post 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
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post 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
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post 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
Rick Graham
Posts: 45
Joined: Sun Jun 07, 2009 10:50 pm

Post 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
Rick Graham
Posts: 45
Joined: Sun Jun 07, 2009 10:50 pm

Post by Rick Graham »

you are right 4.2 only change for the POS function
Rick Graham
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post 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
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

oh never mind I found it! It was hiding under the combobox section. I'll fix it up later toady sometime.

-john
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post 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
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post 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
Rick Graham
Posts: 45
Joined: Sun Jun 07, 2009 10:50 pm

Post by Rick Graham »

if you are searching for "^" with the new POS function, use "^^"

Rick Graham
Post Reply