We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
D'ont read a file
#1
In the following code there is a problem, it does not read the file for me.

Code:
Sub frasi_puoi_passare
max1a = 0
min1a = 1
numero_estratto1a = 0
' Chiedi il percorso del file
filePath1a = Program.Directory +  "/testidescrittivi/fileyes1.txt"
  ' Legge tutto il contenuto del file
  contenuto1a = File.ReadContents(filePath1a)
 
for i1a=1 to 999 ' ' if there are not more then 999 lines in the file
contenuto1a[i1a]=File.ReadLine(filepath1a,i1a)
if contenuto1a[i1a]="" then
i1a=1000
else
lunghezza1a=i1a
endif
endfor
 
 
  GraphicsWindow.ShowMessage(contenuto1a,"Contenuto")
 
' Calcoliamo la lunghezza della lista
'lunghezza = Array.GetItemCount(contenuto) ' mi da' lunghezza = 0 ERRORE
GraphicsWindow.ShowMessage(lunghezza1a,"LUNGHEZZA")
numeroCasuale1a = Math.GetRandomNumber(lunghezza1a - min1a) + (min1a - 1)
' Generiamo un indice casuale tra 1 e lunghezza
' Estraiamo l'elemento corrispondente
elementoCasuale1a = contenuto1a[numerocasuale1a]
' Mostriamo il risultato
GraphicsWindow.ShowMessage("Elemento estratto: " + elementoCasuale1a, "elemento")
EndSub


file:

Puoi passare,
Vai avanti,
Prosegui,
Non ti fermare
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)