I’m trying for the first time to use xCode and the problem I am running into is how to use a Position handler in the code?
How do I enter the on DisplayName (x,y) and how do I call it from the Xcode? I’m an extreme newbie. So If you know of any suitable video tutorials that define this that would be great.
Many Thanks
set xPress to "Matt"
set yPress to "Child"
my DisplayName(xPress, yPress)
on DisplayName(x, y)
display dialog x & " " & y
end DisplayName
as I mam just playing I was attempting to add a drop down box for label colour, add a load images button, and then a process button.
This is the script I’m using (that works)
try
set myFile to ((path to desktop as Unicode text) & "SelectedImages.txt") as alias -- alias
on error
set myFile to choose file name default name "SelectedImages.txt" default location (path to desktop)
end try
set resultFiles to (choose file with multiple selections allowed) -- list of aliases
-- clear existing contents of myFile
my write_to_file("", myFile's POSIX path, {_append:false, _class:«class utf8»})
repeat with f in resultFiles
set f to f's contents
-- append f's HFS path & return to myFile
my write_to_file("" & f & return, myFile's POSIX path, {_append:true, _class:«class utf8»})
-- set f's Finder label index to 2 (red)
tell application "Finder"
set f's label index to 2 --red
end tell
end repeat
on write_to_file(x, p, {_append:_append, _class:_class})
(*
anything x : anything to be written to output file
string p : POSIX path of output file
boolean _append: true to append data, false to replace data
type class _class: type class as which the data is written
*)
local fd
try
set fd to open for access (POSIX file p) with write permission
if not _append then set eof fd to 0
write x as _class to fd starting at eof
close access fd
on error errs number errn
try
close access (POSIX file p)
end try
error "write_to_file(): " & errs number errn
end try
end write_to_file
You’re trying to put the write_to_file() handler inside the pageMaker_() handler – you can’t do that in AppleScript. When you get a compile error, the first thing to to do is use Open with External Editor and try to compile it there.
Sorry in wrong order… kept shifting it thinking things were in the wrong place.
Now it builds without a problem, although I do have this
error?
2014-06-05 13:31:00.897 OpenpageApp[13415:303] *** -[AppDelegate pageMaker:]: write_to_file(): Can’t make current application into type «class fsrf». (error -1700)
Is this refering to the write actions I am trying to do?