home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / MAGAZINE / DDJ9309.ZIP / 1993-SEP.ZIP / PARDIGM.ASC < prev    next >
Text File  |  1993-07-26  |  1KB  |  94 lines

  1. _PROGRAMMING PARADIGMS_
  2. by Michael Swaine
  3.  
  4.  
  5. Example 1: Controlling string comparisons using AppleScript
  6.  
  7. ignoring case and punctuation
  8.   if "It's" = "its" then beep 1
  9.   considering punctuation
  10.     if "It's" = "its" then beep 2
  11.   end considering
  12. end ignoring
  13.  
  14.  
  15.  
  16. Example 2:  The tell statement
  17.  
  18. tell application "Text Editor"
  19.   delete character 1 of word 4 of line 6 of document "Ridley 3/18"
  20. end tell
  21.  
  22. tell word 4 of line 6 of document "Ridley 3/18" of application "Text Editor"
  23.   delete character 1
  24. end tell
  25.  
  26. tell application "Text Editor"
  27.   tell document "Ridley 3/18"
  28.     tell line 6
  29.       tell word 4
  30.         delete character 1
  31.       end tell
  32.     end tell
  33.   end tell
  34. end tell
  35.  
  36.  
  37.  
  38.  
  39. Example 3: Script objects
  40.  
  41. script duck
  42.   bill:     yellow
  43.   footCount:    2
  44.   footStyle:    webbed
  45.   to quack
  46.     open bill
  47.     beep
  48.     close bill
  49.   end quack
  50. end duck
  51.  
  52.  
  53.  
  54.  
  55. Example 4: (a) AppleScript values; (b)
  56.  
  57. (a)
  58.  
  59.  
  60. word 6 of line 4
  61. ref word 6 of line 4
  62.  
  63.  
  64. (b)
  65.  
  66. script dog
  67.   barks: 0
  68.   set barks to barks + 1
  69.   display dialog barks
  70. end dog
  71.  
  72.  
  73.  
  74.  
  75. Example 5: (a) recursive handlers, or subroutines; (b) labeled parameter subroutine definitions.
  76.  
  77. (a)
  78.  
  79. on factorial (n)
  80.   if n = 1 then
  81.     return n
  82.   else
  83.     return factorial (n-1)
  84.   end if
  85. end factorial
  86.  
  87.  
  88. (b) 
  89.  
  90. on FahrenheitToCentigrade of temp
  91. to searchFiles of filesToSearch for theString
  92. to lowerCase of charsInString above minChar given sortOrder
  93.  
  94.