GuidetoSmiledictionary.htmlTEXTVIZFEd:'´ËîU´ËîU“T Smile Dictionary

Smile Dictionary

About the Guide to Smile dictionary

Below is given a summary of the dictionary of Smile. Refer to the dictionary itself for the syntax of any command, and for exhaustivity.

Smile's dictionary includes commands which can be used in any general AppleScript context, for instance commands to do some automatized text processing, and commands specifically needed to handle Smile's objects (windows, dialog boxes ...).

Standard AppleEvents

open : open the specified file(s)
The argument may be a string, an alias, a file specification, or a list of such.
----------------------------
open (navchoose file) --
you may choose multiple files
----------------------------

close : close the specified window
You must absolutely provide the 'saving' parameter (yes / no / ask).
----------------------------
close window "Worksheet" saving ask
----------------------------

make new : make a new object of the specified class
----------------------------
set theTempWind to make new text window with properties {name:"hello"}
----------------------------

delete : delete an object, with no chance to save it
----------------------------
delete theTempWind
----------------------------

quit : quit the application
----------------------------
quit
----------------------------

Remote script handling

execute : run the script contained in a script window
----------------------------
execute window "My first script" --> returns the value returned by the script
----------------------------

check syntax : check syntax of a script window
----------------------------
check syntax window "My first script"
----------------------------

Miscellaneous utilities

display : return the direct object as a string
----------------------------
display (get class of window 1)
----------------------------

change : replace all occurences of a substring in a document. The value returned contains the number of changes, so it can be used to count the occurrences of a given string in the text.
----------------------------
change "a" into "A" in window 2
-- {x, y} x = number of changes made, y = number of characters in the window, useful in a script to update the selection
---------------------------- Note : "change" works on a document, while "replace", a command of the Satimage osax , works on strings contained in AppleScript variables.
'change' is fast, and can be used on arbitrarily long pieces of text.

make new name : return the current time as a string of 19 characters, in a format suitable as a Mac file name.
----------------------------
set theName to make new name
----------------------------
-- "01/01/00, 21h52'05s"

extract column : extract a column out of a table
Comments
The table is supposed to be tab-separated (  ), with rows separated by carriage return characters ( ). The result is returned as a list separated by carriage return characters. You can also obtain the result "as list".
----------------------------
extract column 2 in theTable as list
----------------------------

remote info for : locate an alias on the network
----------------------------
remote info for alias theAliasFileAlias
----------------------------

press key : posts the said keyboard event to the frontmost application
Comments
Can be used, for intance, to drive a non-scriptable application.
The sample makes Script Editor (a non-scriptable application) run a new script.
----------------------------
tell application "Finder" to open application file id "ToyS"
press key "N" with modifiers {command down}
repeat with x in "display dialog \"hello word\""
press key x
end repeat
press key "R" with modifiers {command down}
----------------------------

find definition for : finds the definition of a verb or a class
Comments
The search can target, either a scriptable application, or the scripting addition folder.
----------------------------
tell application "Finder" to get file "Finder" of system folder as text
find definition for "duplicate" in alias result
----------------------------
This will return the definition of "duplicate" as found in the Finder's diectionary.

throwerror : same as AppleScript's 'error' command, but faster
Comments
A bug of certain versions of AppleScript makes it sometimes better to use 'throwerror' than 'error' to throw an error from within a script.
----------------------------
try
[ some lines ]
on error s number n
if n = -128 then throwerror number -128 -- propagate user cancelation
end
----------------------------

Navigation services

The commands below implement the Navigation Services non-modal interface. This means that you can toggle to another application while a Navigation dialog box is open.

navchoose file : choose files

navchoose folder : choose folder

navask save : prompt for save

navnew file : get a new file specification. Can display a custom menu.

navnew folder : get a new folder specification. Can display a custom menu.

Clipboard commands

undo

cut

copy

paste

The clipboard commands are window-specific. Each window has its own undo. So, these commands must be sent to windows:
----------------------------
tell window 1 to paste
tell window 1 to undo
----------------------------

Events sent automatically by Smile

These events are received on special occasions by the script of an object. If the object has an object script , it will receive the call, otherwise the call will be routed to the class script of the object.

prepare : event sent to an object by the application just after the object has been created. Useful to proceed to the required initializations.

do menu : event sent by the application when a menu item is selected

click in : event generated by a click in an object

drop : event generated by dropping

export : return a description for the object dragged

store : event sent by the application just before an object is saved. Useful to proceed to some updates before saving.

Summary of Smile object classes

We present here a selection of the properties of each object, those most often used.

Class basic object : generic class which has the properties owned by each object
Properties:
class type
name
id
container
bounds
path name
visible
script
want idle
properties

Class application : (inherits from basic object) the application program
Elements:
text window
script window
dialog
menu
menu command
Properties:
creator type
cursor
screen bounds
extensions path
user folder
dictionary
modifiers
clipboard

Class window : (inherits from basic object)

Class text window : (inherits from window)
Elements:
character
word
paragraph
text
run info
Properties:
selection
line width
console
store undo
update screen

Class script window : (inherits from text window)

Class character :
Properties:
text size
text font
text color
style
length
index
boundaries
paragraph index
word index

Class button : (inherits from agent)

Class menu :
Elements:
menu item
Properties:
name
enabled
checked

Class menu item :
Properties:
name
enabled
checked
modifiers
shortcut

Text suite - Smile as a scriptable text editor

- Basic descriptions
When refering to a substring of text contained in a Smile text document, you can use the following keywords : character , word , paragraph , text / string , and selection .

By default, these descriptors return lists of strings, like AppleScript does :
----------------------------
words 1 thru 2 of "Smile dictionary"
----------------------------
will [make AppleScript] return {"Smile", "dictionary"}, and :

----------------------------
words 1 thru 2 of window 1
----------------------------
will [make Smile] return {"Smile", "dictionary"}.

Now, you can coerce these expressions, either to list to get the offsets of the ends of the text chunk, or to text to get its contents. You can also coerce them into styled text, to get the text and its style altogether in one variable.

Note that it is more consistent to use the 'boundaries' properties to get the offsets of the ends of a text chunk, rather than coercing it to list - which may lead to unexpected behaviors in complex situations.

----------------------------
first character of paragraph after selection of window 1
----------------------------
-- "-"

----------------------------
words 1 thru 2 of window 1 as text
----------------------------
-- "Smile Dictionary"

----------------------------
words 1 thru 2 of window 1 as list
----------------------------
-- {0, 16}

----------------------------
boundaries of words 1 thru 2 of window 1
----------------------------
-- {0, 16}

----------------------------
set theText to words 1 thru 2 of window 1 as styled text
----------------------------
-- "Smile Dictionary"
The variable 'theText' contains styled text, which can be copied into another text window.

The selection of a text window returns a list. It can also be coerced to text or to styled text.

- Using the 'whose' clauses
By using the 'whose' (or 'where') clause, you can specify a text chunk as the first, or last, fulfilling some condition. Conditions are introduced by the keywords whose , where , and which . Example:
----------------------------
first word of (first paragraph of window 1 where it contains "first word")
----------------------------
-- "first"

- Using the 'every' construction
A description using the 'every' keyword returns a list of such descriptions. The list contains the contents of the concerned text chunks. Instead, it can be coerced to 'list' to return their locations. Example:
----------------------------
(every paragraph of window 1 where it contains "chunk") as list
-- {{6484, 6720}, {6722, 6932}, {7785, 8122}, {8405, 8468}}
----------------------------

- Using 'after' and 'before'
Use the after and before keywords to refer to a piece of text by its location with respect to another one.
----------------------------
paragraph after words 1 thru 2 of window 1
----------------------------
-- ""

----------------------------
paragraph after words 1 thru 2 of window 1 as list
----------------------------
-- {17, 18}

- Getting and setting text and text properties
Both 'get' and 'set' operators (when it makes sense) can be applied to any property of such text description(s), or to their contents, or to the beginning / the end of their content(s). The properties of text are listed under the entry 'text' of the dictionary. Several examples are provided below.
----------------------------
get color of every paragraph of window 1 where it contains "About"
-- {{16000, 0, 32000}, {0, 0, 0}}
----------------------------
get paragraph index of first paragraph of window 1 whose text size is 12
-- 1
----------------------------
set end of (first paragraph of window 1 whose (length > 30)) to " :)"
----------------------------
set first word of window 1 where it is "Smile" to "Smile's"
----------------------------
set first paragraph of window 1 whose color is purple to "About it"
----------------------------

Math library

cos
sin
acos
asin
tan
atan2
atan
sqrt
ln
log10
exp

9È8È_hu, 3 Feb 2000 12:05:08 -0800 User-Agent: Microsoft Outlook Express Macintosh Edition - 5.01 (1630) Date: Thu, 03 Feb 2000 12:05:29 -0800 Subject: Re: Quickeys and Applescript problem From: Paul Berkowitz To: AppleScri7>à    İk¢  ¡  İk¢#  7  İk¢¨  Ï  İk¢     İk¢¨  œ  İkÂ¢Ş  ö  İk¢    İk¢  6  İk¢:    İk¢’  ²  İk¢¶  Ò  İk墎    İk¢=  ]  İk¢h  q  İk¢u  –  İk¢š  â  İk墾    İk¢  ;  İk¢?  _  İk¢j  v  İk¢z  ©  İk¢­  Í  İk墄  %  İk¢)  I  İk¢T  ^  İk¢b  ”  İk¢˜  ¸  İk¢¼  Ò  İk墅  ö  İk¢    İk¢  (  İk¢,  L  İk¢P  X  İk¢\  |  İk¢¾  Ø  İk¢     İk¢   I  İk¢ M  m  İk¢ q  Ï  İk¢ Ó  ó  İk¢ ş    İk¢   8  İk¢ <  \  İk¢ `  “  İk¢ —  ·  İk¢ ù    İk¢ D  O  İk¢ S  ~  İk¢ ‚  ¢  İk¢ ¦  É  İk¢ Í  í  İk¢ ø    İk¢   ¾  İk¢   â  İk¢ æ    İk¢ !  Ÿ  İk¢ £  !  ÔP  a  Ôe  Ÿ  İk¢£  ì  İk¢÷    İk¢  r  İk¢v  –  İkÂ¢š  º  İk¢¾  Ş  İk墉    İk¢  &  İk¢*  P  İk¢W  c  İk¢k  š  İk¢¯  ´  İk¢»  õ  İk¢    İk¢  š  İk¢  ¾  İk¢  ê  İk墔    İk¢  ,  İk¢0  U  İk¢Y  y  İk¢}  ¨  İk¢¬  Ì  İkÂ¢×  ä  İk墏  )  İk¢0  <  İk¢D  ˆ  İk¢Œ  ß  İk墋    İk¢  [  İk¢_  ˜  İk¢œ  ä  İk¢    İk¢  -  İk¢1  j  İk¢n    İk¢™  °  İk¢´  ä  İk墑  ÷  İk¢ÿ  \  İk¢`  €  İk¢„  ã  İk墍  $  İk¢(  H  İk¢L  ®  İk¢¹  Ç  İkÂ¢Ë    İk¢    İk¢  ­  İk¢±  Ñ  İkÂ¢Õ  Ü  İk¢    İk¢  1  İk¢Y  ¢  İk¢¦  ­  İk¢±  Ñ  İk¢  *  İk¢:  ä  İk墕    İk¢    İk¢#  7  İk¢;  O  İk¢Z  i  İk¢m  ƒ  İk¢    İk¢¡  à  İk墑  ü  İk¢  A  İk¢ƒ  ™  İk境  Ñ  İkÂ¢à  ç  İk¢ö  ş  İk¢    İk¢"  ›  İk¢Ÿ  ¿  İkÂ¢à  İ  İk墇  ú  İk¢ş    İk¢`  †  İk¢–  ù  Ô(  9  Ô=  …  Ô³  à  ÔÇ  Ù  İkÂ¢ä  ï  İk増    İk¢ Š  •  İk¢ ™  Ú  İk¢ å  ñ  İk¢ õ  !#  İk¢!.  !6  İk¢!:  !\  İk¢!g  !q  İk¢!u  !§  İk¢!²  !»  İk¢!¿  "4  İk¢"v  "™  İk¢"©  #  İk¢#  #"  İk¢#&  #h  İk¢#l  #{  İk¢#£  #±  İk¢#Ù  #â  İk¢$  $  İk¢$9  $G  İk¢$o  $z  İk¢$¢  $°  İk¢$Ø  $ä  İk¢%  %  İk¢%?  %M  İk¢%u  %„  İk¢%  %¤  İk¢%¨  %ã  İk¢%ç  %ô  İk¢&  &+  İk¢&S  &d  İk¢&Œ  &–  İk¢&¾  &Æ  İk¢&î  &ş  İk¢'  '  İk¢'9  'I  İk¢'q  '{  İk¢'£  '´  İk¢'Ü  'ï  İk¢(  (&  İk¢(N  (\  İk¢(„  (‘  İk¢(¹  (Æ  İk¢(Ñ  (á  İk¢(å  )  İk¢)  ))  İk¢)-  )K  İk¢)O  )\  İk¢)„  )‘  İk¢)¹  )Á  İk¢)é  )ö  İk¢*  *&  İk¢*N  *Z  İk¢*^  *m  İk¢*•  *¢  İk¢*Ê  *Ø  İk¢+  +  İk¢+3  +A  İk¢+i  +z  İk¢+…  +œ  İk¢+   +à  İk¢+Î  +á  İk¢+å  +ì  İk¢+ğ  +ÿ  İk¢,'  ,4  İk¢,\  ,j  İk¢,’  ,¡  İk¢,É  ,Ò  İk¢,ú  -  İk¢-,  -5  İk¢-]  -k  İk¢-“  -¦  İk¢-Î  -İ  İk¢-è  -ø  İk¢-ü  .  İk¢.$  .2  İk¢.6  .=  İk¢.A  .N  İk¢.v  .„  İk¢.ˆ  .—  İk¢.¿  .È  İk¢.ğ  .ü  İk¢/$  /0  İk¢/;  /N  İk¢/R  /Y  İk¢/]  /l  İk¢/”  /  İk¢/Å  /Ñ  İk¢/ù  0  İk¢0-  0;  İk¢0c  0p  İk¢0²  0ä  İk¢0ô  0ú  İk¢0ı  1  İk¢1  1  İk¢1  1  İk¢1¡  1§  İk¢1ª  1²  İk¢1¶  1¼  İk¢1¿  1Ì  İk¢1Ğ  1Ö  İk¢1Ù  1ê  İk¢1î  1ø  İk¢1û  2  İk¢2  2  İk¢2  2l  İk¢2p  2  İk¢2”  2Æ  İk¢2Ê  2ê  İk¢2î  3C  İk¢3K  3k  İk¢3o  3  İk¢3‘  3±  İk¢3µ  3ş  İk¢4  4;  İk¢4>  4F  İk¢4J  4‡  İk¢4Š  4’  İk¢4–  5  İk¢5  5ò  İk¢5ú  6  İk¢6  6Z  İk¢6^  6~  İk¢6–  6   İk¢6Ê  6Û  İk¢6ã  7  İk¢7  7-  İk¢71  7Q  İk¢7U  7x  İk¢7€  7   İk¢7¤  7Ê  İk¢7Î  7î  İk¢7ò  8  İk¢8  8)  İk¢8-  8Y  İk¢8]  8}  İk¢8  8  İk¢8˜  8¸  İk¢8¼  8ø  İk¢8ü  9  İk¢9  9C  İk¢9G  9¥  İk¢9­  9µ  İk¢9¸  9Å  İk¢9É  :  İk¢:(  :.  İk¢:1  :N  İk¢:V  :ı  İk¢;  ;  İk¢;  ;  İk¢;  ;  İk¢;#  ;-  İk¢;0  ;9  İk¢;=  ;K  İk¢;O  ;o  İk¢;s  ;Ë  İk¢;Ï  ;ï  İk¢;ó  <  İk¢<  <  İk¢<  <>  İk¢  >  İk¢>  >)  İk¢>1  >=  İk¢>@  >I  İk¢>M  >V  İk¢>Y  >c  İk¢>g  >½  İk¢>Á  >á  İk¢>å  ?  İk¢?  ?7  İk¢?;  ?N  İk¢?V  ?v  İk¢?z  ?°  İk¢?´  ?Ô  İk¢?Ø  ?ç  İk¢?ï  ?õ  İk¢?ø  @(  İk¢@0  A^  İk¢Ab  A‚  İk¢A†  AÖ  İk¢AÚ  B  İk¢B  B&  İk¢B*  Bv  İk¢Bz  Bƒ  İk¢B‡  B§  İk¢B«  C  İk¢C  C'  İk¢C+  C~  İk¢C‚  C¢  İk¢C¦  C÷  İk¢Cû  D  İk¢D]  Dm  İk¢D¾  DÅ  İk¢DÉ  DĞ  İk¢DÔ  DÜ  İk¢Dà  Dè  İk¢Dì  Dó  İk¢D÷  E  İk¢E  E  İk¢E  E  İk¢E  E"  İk¢E&  E/  İk¢E3  E:  İk¢Eb  ~selelist longAblongAbpbndlist8long longulongÒlongîBDrwfalspvistrueWIDLfalsICFFlongrSiDlong€ptxfTEXTGenevaptpslong Rectlist8longlonglonglongWTBHlongRqULlongLWdtlongBrWdlongAuAdfalsTbSzlong 9È8È_?¨9¨ZstylSOUP&reco2€ÿÿ€ÿÿ7B‚7F@Ècwtx