Hi Matt

Piece of cake. Similar technique used for
http://fox.wikis.com/wc.dll?Wiki~DateOrdinal~VFP

Just pad the individual pieces to 1 longer than the longest piece with
a delimiter "~", so you can add that delimiter "~" to the input.

?INT(AT("DELETE~","VIEW~~~~~~ADD~~~~~~~EDIT~~~~~~DELETE~~~~APPROVAL~~CHNG_STAT~")/10)+1

I'd make a UDF out of it so you can maintain the string and the length
in one place. Something like...

?GetAccessPosition("DELETE")

GetAccessPosition.prg
LPARAMETERS m.tcAccessType
RETURN 
INT(AT(m.tcAccessType,"VIEW~~~~~~ADD~~~~~~~EDIT~~~~~~DELETE~~~~APPROVAL~~CHNG_STAT~")/10)+1

Mike Yearwood
Microsoft MVP 2008 - Visual FoxPro

> Message: 8
> Date: Wed, 22 Apr 2009 07:55:20 -0700
> From: "Matt Jarvis" <[email protected]>
> Subject: RE: position of item in a list
> To: [email protected]
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Alan Bourke
>> Sent: Wednesday, April 22, 2009 7:43 AM
>> To: [email protected]
>> Subject: RE: position of item in a list
>>
>> You still haven't told us how these strings are initially stored !
>>
>> is it :
>>
>> bigstring = ["A", "B", "C", "D"]
>>
>> or a Collection object containing string items?
>>
>
> It's a long story...   I am writing a program to change user access
> permissions to a 3rd party product we use here, because their interface
> is a total kludge-o-matic.
>
> I have a form method that has a user selected action choice being passed
> in (VIEW, ADD, EDIT, etc.). Based on this choice I was using a CASE
> statement to determine a starting position in a string to change. The
> string I am changing is a concatinated string of all the user choices
> i.e. "YNYY" means user permissions are VIEW, can't ADD, EDIT, DELETE,
> etc.)
>
> My case statement merely calculated which of the positions in the string
> I wanted to change:
>
> lcAcclvl = "YNYY"
>
> DO CASE
> CASE lcOption = "VIEW"
>  lnPosition = 1
> CASE lcOption = "ADD"
>  lnPosition = 2
> CASE lcOption = "DELETE"
>  lnPosition = 3
> ......
>
> lcNewString = stuff( lcAcclvl, lnPosition, 1, 'T')
>
> Now if I wanted to, I could do it this way:
>
> lcString = ["VIEW","ADD","EDIT","DELETE","APPROVAL","CHNG_STAT"]
> Alines(laStrings, lcString,0,",")
> lnIndex = Ascan(laStrings, [lcUserChoice])
>
> lcNewString = stuff( lcAcclvl, lnIndex, 1, 'T')
>
>
> Matt Jarvis
> Programmer/DBA
> King | Retail Solutions

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to