• 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: Extracting Script Library Text and/or Handler Calls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extracting Script Library Text and/or Handler Calls


  • Subject: Re: Extracting Script Library Text and/or Handler Calls
  • From: Takaaki Naganoya <email@hidden>
  • Date: Wed, 25 Apr 2018 10:49:27 +0900

I made such a script from another approach.

http://piyocast.com/as/archives/3209

(1) My script recognize each lexical elements by its color (So, this script
does not allow lexical color duplication)
(2) My script can process AppleScript bundle


I wrote this kind of script about 10 years ago (Mac OS X 10.4x era) to analyze
large AppleScript and plot with “MindMap”(Mindjet MindManager) application.

--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/


> 2018/04/24 13:02、Christopher Stone <email@hidden>のメール:
>
> Hey Folks,
>
> I've posted other methods of doing this using both AppleScriptObjC and the
> shell, but I was playing with do loops and wanted a familiar task to
> experiment with.
>
> Here's the result.
>
> Keep in mind this is a shell script and must be run as such.
>
>
> #!/usr/bin/env bash
> # ----------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2018/04/23 15:00
> # dMod: 2018/04/23 15:20
> # Task: List all handler calls in designated AppleScript libraries.
> # Tags: @Shell, @Script, @List, @Handler, @Calls, @Designated, @AppleScript,
> @Libraries
> # ----------------------------------------------------------------
>
> export LC_ALL="en_US.UTF-8"                 # Because the script uses utf8
> characters
>
> cd ~/'Library/Script Libraries/';
>
> for libFile in `'ls' -d *Lb*`               # Limits to libraries whose name
> contains 'Lb'
>     do
>         libText+="ˆ»»» $libFile --> Startˆ" # Marker for start of library
>         libText+=`osadecompile $libFile`    # Decompile the library
>         libText+="ˆ»»» $libFile --> Endˆ"   # Marker for end of library
>     done
>
> # Neaten up the extracted library text.
> libText=$(tr 'ˆ' '\n' <<< "$libText")       # To avoid interfering with
> library text containing "\n"
>
> # Comment this out to see the collated library text.
> libText=$( sed -En '/^on.+|^»/{ s!^on |»!!; s!^»!--!; p; }' <<< "$libText" )
>
> echo "$libText"
>
>
> It should work with any normal library script, but it won't handle things
> like Shane's BridgePlus library.
>
> That's why the “ls” command limits libraries found to these containing “Lb” —
> it's a simple filter to let me get only those libraries I want to extract
> handler-calls from.
>
> You'll need to change that for it to work on your system.
>
> On my system it's pretty fast — ±0.8 seconds to process 6 fairly large
> libraries.
>
> The advantage of this method is that I have more control over how the text is
> collated, and in this case I'm inserting markers to show the beginning and
> end of each library's handlers in the overall list.
>
> And that lets me pull a few tricks when I'm using them in various contexts.
>
>
> If I just wanted to yank out the handler calls and didn't care about marking
> the libraries, I'd do something more terse like this:
>
> #!/usr/bin/env bash
> # ----------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2018/04/23 15:00
> # dMod: 2018/04/23 15:20
> # Task: Terse -- List all handler calls in designated AppleScript libraries.
> # Tags: @Shell, @Script, @List, @Handler, @Calls, @Designated, @AppleScript,
> @Libraries
> # ----------------------------------------------------------------
>
> export LC_ALL="en_US.UTF-8"
> find ~/Library/'Script Libraries' -depth 1 -iname "*Lb*" -exec osadecompile
> {} \; | sed -En 's!^on !!p'
>
>
> I import all of my handler calls into Typinator for very quick and flexible
> searching, and this keeps me from pulling my hair out when I don't remember
> that exact handler name.
>
>
> On my own system where all the script libraries are created as script bundles
> with Script Debugger I use AppleScriptObjC to decode SD's backup RTF file
> embedded in each library.
>
> Why?  Because it's very, very fast.  :)
>
> I'll post this script separately soon.
>
> --
> Best Regards,
> Chris
>
> _______________________________________________
> 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





 _______________________________________________
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

References: 
 >Extracting Script Library Text and/or Handler Calls (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Extracting Script Library Text and/or Handler Calls
  • Next by Date: Re: Editor performance
  • Previous by thread: Re: Extracting Script Library Text and/or Handler Calls
  • Next by thread: Re: Editor performance
  • Index(es):
    • Date
    • Thread