I/O - Reading Files using URL
Input - If you know the correct folder path and file name: This is good if you know the exact path and filename for your file
put URL ("File:C:/Users/example/scores.txt") into field "myData" - puts it into a scrolling field called "myData" or put URL ("File:C:/Users/example/scores.txt") into x - puts it into a variable called x
Works for any platform (PC/Mac/Unix/iOS/Android):This is better because it works on any computer system. Every computer system has a different place for your "Documents" LiveCode knows where that place is and refers to it as "specialFolderPath". This is especially good for cell phones because you probably do not know where documents are kept on them.
put URL ("File:" & specialFolderPath("Documents") & "/scores.txt") into field "myData" - puts it into a scrolling field called "myData" or put URL ("File:" & specialFolderPath("Documents") & "/scores.txt") into x - puts it into a variable called x
Input - Pick your own file to open - selecting a file Instead of specifying the file, you can allow the user to pick what file to use and where to find it
Any type of file:
This will open any type of file (even ones that you should not open)
local tFile answer file "Select the File to load:" put it into tFile if tFile is empty then exit mouseUp else put URL ("file:" & tFile) into field "myData" end if
Only CSV files:
Comma Separated Fields (CSV) are where commas are used to separate the pieces of data or information. Data bases use this
answer file "Select the File to load:" with type "Comma Separated Values|CSV" put URL ("file:" & tFile) into field "myData"
answer file "Select the File to load:" with type "text files|TXT" put URL ("file:" & tFile) into field "myData"
see the Dictionary for other file types
Binary Files:
|