For now, I have a file called Example.txt in my Documents folder. All that is in the file is a 6. As a for instance, how would I use Applescript to get that 6 and store it into a variable?
For example, something like
open Example.txt with read permission
set x to contents of Example.txt
:lol: (you know, why)
set x to read file ((path to documents folder as Unicode text) & "Example.txt")
or take a look at The Ins & Outs of File Read/Write in AppleScript
Alright, I have:
set y to read file ((path to preferences as Unicode text) & "example.txt")
which works fine. (all that is in example.txt is a 6)
However, it wont let me coerce that string into a number.
Later in the script I have return y * minutes for an idle handler, but I get the error “Can’t make “6” into type number”
How can i get that text into a number?
it does let you, but you also should do it
set y to read file (((path to preferences as Unicode text) & "example.txt") as integer)
I tried that and now I got “Cant make “Macintosh HD:Users…Example.txt” into type integer”
where “…” is the full path to the file.
sorry, wrong parentheses
set y to (read file ((path to preferences as Unicode text) & "example.txt")) as integer
I’m still getting “Cant make “4” into type integer.”