|
Post by Psycho on Jan 14, 2009 23:10:51 GMT -5
I'm not sure which function is causing the error but I narrowed down an example piece of code that works fine in Windows but yields the following error in Linux: Runtime Error in program 'untitled': #users, username$(m) Index out of bounds: 3 To test, I created a file in the public folder titled "users.txt" and put the following garbage entries into it: 2 My Name pass1 1 Another Name pass2 1 Where it should read the first line as the number of items for the dim statements, then input the actual values from the next 6 lines. Following is the code excerpt that produces the error: open "public/users.txt" for input as #users line input #users, numberofusers 'Set the variables to match the number of users dim username$(numberofusers) dim password$(numberofusers) dim adminflag(numberofusers) m=1 while eof(#users) = 0 line input #users, username$(m) line input #users, password$(m) line input #users, adminflag(m) m=m+1 wend close #users Using Ubuntu 8.04 John "Psycho" Siejkowski EDIT: As a side note, anyone using Linux should be able to figure it out but, the readme.txt file for starting RB in Linux still says "-cd to the rb101b3 folder" from the last beta.
|
|
|
Post by votan on Jan 15, 2009 14:37:35 GMT -5
Try to exchangewhile eof(#users) = 0 withwhile m <= numberofusers it should solve it for now. Have the feeling that eof is recognized within the third pass and not after the 2nd and so causes this error....
|
|
|
Post by Carl Gundel - admin on Jan 16, 2009 21:42:36 GMT -5
Here's an example of the program that also creates the file. Does this work on your machine? It works fine on my Ubuntu system. I changed the file name so it won't overwrite your file. open "public/myusrs.txt" for output as #users print #users, "3" print #users, "Fred" print #users, "foo" print #users, "1" print #users, "Steve" print #users, "arf" print #users, "0" print #users, "Tim" print #users, "tiny" print #users, "1" close #users open "public/myusrs.txt" for input as #users line input #users, numberofusers 'Set the variables to match the number of users dim username$(numberofusers) dim password$(numberofusers) dim adminflag(numberofusers) m=1 while eof(#users) = 0 line input #users, username$(m) print username$(m) line input #users, password$(m) line input #users, adminflag(m) m=m+1 wend close #users Also, do you realize that saving data into the public folder will allow people on the internet to look at the file if they know the name? The name users.txt is pretty easy to guess for hacker types. -Carl
|
|
|
Post by Psycho on Jan 16, 2009 23:01:43 GMT -5
Also, do you realize that saving data into the public folder will allow people on the internet to look at the file if they know the name? The name users.txt is pretty easy to guess for hacker types. -Carl Thanks for the advice on the public folder but I only set this file up in there for testing this issue. Normally it's tucked safely away in another folder As for the problem, I was about to list it as bizarre when I ran your code successfully, then pasted my code at the end of it only to get the same error. After much fiddling around, I created a new text file with the same info and it worked. Looking back, my test file was a stripped down version of my real file that had been copied from Windows . Despite being a plain text file there must be something different about from Windows because it wouldn't work for anything That being said, this one can be checked off as closed. Thanks for looking into it. John
|
|
|
Post by StefanPendl on Jan 17, 2009 6:22:22 GMT -5
Looking back, my test file was a stripped down version of my real file that had been copied from Windows . Despite being a plain text file there must be something different about from Windows because it wouldn't work for anything Plain text files are plain text files on any system, the problem is the EOL (End Of Line) character. - Windows ... CHR$(13) + CHR$(10)
- Linux ... CHR$(10)
- MAC ... CHR$(13)
More details at en.wikipedia.org/wiki/Newline
|
|
|
Post by Psycho on Jan 17, 2009 15:27:20 GMT -5
Looking back, my test file was a stripped down version of my real file that had been copied from Windows . Despite being a plain text file there must be something different about from Windows because it wouldn't work for anything Plain text files are plain text files on any system, the problem is the EOL (End Of Line) character. - Windows ... CHR$(13) + CHR$(10)
- Linux ... CHR$(10)
- MAC ... CHR$(13)
More details at en.wikipedia.org/wiki/NewlineWell, that certainly explains it Thanks Stefan.
|
|