Ok, try this, i whipped it up to answer another Forum Question...
This is a string parser, if its not comented enough, just say and ill explain it.
`Opens the file to be read from
Open To Read 1,"gamedata.txt"
`DATA is in format
`[CLASS]
`Class,Name,Cost,amount of Attack,amount of Dexterety,amount of Strength,amount of Life,amount of Mana,amount of Stamina
` These two variables set the amount of items and their extent of effects for the array
`Eg, the number of items in the text file determines the value of no_of_items
`and the amount of different info for each item determines the value of no_of_variables
`so, if you had the item as Class,Name,Cost then no_of_variables would be 3.
no_of_items = 3
no_of_variables = 9
`This creates the array
Dim item_data$(no_of_items,no_of_variables)
`This initializes the item number
item_number = 1
Sync On : Sync Rate 0
Do
`Reads an entire line of information from the specified file into the string variable
Read String 1,string$
`Parses to see if its a description tag ([), a comment tag (`), a blank line or item data...
If Left$(string$,1) = "[" Or Left$(string$,1) = "`" Or Left$(string$,1) = ""
`This just stores the next line from the .txt doc into the variable
Read String 1,string$
Else
item$ = string$
Endif
`This initializes the values for the For...Next loop
b = 1
d = 1
If item$ = string$
`Parses to find each part of the info of the item
For a = b To Len(item$)
`Checks to see if there is a comma, if there is, then it goes onto the next array value and does the loop again.
If Mid$(item$,a) <> ","
item_data$(item_number,d) = item_data$(item_number,d) + Mid$(item$,a)
Else
b = a + 1
inc d
EndIf
Next a
`Prints the info to the screen
If item_data$(item_number,2) <> ""
Print "The ";item_data$(item_number,1);" '";item_data$(item_number,2);"';"
Print "Costs ";Val(item_data$(item_number,3));" Gold Pieces;"
Print "Adds An Attack Value Of ";Val(item_data$(item_number,4));";"
Print "Adds A Dexterity Value Of ";Val(item_data$(item_number,5));";"
Print "Adds A Strenght Value Of ";Val(item_data$(item_number,6));";"
Print "Adds A Life Value Of ";Val(item_data$(item_number,7));";"
Print "Adds A Mana Value Of ";Val(item_data$(item_number,8));";"
Print "Adds A Stamina Value Of ";Val(item_data$(item_number,9));";"
Print
Endif
`Increments the item number so each value goes into a seperate part of the array...
inc item_number
Endif
Sync
Loop
And here is what is in the gamedata.txt file feel free to edit it and change it and add things to it all you like, thats what its for...
`In format: Class,Name,Cost,amount of Attack,amount of Dexterety,amount of Strength,amount of Life,amount of Mana,amount of Stamina
[WEAPONS]
Weapon,Cracked Sword,50,12,2,0,0,0,0
Weapon,Hammer,5,3,0,1,0,0,0
[RINGS]
Ring,Thor's Ring,120,0,20,32,15,10,0
Hope I Helped...
PS if you need help using it, just post it and ill explain stuff to you
If Quizz's Are Quizzical, Then What Are Test's?
Check my profile for a quick test of knowladge...