Jump to content
Sign in to follow this  

Problem creating array from FileRead

Recommended Posts


My script opens a text file and grabs all of the information from it to a variable. The variable is correct that it shows all of the listed information. I am having a problem separating that information. I was trying to use Ubound but wasn't able to get that working.

What i would like for it to do, is take the first 3 sets of numbers and put those in the 3 columns then the next 3 numbers until its finished. the text file reads pretty easy





and so forth. Most of them will be less than 40 lines total. I know how to add multiple variables into a list item but im not sure how to actually separate these numbers into different variables from the text file.

here is the 3 lines i have so far, as everything i have tried hasn't worked so has been erased.

$var = FileRead($openwp_file)
MsgBox (0, "hi", $var)      
GUICtrlSetData($item1, $var)

i feel that i need to make an array, but i have found a few on the forums and cant seem to get them to work. $var[0][0] returns array errors and so i tried [1][10] to see if it would work for the reading of down the list. Every attempt has given me "Subscript used with non-array variable" errors. i have tried to declare the $var as a dim along with the [] numbers before hand also. Just not sure where to go with this and any help is appreciated.

Share this post

Link to post
Share on other sites

How about _FileReadToArray ??

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post

Link to post
Share on other sites

lol wow yea ill check it out sounds like it will work fine. thanks!

where on the wiki can i find info on that?

yea that worked thanks!

working code for someone searching. Out puts the line number and the value with that line.

Local $var
_FileReadToArray($openwp_file, $var)
For $w = 1 to $var[0]
MsgBox(0, "", $w & $var[$w])
If @error = -1 Then ExitLoop
Edited by peanutym

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this