New version of ASObj-C database version a14

I uploaded a new version of the ASObj-C database, ASObj-C Database a14.fmpur.zip, to Dropbox. The download link is:

The ASObj-C Database a14.fmpur.zip has a TextEdit copy of the database help file and a TextEdit copy of the database glossary for anyone who wants to look at them.

For anyone who doesn’t have copy of the app to run the file it is uploaded to dropbox. The download link is:

I was inspired by something Jim wrote and I included a much more advanced sample that show how to use spotlight metadata directly from a script. It is one of my favorite things to do with ASObj-C. The script is pretty simple to use. You tell the script where to search for files and what to search for in those files. That’s it. The actual samples are the latest additions to the database with creation dates of 1/14/2017. The creation dates can be seen from the class items window.

Most of the new stuff is from something I call the “Inheritance path windows.” I just copied some things out of the help to explain this.

All classes in ASObjective-C inherit from NSObject. A subclass is a class that takes somethings from it’s parent, and for the rest the subclass creates new things or redefines things that are in the parent class. The original parent class is called a super class of of the newly defined subclass. An inheritance path is all the unique paths starting at NSObject and ending at some unique subclass where that class has no subclasses.

The reason this is of interest is because when figuring what a class can do it is not enough to read the documentation about a class. The superclass of the class in question would be passing on things to the class in question through inheritance. But the same is true of the superclass of the superclass all the way up to to NSObject. Knowing what all the classes in the inheritance chain do from the class being used up to NSObject give the scripter the greatest power when working with ASObj-C.

The first new window is called “Display Inheritance Path”
With this in mind there are two different windows in the database that deal with these inheritance paths. The “Display Inheritance Path” window is designed to give someone a quick overall summary of what is available for ASObj-C. There are class names down the left side of the window. Each time a class is a subclass, of the class listed directly above it, the line with the subclass is indented. To the right of this vertical list is the beginning of a short description of what each class does. The classes with not documentation has the class name grayed out.

With the class name and class description on the same line it gives a quick overview of all the classes. Clicking the class name in the far left column will bring up the full text of the short class description at the bottom of the screen. If you do an “Edit” menu “Copy” both the class name and full short description are copied to the clipboard.

This layout in the database does not have a live search because removing class names from the list would nullify the display of the class structure. Also the usual “Show All,” “Show Omitted,” and “Omit Record” in the upper left corner of the window are not present for the same reason. In the upper right of the window there is a “Search Inheritance path” button that brings up a standard search dialog which allows the “class list” and “descriptions” to be searched. The “Same search again” button just repeats the last search. The text of the previous search is shown above the button.

The advantages of this approach is the inheritance chain can clearly be seen and there is information about what the classes themselves do. The disadvantage of this approach is that it is not as straight forward as the second approach.

The second is new window is called “Search inheritance paths”
This search is a different way to search the inheritance path. It is more straight forward in its use but because of the way it is laid out summaries of what the classes do can’t be displayed in this layout. In this search there is a live search. To use this search just type the name of the class name you are working with and unwanted inheritance paths will disappear with each key press until you have the desired inheritance path. As with the “Display inheritance paths” layout the indents in “Search inheritance paths” also indicates subclasses. But in this layout the entire inheritance chain is listed from NSObject down to the class being looked at for each line in the window. So as parts of the list disappear the inheritance paths are still preserved.

I did these two window after discovering just how hard it is to find a complete list of classes and showing subclasses.

Other then the two search windows I added some more to the glossy. There are now 73 words in the glossary. The only thing left to do for the Alpha part is the actual search keys for the database so people don’t have know what they’re looking for before they can find it.

Right now the other big things is comments from anyone about the database. Complaints and things that are liked are both helpful. The more input I get the better the database.

Bill

@BillKopp, I have downloaded Ver A16, and the FMP Runtime.
But when I double-click on either the DB or the FMP R/T, I get this error:

Is there a special install/setup process I need to use?

I think the database file needs to be in the same folder as the Runtime app.

OK, Bill, so here’s the question that I have for your database.

Let’s just say that I wanted to write the script below from scratch, without all the experienced Scripters hand feeding me all those great commands.

Lets just say I was wondering "Is there a way via ASObjC to:

  • Get the system version and build
  • Get an application’s version and build
  • Find and replace text in a string

If I didn’t know you or Shane or anyone else, and didn’t know already where to look, how could I use your database to help me learn how to write that script?

use scripting additions
use framework "Foundation"
use framework "AppKit"
------------------------------------------------------------------------------
-->Script Debugger 6.0.4 (6A198) on Mac OS 10.10.4 (14E46)
set fileNameFormat to {"Copy SD ", "version and", " OSX ", "version"}
set appName to "SD"
set appId to "com.latenightsw.ScriptDebugger6"

set appNSURL to current application's NSWorkspace's sharedWorkspace()'s URLForApplicationWithBundleIdentifier:appId
set appBundle to current application's NSBundle's bundleWithURL:appNSURL
set appName to (appBundle's infoDictionary()'s objectForKey:"CFBundleName") as text
set appVer to (appBundle's infoDictionary()'s objectForKey:"CFBundleShortVersionString") as text
set appBundleVer to (appBundle's infoDictionary()'s objectForKey:"CFBundleVersion") as text
set sysVer to (current application's NSProcessInfo's processInfo()'s operatingSystemVersionString())
set sysVer to (sysVer's stringByReplacingOccurrencesOfString:("Version") withString:"Mac OS")
set sysVer to (sysVer's stringByReplacingOccurrencesOfString:("Build ") withString:"") as text
set infoString to appName & space & appVer & " (" & appBundleVer & ") on " & sysVer

set the clipboard to "-->" & infoString
set newFileName to "Copy " & infoString

set thisScript to path to me as alias

--Unnote next line and run script to set script name back to default
--set newFileName to fileNameFormat as text

tell application "Finder"
	set oldFileName to the name of thisScript
	if "Unsaved Script Debugger Document" is in oldFileName then return
	if "Untitled" is in oldFileName then return
	set nameExt to the name extension of thisScript
	set newFileName to newFileName & "." & nameExt
	if oldFileName is not newFileName then set the name of thisScript to newFileName
end tell

return the clipboard

BTW, Installed the new version and am toying with it

I’ll tell you how I learned to use ASObj-C effectively. It has a lot to do with 1 very special web site, a number of Objective-C books and using google translate. But my goal is save other people having to go through what I did. I am hoping other people can help me figure out how to best teach this to other people.

One of the best site for ASObj-C source code is a sites at http://piyocast.com/as/

This site has by far the most ASObj-C examples. They don’t explain a lot but they have great examples. The problem is it is a Japanese site. All the comments are in Japanese, some variables names are using Japanese names so I suspect a lot of people don’t use the site that do know about it.

But I am a heavy user of google. So knowing how Google translate works is a big help for me. I’ll explain it but at first it will sound complicated. But it you try it, it gets easier.

If you can’t figure out something go to http://piyocast.com/as/ scroll down the page until you hit the search box. It is just above a long list on the right side of the page called Categories.

All the ASObj-C scripts use english for the ASObj-C language syntax. But comments and a few other things are in Japanese. So you can only search for words in the ASObj-C language. Using the search will find all pages of that contain the ASObj-C terms you are looking for. Sometimes it’s a lot, sometimes just a few and sometimes nothing. When it’s a lot I use google to search the site to narrow down the number of search hits. A single site can be searched in a very powerful way by using advanced google search syntax. That is a huge subject in itself so I can’t list all the things that can be done. But a good start is to include somewhere on the search line you’re typing:

site:piyocast.com

After typing that part you just type out other google search terms specific to your search just like a normal google search. This does a regular google search but only on the site specified. The search results usually have a a translate and if you click it usually trans the Japanese part to english. While this does not teach a person how to use ASObj-C it is a huge help as far as how to use the syntax.

What I did to learn about ASObj-C syntax involved a lot of stuff but one of them was translating pages on the piyocast.com site. Sometimes I can just go to google translate at https://translate.google.com/?hl=en and enter the url of a page in the box on the left if google does have a translate button in the search results or did the translate incorrectly.

Entering the search search source URL in the left box then Google default to guessing the source language and the same URL appears in the right side. Clicking the blue Translate button over the box on the right causes Google to translate and display the specified source page. But google often guesses the source language wrong and then displays a web page saying “The page you have attempted to translate is already in English.” even thought it has Japanese all over it.

When this happens I just go back to the google translate page at https://translate.google.com/?hl=en and click the “Detect language” popup and select Japanese from the choices that come up. This works nearly all the time.

If you still get “The page you have attempted to translate is already in English.” after manually selecting Japanese then I go back to the translate page, copy some Japanese text from the web page and past that Japanese into the box on the left side. The english translation comes up in the box on the right. This always works.

The translation I get from using google are good enough that I can figure out what is being done. Doing this one thing will give you far more help then just typing google terms straight in to google and not specifying a site. This is how I figure out the syntax.

To figure out how the language works I have 19 ebooks on Objective-C. This helps me figure out what the various classes do, good things to use to solve all kinds of different kinds of problems.

So in short I learn the syntax from piyocast.com and I learn how ASObj-C work by learning about Objective-C and adapting. There are a lot of Objective-C book that teach how to use the language and many lesson learned from those book help me figure out ASObj-C. The down side is there are a lot of things I learn about Objective-C that I din’t need to learn.

This is a tedious way to learn and that is why I decided to publish what I learned in a database. You can try some, all or none of what I just described but I am happy to help anyone who needs help. But it required about of year of work before I started to be able to produce any truly useful scripts. After 2 years I write all kinds of useful scripts.

Bill

If your database is going to be something I want to use and would use, it would save me having to do any of that. Rather than going to google and search for sites or look up stuff not written for ASObjC on the Apple Web page, or go to a Japanese web page, etc., etc.

If your data base is going to be useful to someone like me, it will spare me (and other appleScript users) all of that. If I still have to do that to make sense of the data base, I won’t be interested.

As it is, when I want to use it to figure out something useful, I get nowhere.

I appreciate your comments. This time you were more specific then in the past. I keep adding stuff to the database to make it more useful but I haven’t given enough thought to the user being able to apply the knowledge. You are far more adventuresome then the average Apple Scripter. If I can’t keep you interested then I’m in trouble. I have been focusing on better database searching to find what the user is looking for. But you are talking about designing a script given the constraints and advantages of ASObj-C. Nothing in the database shows what the weaknesses are, it doesn’t do a good enough job of showing the advances in a well rounded way. Probably the biggest omission is it does nothing to help someone understand the thousands and thousands of method, properties, … that a scripter has to pick from. Shane’s book only addresses a small part of this.

This is not something that even the Objective-C books do very well. The people who work on figuring out this kind of stuff are computer science researchers. I haven’t really looked into this area. Perhaps I should. What makes ASObj-C special. What is the actual “fundamental” differences between Objective-C and ASObj-C. What can ASObj-C do, what can’t it do. What is it the best at, and what is the worst at. What types of algorithms work the best and the worst with ASObj-C. What design philosophies are best suited suited for ASObj-C and what are the worst suited, … These are all issues that come together to answer your question.

I started out as a computer science researcher until I got bribed into working in the private sector. When I was an undergrad I worked on 3 different research project in addition to my regular undergraduate classes. This is pretty unusual but I managed to talk the professors into it. I was really into this stuff at the time. I used to work with these kinds of things all the time.

The average programmer learns these things but almost always couldn’t say how they actually do it. I spent time figuring out just what successful programmers were doing. How can someone maximize the potential a language offers. Your question is given a set of constraints and requirements what features and objects in ASObj-C should you look into using. In other words where do you start with your future script. This is a different answer then I have been looking for.

Bill

Welcome to my personal Blog, “AS Hole”.

Piyomaru,

I do want to say you have the most amazing AppleScript site on the internet. Your site does more to move ASObj-C forward then any other site I know of. Thanks for your welcome. Thank you for all the hard work you have put into your site : ) I never hear anything but the highest complements about your site. Have a great day : )

Bill

??? Is there a link to the site somewhere? (I think I misinterpreted the Piyomaru’s post when I first saw it as something negative or snarky)

Ed,

The URL to the site (his blog) is http://piyocast.com/as/

This is the site I talked about that had a lot of Japanese on it and I used google to translate it to english. He didn’t mean anything negative. He responded to me and told me “welcome to my blog.” He didn’t post a URL because he knew I already had the URL. But now everyone can know the URL.

If you click on his link in the post it comes up with a lot of Japanese at the top. Translated it says:


Piyomaru

Mukaiyama, Nerima-ku, Tokyo

Programmer (AppleScript), Planner. Piyomaru Software CEO (Chief Exective Orikou-san). The latest book of AppleScript is on sale at Booth! Https://t.co/bKSMQkP7Yw


The last part of his standard header is advertising his electronic AppleScript books. Unfortunately they are written in Japanese. I’m not sure if I could translate his ebooks with google translate so I have never tried any of the books. A lot of ebooks are copy protected and limit the number of times someone can copy text out of a book and they usually limit the maximum size of any single copy.

So it was nothing negative. He was just being friendly.

Bill

Jim,

The required file placement for the files inside the top level folder before the database will work is:

FileMaker Pro folder
	ASObj-C Database.fmpur
	Extensions
		Dictionaries
			deutsalt.mpr
			deutsch.mpr
			deutschw.mpr
			espanol.mpr
			francais.mpr
			italiano.mpr
			ndlands.mpr
			porbras.mpr
			portugs.mpr
			svenska.mpr
			ukenglsh.mpr
			usenglsh.mpr
			usengmed.mpr
			User.upr
	FileMaker Pro runtime.app
	FMP Acknowledgements.pdf

The top level folder name can vary buy everything inside that folder has to be in the same place. The file “FMP Acknowledgements.pdf” does not have to be in the folder before it will work, but FileMarker Inc requires the file to be in the folder before I can distribute it.

The “FileMaker Pro runtime.app” contains a striped down version of FileMaker so people can run the database I created but they can’t create anything new in the database or create any new databases. Technically you probably only need “User.upr” and “usenglsh.mpr” in the "Dictionaries"folder but I have never tried it to see if it works and there are people from other countries that look at the database.

Bill

Thanks, but you left out an important file:
ASObj-C Database.fmpur

where should it go?

May I suggest that in the zip file for each update, that you include an “install.txt” file with the proper instructions to install/setup the DB.

I fixed my previous post where I listed what files go where.

Sounds like a good idea.

Bill

FYI, his name is Takaaki Naganoya – he may be familiar to those on Apple’s AppleScript mailing list. I suggested he pop in here after I saw Bill’s commendation (which I second).

Bill, I’m about ready to give up. I’m still getting this error when I double-click on the R/T app OR the Database:

Here’s my setup in the standard Applications folder:

Now that I think about it you probably haven’t seen the previous instructions on how use the files. When I posted that information you weren’t interested in the database.

Drag the “ASObj-C Database.fmpur” file on top of the “FileMaker Pro runtime.app” and let go. Since the new OS came out the FileMaker runtime get an error if you double click on the database file. FileMaker isn’t that interested in fixing a problem with the previous OS so we’re stuck with that.

The first time you run something with “FileMaker Pro runtime.app” you also have to hold down the option key while doing the procedure described in the previous paragraph. The tells the OS that the application you’re opening is ok to open. After doing this once you don’t have to do that again as long as you’re using the “FileMaker Pro runtime.app” you were when you had the option key down. Your system will remember the app is ok. This happens because I didn’t want to pay $99 to apple for code signing and the Mac OSX will show an error without doing this.

That should fix your problem.

Once you get to the dialog click guest account and click ok.

That should take you into the database.

Bill

Here is a TextEdit document I wrote to help people with installing “ASObj-C Database” It is a TextEdit document so it should run on everyone’s Mac. If this proves to be a problem I can convert it to a pdf.

Bill

install.rtfd.zip (109.0 KB)

Since I don’t see any link to download the newest version of the database on this web page I’ll post it here. This is version A16.

Bill