Small Basic Forum

Full Version: random in a array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
the line of code 

lunghezza = Array.GetItemCount(contenuto) ' mi da' lunghezza = 0 ERRORE

give me a lunghezza equal zero = 0
Hi.  Shy

Could you explain in more detail what "contenuto" is equal to in this line of code?
contenuto = File.ReadContents(filePath)

contenuto = A
                   B
                   C

lunghezza = Array.GetItemCount(contenuto)

lunghezza = 0
File.ReadContents() doesn't automatically put each line in an array element.
If you put a TextWindow.WriteLine(contenuto) after the ReadContents you see all the lines.

If there are no empty lines in the file you can do something like:

for i=1 to 999 ' ' if there are not more then 999 lines in the file
contenuto[i]=File.ReadLine(filepath,i)
if contenuto[i]="" then
i=1000
else
lunghezza=i
endif
endfor
tank you - grazie mille