• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
OOP AppleScript and self-initialization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OOP AppleScript and self-initialization


  • Subject: OOP AppleScript and self-initialization
  • From: Kevin Muldoon <email@hidden>
  • Date: Fri, 08 Aug 2008 10:13:29 -0400

I have been experimenting with OOP and self-initialization in applescript. 

Below is a sample of what I believe to be an elegant way to create objects and have them initialize with one line as well as
having the object able to initialize itself. However, when my full code is implemented and the script is saved as an application, I can only run the app a few times before
a dialog stating "script doesn't understand fobj..." pops up. I suspect a memory issue but I set my obj's to null (thinking
I'm managing the memory) so I'm confused as to why this is an issue.

If there are AS/OOPers out there, please take a look and see if you can point me in the right direction. 

Thanks!

copy fobj(((path to desktop folder) as string) & "myfile.txt") to obj
obj's cp({location:((path to documents folder) as string) & "newname.txt", init:true})
set obj to null

on fobj(str)


script private


property _name : null
property _pathalias : null
property _creationdate : null
property _modificationdate : null


-- and continue defining many, many properties --


on initialize(args)
my populateProperties(iteminfo(args))
end initialize


on populateProperties(args)
-- pull data from args and populate all properties in script object 'private'.
end populateProperties


on iteminfo(args)
tell application "Finder"
-- pull recordlist of every property of the file object
end tell
end iteminfo


end script


private's initialize(str)


script public


on _name()
return (private's _name)
end _name


on _pathalias()
return (private's _pathalias)
end _pathalias


on _creationdate()
return (private's _creationdate)
end _creationdate


on cp(args) -- example: cp({location:((path to desktop folder) as string) & "joe.pdf", init:true})
do shell script "cp " & (quoted form of POSIX path of (private's _pathalias)) & space & (quoted form of POSIX path of (location of args))
if (init of args) then private's initialize((location of args))
end cp


end script
end fobj



-- 
Kevin Muldoon, Owner
TrueBlueDot - Fine Art Printing
New Haven, CT 06511
email@hidden
www.truebluedot.com
"Our pigment meets your imagination"



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: OOP AppleScript and self-initialization
      • From: Philip Aker <email@hidden>
  • Prev by Date: Re: Unicode Bad Characters
  • Next by Date: Rép: old AppleWorks script failing under 10.5
  • Previous by thread: Re: Sorting an array
  • Next by thread: Re: OOP AppleScript and self-initialization
  • Index(es):
    • Date
    • Thread