Hi
In my ASOBC script I have some code like the below, the property’s are bound to
text fields in IB and when a button is clicked the string values are retrieved and then
the next piece of code opens a scpt file from the main bundle, this works fine.
What I cant figure out is how to get the string values returned from the text
fields to the scpt file as variables, could some one please show me how?
script BMMAAppDelegate
property parent : class "NSObject"
---------------------------------------------------------------------
--- PROPERTYS
---------------------------------------------------------------------
property A : missing value
property B : missing value
on CreateWin_(sender)
set ENT to A's stringValue()
set ENT to ENT as string
-----
set ENW to B's stringValue()
set ENW to ENW as string
set posixPath to current application's NSBundle's mainBundle's pathForResource_ofType_("BMMANUAL", "scpt") as string
set scriptAlias to (posixPath as text) as POSIX file
run script scriptAlias
end CreateWin_
thanks for the reply’s guys, but im still not getting it, using the below called from the code above, or have i completely misunderstood?.
the rest of the scpt file runs fine apart from getting the variables across from the main script
to it, the variables are used in the scpt file like this
on BTFF()
--tried this & failed
set _WHeight to ENT's stringValue()
set _WWidth to ENW's stringValue()
set WSize3 to {_WHeight, _WWidth}
--tried this & failed
set _WHeight to ENT as string
set _WWidth to ENW as string
set WSize3 to {_WHeight, _WWidth}
--tried this & failed
set WSize3 to {ENT, ENW}
end BTFF
I thought i had using this, or do i need to do it a different way?
script BMMAAppDelegate
property parent : class "NSObject"
---------------------------------------------------------------------
--- PROPERTYS
---------------------------------------------------------------------
property A : missing value
property B : missing value
on CreateWin_(sender)
set ENT to A's stringValue()
set ENT to ENT as string
-----
set ENW to B's stringValue()
set ENW to ENW as string
set posixPath to current application's NSBundle's mainBundle's pathForResource_ofType_("BMMANUAL", "scpt") as string
set scriptAlias to (posixPath as text) as POSIX file
run script scriptAlias
end CreateWin_
If you have property A in your ASOC class, and you load a script that says something like “display dialog A”, the second A will reflect the value of the first.
thanks for your patience here Shane but i still cant get my scpt file to see the property from my main script, ive gone back to the beginning and started a new test app.
I must be doing something very wrong here, I have set up a new asoc app
with one button and one text field, created a script that is the below, and bound
button and text field in ib.
script property__a_to_called_scpt_AppDelegate
property parent : class "NSObject"
property b : "bob"
on TESTBUTTON_(sender)
set posixPath to current application's NSBundle's mainBundle's pathForResource_ofType_("TESTONE", "scpt") as string --FROM A SCPT FILE
set scriptAlias to (posixPath as text) as POSIX file
run script scriptAlias
end TESTBUTTON_
end script
I have then opened up script editor and added this code
display dialog b
saved the script as TESTONE.scpt , I have then manually added the script
to the Targets Copy Bundle Resource folder, build and run, click on button
no dialog saying bob, to test to make sure i had everything working fine I
put a display dialog “test” into the script built and ran again, dialog appeared,
So my scpt file is not seeing/getting the property b in my main script.