Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transforming string representation
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00564145
Message ID:
00564167
Views:
22
Something along those lines. I haven't came up to the simple algorithm yet, so yours may help.

>Hi!
>
>Probably this will require to extract numbers from the string:
>
>
>str="PRICE<=5000000"
>llNotFound = .T.
>lnPos = 1
>do while llNotFound
>  lnNumPos = at('~',chrtran(str,"0123456789.-+,","~"),lnPos)
>  if lnNumPos=0
>    return str && no numbers in string
>  endif
>  if substr(str,lnNumPos-1,1) $ "<>=#!( ,;:'"+'"' && all characters that ccans separate number, for
>                                 &&example, to distinguish "Alpha225" variable from "=225"
>    llNotFound = .F.
>  else
>    lnPos = lnPos +1
>  endif
>enddo
>lnNumPosEnd = lnNumPos
>do while substr(str,lnNumPosEnd,1) $ "0123456789.-+,"
>  lnNumPosEnd = lnNumPosEnd + 1
>enddo
>return left(str,lnNumPos-1) + PreFormat(val(substr(str,lnNumPos,lnNumPosEnd-lnNumPos+1))) + substr(str,lnNumPosEnd)
>
>
>PreFormat - is your function to pre-format a number to your desired user-friendly format.
>
>Is that what you meant?
>
>>>Hi!
>>>
>>>Nadya, uaually I do this from another way - build a string the way tyhat it is represented correctly. In my filtering controls I have 2 methods. First is to gather comparison expression from all filtering controls to apply filter. Second - to gather the same, but in user-friendly form. This way you will not require to invent complex string processing, just build it by 2 ways - filtering control returns required string on request ;)
>>>
>>>Above you can also replace "control" by "code fragment" that responsible for generating filter expression.
>>
>>Actually, you're right and I even have these methods already. But neverless, this would be an interesting string problem to solve :)
>>
>>
>>>>Hi everybody,
>>>>
>>>>I have a form, where the user can make selection criteria. On this form I have a button, which says: "Show criteria".
>>>>If I have this kind of criterion, for example, PRICE<=5000000, I'm thinking about presenting it as PRICE<=$5,000,000. My question is: how can I perform such string modifications? As you understand, I return each criterion as a string lcCrit, so it might be "between(price, 100,1000000)" for another example.
>>>>
>>>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform