home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
MAGAZINE
/
DDJ9309.ZIP
/
1993-SEP.ZIP
/
PARDIGM.ASC
< prev
next >
Wrap
Text File
|
1993-07-26
|
1KB
|
94 lines
_PROGRAMMING PARADIGMS_
by Michael Swaine
Example 1: Controlling string comparisons using AppleScript
ignoring case and punctuation
if "It's" = "its" then beep 1
considering punctuation
if "It's" = "its" then beep 2
end considering
end ignoring
Example 2: The tell statement
tell application "Text Editor"
delete character 1 of word 4 of line 6 of document "Ridley 3/18"
end tell
tell word 4 of line 6 of document "Ridley 3/18" of application "Text Editor"
delete character 1
end tell
tell application "Text Editor"
tell document "Ridley 3/18"
tell line 6
tell word 4
delete character 1
end tell
end tell
end tell
end tell
Example 3: Script objects
script duck
bill: yellow
footCount: 2
footStyle: webbed
to quack
open bill
beep
close bill
end quack
end duck
Example 4: (a) AppleScript values; (b)
(a)
word 6 of line 4
ref word 6 of line 4
(b)
script dog
barks: 0
set barks to barks + 1
display dialog barks
end dog
Example 5: (a) recursive handlers, or subroutines; (b) labeled parameter subroutine definitions.
(a)
on factorial (n)
if n = 1 then
return n
else
return factorial (n-1)
end if
end factorial
(b)
on FahrenheitToCentigrade of temp
to searchFiles of filesToSearch for theString
to lowerCase of charsInString above minChar given sortOrder