home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Programming / Dialog Director 0.6 / Examples / Sorted!.as < prev    next >
Encoding:
Text File  |  1997-04-17  |  4.1 KB  |  185 lines  |  [TEXT/ToyS]

  1. property l1 : {¬
  2.     "Klingon", ¬
  3.     "Russian", ¬
  4.     "Maldivian", ¬
  5.     "Slavic", ¬
  6.     "Sindhi", ¬
  7.     "English", ¬
  8.     "French", ¬
  9.     "German", ¬
  10.     "Italian", ¬
  11.     "Dutch", ¬
  12.     "Swedish", ¬
  13.     "Spanish", ¬
  14.     "Danish", ¬
  15.     "Norwegian", ¬
  16.     "Hebrew", ¬
  17.     "Japanese", ¬
  18.     "Arabic", ¬
  19.     "Finnish", ¬
  20.     "Greek", ¬
  21.     "Icelandic", ¬
  22.     "Maltese", ¬
  23.     "Turkish", ¬
  24.     "Croatian", ¬
  25.     "Urdu", ¬
  26.     "Hindi", ¬
  27.     "Thai", ¬
  28.     "Korean", ¬
  29.     "Lithuanian", ¬
  30.     "Polish", ¬
  31.     "Hungarian", ¬
  32.     "Estonian", ¬
  33.     "Lettish", ¬
  34.     "Latvian", ¬
  35.     "Saamisk", ¬
  36.     "Lappish", ¬
  37.     "Faeroese", ¬
  38.     "Farsi", ¬
  39.     "Persian", ¬
  40.     "Flemish", ¬
  41.     "Irish", ¬
  42.     "Albanian", ¬
  43.     "Romanian", ¬
  44.     "Czech", ¬
  45.     "Slovak", ¬
  46.     "Slovenian", ¬
  47.     "Yiddish", ¬
  48.     "Serbian", ¬
  49.     "Macedonian", ¬
  50.     "Bulgarian", ¬
  51.     "Ukrainian", ¬
  52.     "Byelorussian", ¬
  53.     "Uzbek", ¬
  54.     "Kazakh", ¬
  55.     "Azerbaijani", ¬
  56.     "Armenian", ¬
  57.     "Georgian", ¬
  58.     "Moldavian", ¬
  59.     "Kirghiz", ¬
  60.     "Tajiki", ¬
  61.     "Turkmen", ¬
  62.     "Mongolian", ¬
  63.     "Pashto", ¬
  64.     "Kurdish", ¬
  65.     "Kashmiri", ¬
  66.     "Tibetan", ¬
  67.     "Nepali", ¬
  68.     "Sanskrit", ¬
  69.     "Marathi", ¬
  70.     "Bengali", ¬
  71.     "Assamese", ¬
  72.     "Gujarati", ¬
  73.     "Punjabi", ¬
  74.     "Oriya", ¬
  75.     "Malayalam", ¬
  76.     "Kannada", ¬
  77.     "Tamil", ¬
  78.     "Telugu", ¬
  79.     "Sinhalese", ¬
  80.     "Burmese", ¬
  81.     "Khmer", ¬
  82.     "Lao", ¬
  83.     "Vietnamese", ¬
  84.     "Indonesian", ¬
  85.     "Tagalog", ¬
  86.     "Amharic", ¬
  87.     "Tigrinya", ¬
  88.     "Galla", ¬
  89.     "Oromo", ¬
  90.     "Somali", ¬
  91.     "Swahili", ¬
  92.     "Ruanda", ¬
  93.     "Rundi", ¬
  94.     "Chewa", ¬
  95.     "Malagasy", ¬
  96.     "Esperanto", ¬
  97.     "Welsh", ¬
  98.     "Basque", ¬
  99.     "Catalan", ¬
  100.     "Latin", ¬
  101.     "Quechua", ¬
  102.     "Guarani", ¬
  103.     "Aymara", ¬
  104.     "Tatar", ¬
  105.     "Uighur", ¬
  106.     "Dzongkha", ¬
  107.     "Javanese", ¬
  108.     "Sundanese", ¬
  109.     "Portugese", ¬
  110.     "Yugoslavian", ¬
  111.     "Chinese", ¬
  112.     "Lapponian"}
  113.  
  114. set sortDialog to {size:[500, 196], name:"Sorted!", style:movable modal, contents:[¬
  115.     {class:push button, name:"Sort", bounds:[210, 24, 290, 44]}, ¬
  116.     {class:push button, name:"Done", bounds:[210, 53, 290, 73]}, ¬
  117.     {class:push button, name:"Change", bounds:[210, 80, 290, 100], enabled:[dAnd, 6, 7]}, ¬
  118.     {class:push button, name:"Append", bounds:[210, 107, 290, 127], enabled:7}, ¬
  119.     {class:push button, name:"Delete", bounds:[210, 134, 290, 154], enabled:6}, ¬
  120.     {class:list box, contents:l1, bounds:[10, 24, 190, 154], flags:130}, ¬
  121.     {class:text field, bounds:[12, 170, 260, 186]}, ¬
  122.     {class:list box, contents:[], bounds:[310, 24, 490, 154]}, ¬
  123.     {class:static text, contents:"Source", bounds:[8, 4, 160, 20]}, ¬
  124.     {class:static text, contents:"Destination", bounds:[308, 4, 460, 20]} ¬
  125.         ]}
  126.  
  127. dd install with greyscale
  128. set d to dd make dialog sortDialog
  129. repeat
  130.     set i to dd interact with user
  131.     --tell application "Transcript" to «event miscEcho» (i as string) & return
  132.     if i = 1 then -- Sort
  133.         DoSort(d)
  134.     else if i = 2 then -- Cancel
  135.         exit repeat
  136.     else if i = 3 then -- Change
  137.         set n to dd get value of item 6 of d
  138.         set l1's item n to dd get value of item 7 of d
  139.         dd set contents of item 6 of d to l1
  140.         dd set value of item 6 of d to n
  141.     else if i = 4 then -- Append
  142.         set l1 to l1 & (dd get value of item 7 of d)
  143.         dd set contents of item 6 of d to l1
  144.         dd set value of item 6 of d to l1's length
  145.     else if i = 5 then -- Delete
  146.         set l1 to DelItem(l1, dd get value of item 6 of d)
  147.         dd set contents of item 6 of d to l1
  148.     else if i = 6 then -- List 1
  149.         set n to dd get value of item 6 of d
  150.         if n ≠ 0 then dd set value of item 7 of d to l1's item n
  151.     end if
  152. end repeat
  153. dd uninstall
  154.  
  155. on DoSort(d)
  156.     set p to dd make dialog {size:[300, 50], contents:[¬
  157.         {class:static text, contents:"Sorting…", bounds:[8, 4, 160, 20]}, ¬
  158.         {class:gauge, bounds:[10, 25, 290, 25 + 12], value:0, max value:l1's length} ¬
  159.             ]}
  160.     try -- A simple bubble sort
  161.         set l2 to l1
  162.         repeat with n from 1 to l2's length
  163.             repeat with j from 1 to (l2's length) - n
  164.                 if l2's item j > l2's item (j + 1) then
  165.                     set temp to l2's item j
  166.                     set l2's item j to l2's item (j + 1)
  167.                     set l2's item (j + 1) to temp
  168.                 end if
  169.             end repeat
  170.             dd set value of item 2 of p to n
  171.             --if (dd interact with user for max ticks 0) = 1 then exit repeat
  172.         end repeat
  173.         dd set contents of item 8 of d to l2
  174.     on error
  175.     end try
  176.     dd delete p
  177. end DoSort
  178.  
  179. on DelItem(l, i)
  180.     if i = length of l then
  181.         return items 1 thru (i - 1) of l
  182.     else
  183.         return items 1 thru (i - 1) of l & items (i + 1) thru (length of l) of l
  184.     end if
  185. end DelItem