SuperCard Shell Essentials

 

command line program example

Page history last edited by DCS 3 yrs ago

command line program example

This is an example of how to get and use a command line program.

As well as all the shell programs that come with os x there are many that can be downloaded and then used with Supercard's shell function.

For this example we will use jhead

jhead is a program that can do many things with Exif jpeg files.

You can download a pre-compiled version of jhead (you can also download the source of many unix programs and use the make command in the terminal to create the program)

You need to set the executable bit of the file, so in the terminal cd to the folder you have put the jhead file in:

cd "/Users/johnjohn/Desktop/jhead/"

then type:

chmod +x jhead

in the terminal and press return

you can now use jhead, test it by typing:

./jhead -h

 

in the terminal and pressing return. You should see the jhead help displayed. You can now use jhead in SuperCard like a normal shell command except you need to pass the full file path to jhead.

If we have the jhead executable in the same folder as our project, this will make it easy to find.

to use jhead we need to use unix style paths for both the location of jhead and the image here we are going to use a function to convert Supercard style paths to unix ones:

 

Returns path in macroman encoding in a single, unterminated line.
function mactoUnixPath macpath
put merge("osascript -e 'posix path of alias `[[macpath]]`' | ") into cmd
put "iconv -f utf8-mac -t macroman | " after cmd
put "perl -pe chomp" after cmd
return shell(cmd)
end mactoUnixPath
Note: subsequent calls may require utf8 encoded path. Remove "iconv -f utf8-mac...' line to retain utf8 encoding.

 

 

See the Path Conversions page for more details.

So here is a script to see an images exif data:

answer file "Choose an image:"
put it into timagefilepath
put projPath(this proj)&"jhead" into jheadPath
put mactoUnixPath(timagefilepath)  into uImagepath
put mactoUnixPath(jheadPath) into ujheadPath
put shell(merge("`[[ujheadPath]]` `[[uImagePath]]`") )

Of course that will only put the first of the many lines returned, so you can put it into a field instead.

 

Here is a script that will set a comment in an images exif data:

ask "Comment What?"
put it into tcomment
answer file "Choose an image:"
put it into timagefilepath
put projPath(this proj)&"jhead" into jheadPath
put mactoUnixPath(timagefilepath)  into uImagepath
put mactoUnixPath(jheadPath) into ujheadPath
put shell(merge("`[[ujheadPath]]` -cl '[[tcomment]]' `[[uImagePath]]`") )

you can check the new comments with the earlier script.

Of course you would probably want to wrap these scripts into functions.

Top

Comments (0)

You don't have permission to comment on this page.