Small Basic Forum
random in a array - Printable Version

+- Small Basic Forum (https://litdev.uk/mybb)
+-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1)
+--- Forum: Standard Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=2)
+--- Thread: random in a array (/showthread.php?tid=580)



random in a array - francesco - 03-27-2026

the line of code 

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

give me a lunghezza equal zero = 0


RE: random in a array - AbsoluteBeginner - 03-27-2026

Hi.  Shy

Could you explain in more detail what "contenuto" is equal to in this line of code?


RE: random in a array - francesco - 03-29-2026

contenuto = File.ReadContents(filePath)

contenuto = A
                   B
                   C

lunghezza = Array.GetItemCount(contenuto)

lunghezza = 0


RE: random in a array - WhTurner - 03-29-2026

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