Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find number within string
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00237774
Message ID:
00237913
Views:
13
>Hi Todd,
>
>>You may need to check more carefully to see if there is text between numbers and pull the numbers out seperately. Then again, you may not, and I may be wasting bandwidth :-)
>
>You are right. And as Ed said I'd simply modify the line. But instead of blanks I'd use CHR(13). Then I can use MLINE(), or in VFP 6 ALINES(), to loop through all numbers, skipping over empty lines. And just in case it might contain decimal numbers, I'd add "." and "-" to the set of characters that are not replaced.
>
I agree that including '-' and '.' are goo ideas, as long as numbers are well-formed. in the US, a ZIP+4 would cause confusing results, since the format is 99999-9999, but that's a decision the user has to make...

With whitespace in place, you can use the FoxTools WORD functions to strip out the results, or do something like the following once the whitespce is in place:
LOCAL aNums[1], nNumFound, cString, nPos
nNumFound = 0
cString = ALLTRIM(SourceLine)
DO WHILE ! EMPTY(cString)
   nNumFound = nNumFound + 1
   DIMENSION aNums[nNumFound]
   aNums[nNumFound] = VAL(cString)
   nPos = AT(' ',cString)
   IF nPos > 0
      cString = ALLTRIM(SUBST(cString,nPos))
   ELSE
      cString = ''
   ENDIF
ENDDO
Ed
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