Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Qbasic...strings and numbers 1

Status
Not open for further replies.

Xcalibur

Programmer
Aug 8, 2001
2
0
0
US
In a program I am working on I have to open a normal text file and load it into an array. Unfortunatly the text file I must work with has mixed data...both strings and numbers.

Example:
-----------------
1073741825 0 0 S
1 0 0 0d0+0 0d0+0
#OBJECTS
#1200
immortal board~
the immortal board~
Mystical sparkling colors converge here to form arcane runes...~
-----------------
I load everything in as string format...now is there any alternative way of loading or manipulating the strings to "extract" the individual numbers? (ie: "1 0 0 0d0+0 0d0+0" --> 1,0,0,"0d0+0","0d0+0")

Any help would be much appreciated, thanks!

-=X_calibur=-
 
It depends on what you want to do with the values. This little routine will simply parse them out and print them:[tt]
CLS
MyLine$ = "1 0 0 0d0+0 0d0+0"
NCount = 1
FOR R = 1 TO LEN(MyLine$)
ThisByte$ = MID$(MyLine$, R, 1)
IF ThisByte$ <> &quot; &quot; THEN
Tmp$ = Tmp$ + ThisByte$
ELSE
PRINT &quot;Number&quot;; NCount; &quot;: &quot;; Tmp$
NCount = NCount + 1
Tmp$ = &quot;&quot;
END IF
NEXT
IF LEN(Tmp$) > 0 THEN
PRINT &quot;Number&quot;; NCount; &quot;: &quot;; Tmp$
END IF
[/tt]
VCA.gif

Alt255@Vorpalcom.Intranets.com​
 
Thank you! It works perfectly for my purposes! =)

-=X_calibur=-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top