• 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
Re: Design Report for Scripts?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design Report for Scripts?


  • Subject: Re: Design Report for Scripts?
  • From: Yvan KOENIG <email@hidden>
  • Date: Fri, 20 Nov 2015 22:37:15 +0100

# Edited according to Stan Cleveland comments.

set theScript to (path to desktop as text) & "work in progress 1.applescript" as alias

set itsText to read theScript as «class ut16»

set theProperties to {}

set maybe to my decoupe(itsText, "property ")

repeat with i from 2 to count maybe
set maybe2 to my decoupe(maybe's item i, space)
if item 2 of maybe2 starts with ":" then
set end of theProperties to item 1 of maybe2
end if
end repeat
theProperties # List of declared properties

set theHandlers to {}
set maybe to my decoupe(itsText, linefeed & "on ")
repeat with i from 2 to count maybe
set maybe2 to maybe's item i
set dropIt to false
repeat with unwanted in {"run", "open", "idle", "quit", "reopen", "error"}
if maybe2 starts with unwanted then
set dropIt to true
exit repeat
end if
end repeat
if not dropIt then
set end of theHandlers to item 1 of my decoupe(maybe2, "(")
end if
end repeat

theHandlers # list of handlers

set theGlobals to {}
set maybe to my decoupe(itsText, linefeed & "global ")
repeat with i from 2 to count maybe
set maybe2 to maybe's item i
if maybe2 does not contain ", " then
if maybe contains space then
set end of theGlobals to item 1 of my decoupe(maybe2, space)
else
set end of theGlobals to maybe2
end if
else
# we have several globals in the same instruction
# must drop possible comments
set maybe2 to item 1 of my decoupe(maybe2, {" #", " --", linefeed})
# grab the list of globals available in maybe2
set theGlobals to theGlobals & my decoupe(maybe2, ", ")
end if
end repeat

theGlobals

#=====

on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe

#=====


For me it’s time to sleep.
Will be back tomorrow.

Yvan KOENIG running El Capitan 10.11.1 in French (VALLAURIS, France) vendredi 20 novembre 2015 22:33:22


 _______________________________________________
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: Design Report for Scripts?
      • From: Yvan KOENIG <email@hidden>
References: 
 >Design Report for Scripts? (From: "S. J. Cunningham" <email@hidden>)
 >Re: Design Report for Scripts? (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Help please
  • Next by Date: Re: Design Report for Scripts?
  • Previous by thread: Re: Design Report for Scripts?
  • Next by thread: Re: Design Report for Scripts?
  • Index(es):
    • Date
    • Thread