Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining if a text string exists
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00386909
Message ID:
00386917
Views:
13
>What is the best way to determine if a text string is present anywhere in a field, memory variable or form property. I've looked at the strtran() and I'm not sure if this will do this.
>
>For example, say I have a memory variable called lctext that contains 'Settlement ATM June 30'. What code would I use to determine if the text string 'ATM' is located anywhere in that variable?
>

Presumption: cMemVar contains 'Settlement ATM June 30'

The '$' operator (eg 'ATM' $ cMemvar will return a logical .T.); this is a case sensitive compare operation (eg 'atm' $ cMemvar will return a logical .F.). The ATC() function will return a non-zero value if it occurs, indicating the starting position of the test string within the tested string, and is not case-sensitive (eg ATC('atm',cMemVar) returns a positive integer value).

If you need more robust comparison, look into the LIKE() function which provides some wild card matching ability, or the VBScript.RegExp automation object from the WSH which provides regular expression parsing capability.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform