Satimageosax.htmlTEXTVIZF%VV@ The Satimage osax

The Satimage osax

The Satimage osax must be installed in the scripting additions folder for Smile to be fully functional.
(osax is a nickname which means "Scripting addition")
Using the "Open dictionary" command of the "File" menu, you can open the dictionary of the Satimage osax. The present help file introduces this osax with additional details and examples. Please refer to the Satimage osax dictionary itself for the syntax of any command.
The commands of the Satimage osax are given below in a thematic order: strings , lists and records , files , resources and maths .

String manipulation

extract string : extract a substring
Negative indexes start from the end (far right side) of the string.
----------------------------
set theTime to "12:34:56"
set theSeconds to extract string theTime from -2 to -1
-- "56"
----------------------------
uppercase : move to upper case
Uppercase is useful to make case insensitive searches or comparisons.
----------------------------
set theName to "AppleScript"
set theName to uppercase theName
-- "APPLESCRIPT"
----------------------------
replace : replace all occurences of a substring
----------------------------
set theString to "12:34:56"
set theFileName to replace ":" by "-" in theString
-- "12-34-56"
----------------------------
format : format a real number into a string
----------------------------
format pi into "###000.0000'...'"
-- "003.1416..."
----------------------------

Lists and records manipulation

concat : concatenates records, using a sum rule on the items
----------------------------
set theStore to {books:12, pens:{black:50, green:50}, copybooks:3}
set theDelivery to {books:5, pens:{black:50, red:20}, eraser:1}
set theStore to concat theStore with theDelivery
-- {books:17, pens:{black:100, green:50, red:20}, copybooks:3, eraser:1}
----------------------------
suppress item : delete an item from a list or a record
Depending if a key in a record is user-defined or defined by the application (or AppleScript), you need or need not enclose its title between quotes.
----------------------------
set theG3s to {"Blue", "White", "Beige"}
set theNewG3 to suppress item -1 from theG3s
-- {"Blue", "White"}
----------------------------
----------------------------
set theStore to {books:12, pens:{black:50, green:50}, copybooks:3}
set thePaper to suppress item "pens" from theStore -- pens is a user property
-- {books:12, copybooks:3}
----------------------------
----------------------------
set theRecord to {name:"Bob", age:33}
set theAge to suppress item name from theRecord -- name is pre-defined
-- {age:33}
----------------------------

File management

applicationpath : find an application file (or all of them) with a given creator type in a given volume
When the "list all" argument is false, the command returns the last modified application with the given creator type in the given volume. This may be or not be the way "Finder" chooses what application it will open when you double-click a document - in the case where several applications with the same creator type are on the same volume.
----------------------------
applicationpath "VIZF" in path to startup disk
-- file "160GB HD:Desktop Folder:Smile 1.6:Smile :Smile"
----------------------------
get alias info for : returns a list of 3 strings, the names of the AppleTalk zone, of the machine, and of the volume, a given file (or alias) belongs to.
This command is intended, among other things, to provide some workaround to a deep bug of the "Finder", namely its unability to distinguish properly in AppleScript between different file specifications with the same name when they are on the Desktop.
----------------------------
remote info for alias (my path name)
-- {"RedZone", "G4/800", "160GB HD"}
----------------------------
backup : synchronizes 2 folders
The arguments of the command can be aliases of folders, instead of folders.
The output of this command, in level 0 (resp. 2), lists the files to be (resp. which have been) modified or created. As the comments are in French, you need know that "Elments mis jour" means updating, "Elments crs" means creating, and "RAS" means "nothing to report".
The dictionary mentions that the "backup" command is a beta version. So far, the only known bug concerns the backup of empty folders. It is not known as possibly inducing data loss.
General form
----------------------------
backup [source folder] onto [target folder] level 2
----------------------------
----------------------------
backup "160GB HD:Claris Emailer:Claris Emailer Files:Filing Cabinet" onto "Mail Zip, jan 2001" level 2
-- returns the lists of the created / modified folders / files
----------------------------

Resource management

The Satimage osax provides facilities to read and write resources from / to the resource fork of a file. This can prove useful for a lot of technical operations on your Macintosh.
LoadResource : get a resource of a specified type and id number from a specified file
----------------------------
LoadResource 4000 type "STR " from "" & (path to system folder) & "Finder"
-- "About This Computer ..."
----------------------------
ListResources : get the list of the id numbers of resources of a specified type a the specified file
----------------------------
ListResources "PICT" from "" & (path to system folder) & "Finder"
-- {4000, 4001}
----------------------------
GetResourceName : get the name of a resource of specified type and id number from the specified file
----------------------------
GetResourceName 6 type "CODE" from "" & (path to system folder) & "Finder"
-- "CFM Launch"
----------------------------
PutResource : write the given resource to the specified file with specified type and id number
This command will write to the disk, and will erase any existing resource of the specified file with the same type and the same id number. If you make a mistake, this can mean data loss.
----------------------------
set theRect to {20,40,120,140}
PutResource theRect index 128 type "qdrt" to (new file)
----------------------------

Maths

cos, sin, acos, asin, tan, atan2, atan, sqrt, ln, log10, exp
The angles must be given in radians (rad). If an angle is given in degrees (), multiply it by (pi/180) before calling any trigonometric function.
----------------------------
2 * (atan2 {1, 0}) -- {opposite side, adjacent side}
-- 3.14159265359
----------------------------

Advanced

The default name given to a resource by "PutResource" is the four character code of the AppleScript data type. "LoadResource" uses this name to coerce the data stored in the resource into the AppleScript type, except if you force coercion by a call to "LoadResource ... as ...". Thus you should not give a four character name to a resource unless you know what you are doing.
You can use this feature to force the type of the data. For instance, if you store a list of four integers with:
----------------------------
PutResource theRect index 128 type "qdrt" to MyFile
----------------------------
then the corresponding "LoadResource" will create a QuickDraw bounds type.
"LoadResource" is particularly useful for storing scripts. When you want to load a script which is stored in the resource fork, always force the coercion into a fake type, such as:
----------------------------
LoadResource 129 type "scpt" from MyFile as "foo "
----------------------------
Otherwise, "LoadResource" will return, not the script, but the result of the script, that is, the returned value of the "run" handler of the script.



_Xl 7Eڕ"|`@&uo#t S,I 0G  [$9Y  & 5 kp6{ >Y]& JM5#O / g=    k  +  k   k  7  k;  t  kx    k                  %  8  M  Q  W  c  h  {                                k    k`  w  k    k    k    k  )  k-  J  kN    k    k    k    k    k  <  k@  `  kd    k    k    k    k    k  -  k1  Q  kU  t  kx    k    k    k    k  (  k,  L  kP  u  ky    k    k    k  .  k A  L  k P   k   k   k  >  k B  v  k z   k   k    k  6  k :   k   k  (  k ,  \  k `  {  k    k   k   k   b  k f   k   k   k   k  J  kN  `  kd    k    k    k    k  u  ky    k    k  *  k.  n  kr    k    k  >  kB  @  kD  d  kh    k    k    k    k    k  h  kl    k  ?  kC  T  kX  x  k|    k    k    k  i  km    k    k    k/  F  kV    k  %  k)  u  ky    k    k  !  k%  E  kL  ]  ka    k    k  8  k<  R  kV  v  k}    k    k    k  r  kv    k    k    k  !  k%    k    k  -  k1  l  kp    k    k    k  D  kL    k    k  C  k G  ^  k b   k   k  "_  k"c  "  k"  "  k"  #6  k#:  #Z  k#^  #  k#  $h  k$l  $  k$  $  k$  $  k$  %  k%  selelist long%long%pbndlist8longUlongGlonglongBDrwfalspvistrueWIDLfalsICFFlongrSiDlongptxfTEXTGenevaptpslong Rectlist8longlonglonglongWTBHlongRqULlongLWdtlongBrWdlongAuAdfalsTbSzlong scptscptVFasdUAS 1.101.10  misccura"  CONT  misccura  cwtx>  kfrmID ascr ޭ_@7ZstylSOUP&reco2A\cwtx