Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transforming string representation
Message
From
04/10/2001 10:49:10
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00564145
Message ID:
00564173
Views:
30
This is the most simple and works for one mumber only. You might want to continue loop and change position to get next numbers in string and convert them too.

>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.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform