Need urgent help opening .txt files.
Posted: Tue Aug 20, 2013 4:45 pm
				
				Hello. I need urgent help. I need to edit my code by tomorrow so my program allows me to select a .txt document, open it, and place the text from the file in a text field.
The code I have below only opens up the .txt file called numbers on the desktop. I need to change it so it will allow me to open any document.
Help is hugely appreciated!
			The code I have below only opens up the .txt file called numbers on the desktop. I need to change it so it will allow me to open any document.
Code: Select all
global fileChoice
global listOfNumbers
global n
global numbers
on mouseUp
   readInData
   putDataInArray
   displaydata
end mouseUp
on readInData
      open file specialFolderPath("Desktop") & "/numbers.txt" for read
      read from file specialFolderPath("Desktop") & "/numbers.txt" until eof
      put it into listOfNumbers
      read from file file until eof
   close file fileChoice
   end if
end readInData
on putDataInArray
   local i // integer
   put the number of words in listOfNumbers into n
   repeat with i= 1 to n
      put word i of listOfNumbers into numbers[i]
   end repeat
end putDataInArray
displayData
