I’m trying to simply change set a variables value depending on what segment is clicked in the segmented control but for some reason, it just keeps saying theSegment is not defined.
Here’s my code:
property social : false
property theSegment : missing value
on clicked theObject
if the name of theObject is "viewControl" then
set theSegment to (call method "selectedSegment" of "viewControl")
if theSegment is 0 then
set social to true
end if
end if
end clicked
it is most likely because your call method is failing. If a call method fails it doesn’t generate an error you will just get the error you are seeing that your variable isn’t defined. I would assume it’s because you aren’t referencing segmented control correctly Ex.
tell control "viewControl" of window "yourNameHere"
set theSegment to call method "selectedSegment" of it
end tell
but if all else fails you can do try this as well.
Dallas
property social : false
property theSegment : missing value
on clicked theObject
if the name of theObject is "viewControl" then
set theSegment to (call method "selectedSegment" of theObject)
if theSegment is 0 then
set social to true
end if
end if
end clicked