home *** CD-ROM | disk | FTP | other *** search
/ Better Homes & Gardens: …oking for Today - Chicken / Image.iso / pc / personal.dxr / 00001_movie.ls next >
Encoding:
Text File  |  1995-11-20  |  27.1 KB  |  909 lines

  1. on startMovie
  2.   global gLastRecipeLine, gPhotoSprite, gEditorSprites, gFractions, gLastCurrentRecipe, gLastCurrentBook, gCurrentRecipe, gCurrentBook, gHelpSprite, gCurrentCategory
  3.   set gLastRecipeLine to 0
  4.   set gPhotoSprite to 25
  5.   set gEditorSprites to [2, 3, 8, 9, 10, 11, 12, 13, 24, 28, 32]
  6.   if the machineType = 256 then
  7.     set the textHeight of field "instructions scroll" to 14
  8.     set the textSize of field "instructions scroll" to 12
  9.     set the textStyle of field "instructions scroll" to "plain"
  10.     set the textFont of field "instructions scroll" to "arial"
  11.     set the textHeight of field "instructions" to 14
  12.     set the textSize of field "instructions" to 12
  13.     set the textStyle of field "instructions" to "plain"
  14.     set the textFont of field "instructions" to "arial"
  15.     set the textHeight of field "ingredients scroll" to 14
  16.     set the textSize of field "ingredients scroll" to 12
  17.     set the textStyle of field "ingredients scroll" to "plain"
  18.     set the textFont of field "ingredients" to "arial"
  19.     set the textHeight of field "ingredients" to 14
  20.     set the textSize of field "ingredients" to 12
  21.     set the textStyle of field "ingredients" to "plain"
  22.     set the textFont of field "ingredients" to "arial"
  23.   else
  24.     set the textHeight of field "instructions scroll" to 14
  25.     set the textSize of field "instructions scroll" to 12
  26.     set the textStyle of field "instructions scroll" to "plain"
  27.     set the textFont of field "instructions scroll" to "helvetica"
  28.     set the textHeight of field "instructions" to 14
  29.     set the textSize of field "instructions" to 12
  30.     set the textStyle of field "instructions" to "plain"
  31.     set the textFont of field "instructions" to "helvetica"
  32.     set the textHeight of field "ingredients scroll" to 14
  33.     set the textSize of field "ingredients scroll" to 12
  34.     set the textStyle of field "ingredients scroll" to "plain"
  35.     set the textFont of field "ingredients" to "helvetica"
  36.     set the textHeight of field "ingredients" to 14
  37.     set the textSize of field "ingredients" to 12
  38.     set the textStyle of field "ingredients" to "plain"
  39.     set the textFont of field "ingredients" to "helvetica"
  40.   end if
  41.   set gFractions to ["0", "1/16", "1/8", "3/16", "1/4", "5/16", "1/3", "3/8", "7/16", "1/2", "9/16", "5/8", "2/3", "11/16", "3/4", "13/16", "7/8", "15/16"]
  42.   set gLastCurrentRecipe to gCurrentRecipe
  43.   set gLastCurrentBook to gCurrentBook
  44.   updateRecipes()
  45.   loadCategoryNames()
  46.   loadPersonalIndexes()
  47.   set gHelpSprite to 48
  48.   helpOff()
  49.   set gCurrentCategory to 1
  50.   Index()
  51. end
  52.  
  53. on stopMovie
  54.   global gPersonalIDDB, gPersonalBrowser, gCurrentBook, gCFTBook
  55.   loadPersonalIndexes()
  56.   if (count(gPersonalIDDB) > 0) and (count(gPersonalBrowser) > 0) then
  57.     nothing()
  58.   else
  59.     set gCurrentBook to gCFTBook
  60.   end if
  61.   saveCategoryNames()
  62.   saveRecipe()
  63.   cleanLegos()
  64. end
  65.  
  66. on Index
  67.   global gEditorType
  68.   saveRecipe()
  69.   set gEditorType to #new
  70.   put " " into field "indexScroll"
  71.   indexPhotoOff()
  72.   cleanLegos()
  73.   go("index")
  74.   set the selEnd to 0
  75.   makeIndexScrolls()
  76.   makeIndexButtons()
  77.   set gInBSnotMade to 1
  78.   setCategoryButton()
  79. end
  80.  
  81. on indexNoSave
  82.   global gEditorType
  83.   set gEditorType to #new
  84.   put " " into field "indexScroll"
  85.   indexPhotoOff()
  86.   cleanLegos()
  87.   go("index")
  88.   set the selEnd to 0
  89.   makeIndexScrolls()
  90.   makeIndexButtons()
  91.   set gInBSnotMade to 1
  92.   setCategoryButton()
  93. end
  94.  
  95. on editor
  96.   global gEditorType, gLastTitle, gLastCategory, gCurrentCategory, gIngredientsScroll, gInstructionsScroll
  97.   editorOff()
  98.   cleanCategoryNames()
  99.   clearEditor()
  100.   if gEditorType = #book then
  101.     DBBookToPersonal()
  102.   else
  103.     if gEditorType = #personal then
  104.       DBEditPersonal()
  105.     else
  106.       put "Untitled" into field "title"
  107.     end if
  108.   end if
  109.   set gLastTitle to field "title"
  110.   set gLastCategory to gCurrentCategory
  111.   cleanLegos()
  112.   go("editor")
  113.   set the selEnd to 0
  114.   makeEditorScrolls()
  115.   makeEditorButtons()
  116.   set gEdBSnotMade to 1
  117.   categoriesMenu()
  118.   dishesMenu()
  119.   timesMenu()
  120.   setCategoryMenu()
  121.   if (gEditorType = #book) or (gEditorType = #personal) then
  122.     setCurrentMenus()
  123.   end if
  124.   controlPosition(gIngredientsScroll, 0.0)
  125.   controlPosition(gInstructionsScroll, 0.0)
  126.   editorOn()
  127. end
  128.  
  129. on category1
  130.   global gCurrentCategory, gCategory1
  131.   clearLastLine()
  132.   set gCurrentCategory to 1
  133.   if gCategory1 = EMPTY then
  134.     put "Empty" into field "indexScroll"
  135.   else
  136.     if gCategory1 = "Empty" then
  137.       put "Empty" into field "indexScroll"
  138.     else
  139.       put gCategory1 into field "indexScroll"
  140.     end if
  141.   end if
  142.   selectRecipe(1)
  143. end
  144.  
  145. on category2
  146.   global gCurrentCategory, gCategory2
  147.   clearLastLine()
  148.   set gCurrentCategory to 2
  149.   if gCategory2 = EMPTY then
  150.     put "Empty" into field "indexScroll"
  151.   else
  152.     if gCategory2 = "Empty" then
  153.       put "Empty" into field "indexScroll"
  154.     else
  155.       put gCategory2 into field "indexScroll"
  156.     end if
  157.   end if
  158.   selectRecipe(1)
  159. end
  160.  
  161. on category3
  162.   global gCurrentCategory, gCategory3
  163.   clearLastLine()
  164.   set gCurrentCategory to 3
  165.   if gCategory3 = EMPTY then
  166.     put "Empty" into field "indexScroll"
  167.   else
  168.     if gCategory3 = "Empty" then
  169.       put "Empty" into field "indexScroll"
  170.     else
  171.       put gCategory3 into field "indexScroll"
  172.     end if
  173.   end if
  174.   selectRecipe(1)
  175. end
  176.  
  177. on category4
  178.   global gCurrentCategory, gCategory4
  179.   clearLastLine()
  180.   set gCurrentCategory to 4
  181.   if gCategory4 = EMPTY then
  182.     put "Empty" into field "indexScroll"
  183.   else
  184.     if gCategory4 = "Empty" then
  185.       put "Empty" into field "indexScroll"
  186.     else
  187.       put gCategory4 into field "indexScroll"
  188.     end if
  189.   end if
  190.   selectRecipe(1)
  191. end
  192.  
  193. on category5
  194.   global gCurrentCategory, gCategory5
  195.   clearLastLine()
  196.   set gCurrentCategory to 5
  197.   if gCategory5 = EMPTY then
  198.     put "Empty" into field "indexScroll"
  199.   else
  200.     if gCategory5 = "Empty" then
  201.       put "Empty" into field "indexScroll"
  202.     else
  203.       put gCategory5 into field "indexScroll"
  204.     end if
  205.   end if
  206.   selectRecipe(1)
  207. end
  208.  
  209. on updateRecipes
  210.   global gPersonalRecipes
  211.   loadPersonalIndexes()
  212.   set sentList to EMPTY
  213.   set number to count(gPersonalRecipes)
  214.   if number = 0 then
  215.     set sentList to "(send recipes here from recipe screen)"
  216.   else
  217.     if number = 1 then
  218.       set sentList to getAt(gPersonalRecipes, 1) & RETURN
  219.     else
  220.       set sentList to getAt(gPersonalRecipes, 1) & RETURN
  221.       repeat with i = 2 to number
  222.         put getAt(gPersonalRecipes, i) & RETURN after sentList
  223.       end repeat
  224.     end if
  225.   end if
  226.   put sentList into field "sentScroll"
  227. end
  228.  
  229. on selectRecipe lineNum
  230.   global gCurrentBook, gCurrentRecipe, gLastRecipeLine, gRecipeIDDB, gPersonalIDDB, gPhotoSprite
  231.   if lineNum < 1 then
  232.     exit
  233.   end if
  234.   if gLastRecipeLine = lineNum then
  235.     exit
  236.   end if
  237.   set theRecipe to line lineNum of field "indexScroll"
  238.   if (theRecipe = EMPTY) or (theRecipe = "Empty") then
  239.     exit
  240.   end if
  241.   set the textStyle of line gLastRecipeLine of field "indexScroll" to "plain"
  242.   set gLastRecipeLine to lineNum
  243.   set gCurrentRecipe to getaProp(gRecipeIDDB, theRecipe)
  244.   if gCurrentRecipe = 0 then
  245.     set gCurrentBook to "personal"
  246.     set gCurrentRecipe to getaProp(gPersonalIDDB, theRecipe)
  247.   else
  248.     if (gCurrentRecipe > 1700) and (gCurrentRecipe < 1772) then
  249.       set gCurrentBook to "Pasta"
  250.       set the castNum of sprite gPhotoSprite to the number of cast "index photo"
  251.     else
  252.       if (gCurrentRecipe > 1800) and (gCurrentRecipe < 1869) then
  253.         set gCurrentBook to "Vegi"
  254.         set the castNum of sprite gPhotoSprite to the number of cast "index photo"
  255.       else
  256.         if (gCurrentRecipe > 1900) and (gCurrentRecipe < 1969) then
  257.           set gCurrentBook to "Stir"
  258.           set the castNum of sprite gPhotoSprite to the number of cast "index photo"
  259.         else
  260.           if (gCurrentRecipe > 2000) and (gCurrentRecipe < 2069) then
  261.             set gCurrentBook to "Chick"
  262.             set the castNum of sprite gPhotoSprite to the number of cast "index photo"
  263.           end if
  264.         end if
  265.       end if
  266.     end if
  267.   end if
  268.   updateIndexPhoto()
  269.   set gCurrentBook to "personal"
  270.   set the visible of sprite gPhotoSprite to 1
  271.   set the textStyle of line lineNum of field "indexScroll" to "bold"
  272. end
  273.  
  274. on addRecipe
  275.   global gCurrentCategory, gPersonalIDDB
  276.   loadPersonalIndexes()
  277.   set lineNum to the mouseLine
  278.   if lineNum < 1 then
  279.     exit
  280.   end if
  281.   set aLine to line lineNum of field "sentScroll"
  282.   if (aLine = EMPTY) or (aLine = "(send recipes here from recipe screen)") then
  283.     exit
  284.   end if
  285.   clearLastLine()
  286.   DBBeginSaveSession()
  287.   set newID to DBSetRecord("personal recipe", "0^" & aLine & "^0^" & gCurrentCategory & "^cat^1^2^inst^0^cup^nil^ingr^0")
  288.   addProp(gPersonalIDDB, aLine, newID)
  289.   DBEndSession()
  290.   if field "indexScroll" = "Empty" then
  291.     put aLine into field "indexScroll"
  292.   else
  293.     set Index to stringToList(removeReturns2(field "indexScroll"))
  294.     add(Index, aLine)
  295.     sort(Index)
  296.     put listToString2(Index) into field "indexScroll"
  297.   end if
  298.   updateCurrentCategory()
  299.   selectRecipe(1)
  300. end
  301.  
  302. on editRecipe
  303.   global gCurrentRecipe, gLastRecipeLine, gEditorType
  304.   loadPersonalIndexes()
  305.   helpOff()
  306.   if field "indexScroll" = "Empty" then
  307.     set gEditorType to #new
  308.   else
  309.     if gCurrentRecipe < 2069 then
  310.       set gEditorType to #book
  311.       put line gLastRecipeLine of field "indexScroll" into field "title"
  312.     else
  313.       if gCurrentRecipe >= 6000 then
  314.         set gEditorType to #personal
  315.         put line gLastRecipeLine of field "indexScroll" into field "title"
  316.       end if
  317.     end if
  318.   end if
  319.   editor()
  320. end
  321.  
  322. on deleteRecipe
  323.   global gLastRecipeLine, gRecipeIDDB, gPersonalIDDB, gCurrentCategory
  324.   loadPersonalIndexes()
  325.   if field "indexScroll" = "Empty" then
  326.     exit
  327.   end if
  328.   set theRecipe to line gLastRecipeLine of field "indexScroll"
  329.   set num to count(gPersonalIDDB)
  330.   repeat with i = 1 to num
  331.     set title to getPropAt(gPersonalIDDB, i)
  332.     if title = theRecipe then
  333.       set id to getAt(gPersonalIDDB, i)
  334.       DBBeginSaveSession()
  335.       DBGetSetRecord(id, "personal recipe")
  336.       set category to integer(DBGetSetField(3004))
  337.       DBEndSession()
  338.       if category = gCurrentCategory then
  339.         deleteProp(gPersonalIDDB, theRecipe)
  340.         DBBeginSaveSession()
  341.         DBDeleteRecord("personal recipe", integer(id))
  342.         DBEndSession()
  343.         delete line gLastRecipeLine of field "indexScroll"
  344.         delete line gLastRecipeLine of field "indexScroll"
  345.         clearLastLine()
  346.         if (field "indexScroll" = EMPTY) or (field "indexScroll" = RETURN) then
  347.           set the textStyle of line gLastRecipeLine of field "indexScroll" to "plain"
  348.           put "Empty" into field "indexScroll"
  349.           indexPhotoOff()
  350.         else
  351.           set gLastRecipeLine to 0
  352.           selectRecipe(1)
  353.         end if
  354.         updateCurrentCategory()
  355.         exit repeat
  356.       end if
  357.     end if
  358.   end repeat
  359. end
  360.  
  361. on addIngredient
  362.   global gIngredientsScroll
  363.   cleanEditor()
  364.   if (field "fraction" = 0) and (field "quantity" = 0) then
  365.     set quantity to EMPTY
  366.   else
  367.     if field "fraction" = 0 then
  368.       set quantity to field "quantity" & " "
  369.     else
  370.       if field "quantity" = "0" then
  371.         set quantity to field "fraction" & " "
  372.       else
  373.         set quantity to field "quantity" & "-" & field "fraction" & " "
  374.       end if
  375.     end if
  376.   end if
  377.   if (field "unit" = "empty") or (removeSpace(field "unit") = EMPTY) then
  378.     set unit to " "
  379.   else
  380.     set unit to field "unit" & " "
  381.   end if
  382.   if (field "ingredient" = "empty") or (removeSpace(field "ingredient") = EMPTY) then
  383.     set ingredient to " "
  384.   else
  385.     set ingredient to field "ingredient"
  386.   end if
  387.   set aLine to quantity & unit & ingredient
  388.   if aLine <> "  " then
  389.     put aLine & RETURN & RETURN before field "ingredients"
  390.   end if
  391.   controlPosition(gIngredientsScroll, 0.0)
  392. end
  393.  
  394. on checkUnit
  395.   if the selStart = 0 then
  396.     put " " into field "unit"
  397.     exit
  398.   end if
  399.   set theWord to char 1 to the selStart of field "unit"
  400.   put theWord into field "unit"
  401.   set theField to field "units"
  402.   set fieldNum to length(theField)
  403.   set num to length(theWord)
  404.   repeat with i = 1 to fieldNum
  405.     if theWord = char 1 to num of line i of theField then
  406.       put line i of theField into field "unit"
  407.       exit repeat
  408.     end if
  409.   end repeat
  410. end
  411.  
  412. on quantityUp
  413.   set num to integer(field "quantity")
  414.   set doOnce to 1
  415.   repeat while the mouseDown or doOnce
  416.     if num < 9999 then
  417.       set num to num + 1
  418.     end if
  419.     put num into field "quantity"
  420.     waste()
  421.     set doOnce to 0
  422.   end repeat
  423. end
  424.  
  425. on quantityDown
  426.   set num to integer(field "quantity")
  427.   set doOnce to 1
  428.   repeat while the mouseDown or doOnce
  429.     if num > 0 then
  430.       set num to num - 1
  431.     end if
  432.     put num into field "quantity"
  433.     waste()
  434.     set doOnce to 0
  435.   end repeat
  436. end
  437.  
  438. on fractionUp
  439.   global gFractions
  440.   set num to getPos(gFractions, field "fraction")
  441.   set doOnce to 1
  442.   repeat while the mouseDown or doOnce
  443.     if num < 18 then
  444.       set num to num + 1
  445.     end if
  446.     put getAt(gFractions, num) into field "fraction"
  447.     waste()
  448.     set doOnce to 0
  449.   end repeat
  450. end
  451.  
  452. on fractionDown
  453.   global gFractions
  454.   set num to getPos(gFractions, field "fraction")
  455.   set doOnce to 1
  456.   repeat while the mouseDown or doOnce
  457.     if num > 1 then
  458.       set num to num - 1
  459.     end if
  460.     put getAt(gFractions, num) into field "fraction"
  461.     waste()
  462.     set doOnce to 0
  463.   end repeat
  464. end
  465.  
  466. on categoriesMenu
  467.   global gCategoriesMenu
  468.   set gCategoriesMenu to birth(script "pull down menu", 22, 23, the number of cast "menu", the number of cast "button", "categories", field "Category1" & RETURN & field "Category2" & RETURN & field "Category3" & RETURN & field "Category4" & RETURN & field "Category5", "setCurrentCategory")
  469. end
  470.  
  471. on dishesMenu
  472.   global gDishesMenu
  473.   set gDishesMenu to birth(script "pull down menu", 26, 27, the number of cast "menu", the number of cast "button", "dishes", "Appetizers & Snacks" & RETURN & "Main Dishes" & RETURN & "Side Dishes, Breads & Rolls" & RETURN & "Soup, Salad & Sandwiches" & RETURN & "Desserts & Beverages")
  474. end
  475.  
  476. on timesMenu
  477.   global gTimesMenu
  478.   set gTimesMenu to birth(script "pull down menu", 30, 31, the number of cast "menu", the number of cast "button", "times", "Less than 15 minutes" & RETURN & "Less than 30 minutes" & RETURN & "Less than 1 hour" & RETURN & "Less than 2 hours" & RETURN & "Less than 4 hours")
  479. end
  480.  
  481. on makeIndexScrolls
  482.   global gCategoryScroll, gSentScroll
  483.   set track to new("Button", [#spriteChan: 33])
  484.   set ball to new("Button", [#spriteChan: 34, #pressedCast: 96])
  485.   set up to new("Button", [#spriteChan: 35, #pressedCast: 98])
  486.   set down to new("Button", [#spriteChan: 36, #pressedCast: 100])
  487.   set gCategoryScroll to new("ScrollBar", [#scrollSprite: 2, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
  488.   set track to new("Button", [#spriteChan: 37])
  489.   set ball to new("Button", [#spriteChan: 38, #pressedCast: 96])
  490.   set up to new("Button", [#spriteChan: 39, #pressedCast: 98])
  491.   set down to new("Button", [#spriteChan: 40, #pressedCast: 100])
  492.   set gSentScroll to new("ScrollBar", [#scrollSprite: 3, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
  493. end
  494.  
  495. on makeEditorScrolls
  496.   global gIngredientsScroll, gInstructionsScroll
  497.   set track to new("Button", [#spriteChan: 33])
  498.   set ball to new("Button", [#spriteChan: 34, #pressedCast: 96])
  499.   set up to new("Button", [#spriteChan: 35, #pressedCast: 98])
  500.   set down to new("Button", [#spriteChan: 36, #pressedCast: 100])
  501.   set gIngredientsScroll to new("ScrollBar", [#scrollField: "ingredients", #scrollFieldOut: 2, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
  502.   set track to new("Button", [#spriteChan: 37])
  503.   set ball to new("Button", [#spriteChan: 38, #pressedCast: 96])
  504.   set up to new("Button", [#spriteChan: 39, #pressedCast: 98])
  505.   set down to new("Button", [#spriteChan: 40, #pressedCast: 100])
  506.   set gInstructionsScroll to new("ScrollBar", [#scrollField: "instructions", #scrollFieldOut: 3, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
  507. end
  508.  
  509. on updateCurrentCategory
  510.   global gCurrentCategory, gCategory1, gCategory2, gCategory3, gCategory4, gCategory5
  511.   if gCurrentCategory = 1 then
  512.     set gCategory1 to field "indexScroll"
  513.   else
  514.     if gCurrentCategory = 2 then
  515.       set gCategory2 to field "indexScroll"
  516.     else
  517.       if gCurrentCategory = 3 then
  518.         set gCategory3 to field "indexScroll"
  519.       else
  520.         if gCurrentCategory = 4 then
  521.           set gCategory4 to field "indexScroll"
  522.         else
  523.           if gCurrentCategory = 5 then
  524.             set gCategory5 to field "indexScroll"
  525.           end if
  526.         end if
  527.       end if
  528.     end if
  529.   end if
  530. end
  531.  
  532. on setCurrentCategory
  533.   global gCurrentCategory, gCategory1, gCategory2, gCategory3, gCategory4, gCategory5
  534.   set category to field "categories"
  535.   if category = field "category1" then
  536.     set gCurrentCategory to 1
  537.     put gCategory1 into field "indexScroll"
  538.   else
  539.     if category = field "category2" then
  540.       set gCurrentCategory to 2
  541.       put gCategory2 into field "indexScroll"
  542.     else
  543.       if category = field "category3" then
  544.         set gCurrentCategory to 3
  545.         put gCategory3 into field "indexScroll"
  546.       else
  547.         if category = field "category4" then
  548.           set gCurrentCategory to 4
  549.           put gCategory4 into field "indexScroll"
  550.         else
  551.           if category = field "category5" then
  552.             set gCurrentCategory to 5
  553.             put gCategory5 into field "indexScroll"
  554.           end if
  555.         end if
  556.       end if
  557.     end if
  558.   end if
  559. end
  560.  
  561. on setCategoryMenu
  562.   global gCategoriesMenu, gCurrentCategory
  563.   controlSelection(gCategoriesMenu, gCurrentCategory)
  564. end
  565.  
  566. on setCurrentMenus
  567.   global gDishesMenu, gTimesMenu, gCurrentDishType, gCurrentPrepTime
  568.   if gCurrentDishType = "Appetizers and Snacks" then
  569.     set dishNum to 1
  570.   else
  571.     if gCurrentDishType = "Main Dishes" then
  572.       set dishNum to 2
  573.     else
  574.       if gCurrentDishType = "Side Dishes, Breads and Rolls" then
  575.         set dishNum to 3
  576.       else
  577.         if gCurrentDishType = "Soup, Salad and Sandwiches" then
  578.           set dishNum to 4
  579.         else
  580.           if gCurrentDishType = "Desserts and Beverages" then
  581.             set dishNum to 5
  582.           else
  583.             set dishNum to gCurrentDishType
  584.           end if
  585.         end if
  586.       end if
  587.     end if
  588.   end if
  589.   if not getPos([1, 2, 3, 4, 5], dishNum) then
  590.     set dishNum to 1
  591.   end if
  592.   controlSelection(gDishesMenu, dishNum)
  593.   if gCurrentPrepTime < 15 then
  594.     set timeNum to 1
  595.   else
  596.     if gCurrentPrepTime < 30 then
  597.       set timeNum to 2
  598.     else
  599.       if gCurrentPrepTime < 60 then
  600.         set timeNum to 3
  601.       else
  602.         if gCurrentPrepTime < 120 then
  603.           set timeNum to 4
  604.         else
  605.           if gCurrentPrepTime < 240 then
  606.             set timeNum to 5
  607.           else
  608.             set timeNum to gCurrentPrepTime - 1000
  609.           end if
  610.         end if
  611.       end if
  612.     end if
  613.   end if
  614.   if not getPos([1, 2, 3, 4, 5], timeNum) then
  615.     set dishNum to 1
  616.   end if
  617.   controlSelection(gTimesMenu, timeNum)
  618. end
  619.  
  620. on getCurrentDishType
  621.   set dishType to field "dishes"
  622.   if dishType = "Appetizers & Snacks" then
  623.     set dishNum to 1
  624.   else
  625.     if dishType = "Main Dishes" then
  626.       set dishNum to 2
  627.     else
  628.       if dishType = "Side Dishes, Breads & Rolls" then
  629.         set dishNum to 3
  630.       else
  631.         if dishType = "Soup, Salad & Sandwiches" then
  632.           set dishNum to 4
  633.         else
  634.           if dishType = "Desserts & Beverages" then
  635.             set dishNum to 5
  636.           end if
  637.         end if
  638.       end if
  639.     end if
  640.   end if
  641.   return dishNum
  642. end
  643.  
  644. on getCurrentPrepTime
  645.   set prepTime to field "times"
  646.   if prepTime = "Less than 15 minutes" then
  647.     set timeNum to 1
  648.   else
  649.     if prepTime = "Less than 30 minutes" then
  650.       set timeNum to 2
  651.     else
  652.       if prepTime = "Less than 1 hour" then
  653.         set timeNum to 3
  654.       else
  655.         if prepTime = "Less than 2 hours" then
  656.           set timeNum to 4
  657.         else
  658.           if prepTime = "Less than 4 hours" then
  659.             set timeNum to 5
  660.           end if
  661.         end if
  662.       end if
  663.     end if
  664.   end if
  665.   return timeNum
  666. end
  667.  
  668. on clearEditor
  669.   put "0" into field "servings"
  670.   put " " into field "ingredients"
  671.   put " " into field "ingredients scroll"
  672.   put "Enter recipe instructions here" into field "instructions"
  673.   put "Enter recipe instructions here" into field "instructions scroll"
  674.   put "0" into field "quantity"
  675.   put "0" into field "fraction"
  676.   put "empty" into field "unit"
  677.   put "empty" into field "ingredient"
  678. end
  679.  
  680. on clearLastLine
  681.   global gLastRecipeLine, gCategoryScroll
  682.   indexPhotoOff()
  683.   set the textStyle of line gLastRecipeLine of field "indexScroll" to "plain"
  684.   set gLastRecipeLine to 0
  685.   controlPosition(gCategoryScroll, 0.0)
  686. end
  687.  
  688. on indexPhotoOff
  689.   global gPhotoSprite
  690.   set the visible of sprite gPhotoSprite to 0
  691. end
  692.  
  693. on editorOn
  694.   global gEditorSprites
  695.   repeat with i in gEditorSprites
  696.     set the visible of sprite i to 1
  697.   end repeat
  698. end
  699.  
  700. on editorOff
  701.   global gEditorSprites
  702.   repeat with i in gEditorSprites
  703.     set the visible of sprite i to 0
  704.   end repeat
  705. end
  706.  
  707. on loadCategoryNames
  708.   global gDBResult
  709.   DBBeginSaveSession()
  710.   DBGetSetRecord(1, "personal category")
  711.   if gDBResult = 0 then
  712.     put DBGetSetField(5001) into field "category1"
  713.   end if
  714.   DBGetSetRecord(2, "personal category")
  715.   if gDBResult = 0 then
  716.     put DBGetSetField(5001) into field "category2"
  717.   end if
  718.   DBGetSetRecord(3, "personal category")
  719.   if gDBResult = 0 then
  720.     put DBGetSetField(5001) into field "category3"
  721.   end if
  722.   DBGetSetRecord(4, "personal category")
  723.   if gDBResult = 0 then
  724.     put DBGetSetField(5001) into field "category4"
  725.   end if
  726.   DBGetSetRecord(5, "personal category")
  727.   if gDBResult = 0 then
  728.     put DBGetSetField(5001) into field "category5"
  729.   end if
  730.   DBEndSession()
  731. end
  732.  
  733. on saveCategoryNames
  734.   cleanCategoryNames()
  735.   DBBeginSaveSession()
  736.   set category1 to 1 & "^" & field "category1"
  737.   set category2 to 2 & "^" & field "category2"
  738.   set category3 to 3 & "^" & field "category3"
  739.   set category4 to 4 & "^" & field "category4"
  740.   set category5 to 5 & "^" & field "category5"
  741.   DBSetRecord("personal category", category1)
  742.   DBSetRecord("personal category", category2)
  743.   DBSetRecord("personal category", category3)
  744.   DBSetRecord("personal category", category4)
  745.   DBSetRecord("personal category", category5)
  746.   DBEndSession()
  747. end
  748.  
  749. on cleanCategoryNames
  750.   put removeCarrots(line 1 of field "category1") into field "category1"
  751.   put removeCarrots(line 1 of field "category2") into field "category2"
  752.   put removeCarrots(line 1 of field "category3") into field "category3"
  753.   put removeCarrots(line 1 of field "category4") into field "category4"
  754.   put removeCarrots(line 1 of field "category5") into field "category5"
  755. end
  756.  
  757. on cleanEditor
  758.   put line 1 of field "title" into field "title"
  759.   put line 1 of field "servings" into field "servings"
  760.   put line 1 of field "unit" into field "unit"
  761.   put line 1 of field "ingredient" into field "ingredient"
  762. end
  763.  
  764. on waste
  765.   startTimer()
  766.   repeat while the timer < 10
  767.     nothing()
  768.   end repeat
  769. end
  770.  
  771. on makeIndexButtons
  772.   global gMainButton, gBackButton, gHelpButton, gCategoryButton1, gCategoryButton2, gCategoryButton3, gCategoryButton4, gCategoryButton5, gEditButton, gDeleteButton
  773.   set gMainButton to birth(script "GACButton", 5)
  774.   set gHelpButton to birth(script "GACButton", 7)
  775.   set gBackButton to birth(script "GACButton", 6)
  776.   set gCategoryButton1 to birth(script "radioButton", 16)
  777.   set gCategoryButton2 to birth(script "radioButton", 17)
  778.   set gCategoryButton3 to birth(script "radioButton", 18)
  779.   set gCategoryButton4 to birth(script "radioButton", 19)
  780.   set gCategoryButton5 to birth(script "radioButton", 20)
  781.   set gEditButton to birth(script "GACButton", 22)
  782.   set gDeleteButton to birth(script "GACButton", 23)
  783. end
  784.  
  785. on makeEditorButtons
  786.   global gMainButton, gBackButton, gAddButton, gSaveButton
  787.   set gMainButton to birth(script "GACButton", 5)
  788.   set gBackButton to birth(script "GACButton", 6)
  789.   set gAddButton to birth(script "GACButton", 47)
  790.   set gSaveButton to birth(script "GACButton", 21)
  791. end
  792.  
  793. on setCategoryButton
  794.   global gCurrentCategory, gCategoryButton1, gCategoryButton2, gCategoryButton3, gCategoryButton4, gCategoryButton5
  795.   if gCurrentCategory = 1 then
  796.     select(gCategoryButton1)
  797.     category1()
  798.   else
  799.     if gCurrentCategory = 2 then
  800.       select(gCategoryButton2)
  801.       category2()
  802.     else
  803.       if gCurrentCategory = 3 then
  804.         select(gCategoryButton3)
  805.         category3()
  806.       else
  807.         if gCurrentCategory = 4 then
  808.           select(gCategoryButton4)
  809.           category4()
  810.         else
  811.           if gCurrentCategory = 5 then
  812.             select(gCategoryButton5)
  813.             category5()
  814.           end if
  815.         end if
  816.       end if
  817.     end if
  818.   end if
  819. end
  820.  
  821. on saveRecipe
  822.   global gCurrentRecipe, gRecipeIDDB, gPersonalIDDB, gCurrentCategory, theTitle, theNumber, gLastTitle, gLastCategory
  823.   if the frame <> label("editor") then
  824.     exit
  825.   end if
  826.   cleanEditor()
  827.   cursor(4)
  828.   DBBeginSaveSession()
  829.   set title to removeCarrots(field "title")
  830.   if removeSpace(title) = EMPTY then
  831.     set title to "Untitled"
  832.   end if
  833.   set theTitle to title
  834.   set theNumber to 1
  835.   noDuplicateTitles()
  836.   set title to theTitle
  837.   set servings to integer(removeCarrots(field "servings"))
  838.   if not integerp(servings) then
  839.     set servings to 0
  840.   end if
  841.   set aString to 0 & "^" & title & "^" & servings & "^" & gCurrentCategory & "^" & "collate^" & getCurrentDishType() & "^" & getCurrentPrepTime() & "^" & removeCarrots(field "instructions")
  842.   set ingredients to removeCarrots(field "ingredients")
  843.   set ingredientsNum to the number of lines in ingredients
  844.   repeat with i = 1 to ingredientsNum
  845.     set aLine to line i of ingredients
  846.     if (aLine <> EMPTY) or (ingredientsNum = 1) then
  847.       set ingredient to aLine
  848.       put "^0^unit^nil^" & ingredient & " ^0" after aString
  849.     end if
  850.   end repeat
  851.   set newID to DBSetRecord("personal recipe", aString)
  852.   addProp(gPersonalIDDB, title, newID)
  853.   if (field "indexScroll" = "Empty") or (field "indexScroll" = EMPTY) then
  854.     put title into field "indexScroll"
  855.   else
  856.     set Index to stringToList(removeReturns2(field "indexScroll"))
  857.     add(Index, title)
  858.     sort(Index)
  859.     put listToString2(Index) into field "indexScroll"
  860.   end if
  861.   updateCurrentCategory()
  862.   DBEndSession()
  863.   cursor(-1)
  864. end
  865.  
  866. on noDuplicateTitles
  867.   global theTitle, theNumber, gRecipeIDDB, gPersonalIDDB
  868.   set Index to field "indexScroll"
  869.   set indexNum to the number of lines in Index
  870.   set duplicateP to getaProp(gPersonalIDDB, theTitle)
  871.   if voidp(duplicateP) then
  872.     set duplicateP to getaProp(gRecipeIDDB, theTitle)
  873.   end if
  874.   if not voidp(duplicateP) then
  875.     if (theTitle contains "(") and (theTitle contains ")") then
  876.       set place1 to offset("(", theTitle) + 1
  877.       set place2 to offset(")", theTitle) - 1
  878.       set number to integer(char place1 to place2 of theTitle)
  879.       if not integerp(number) then
  880.         set theNumber to 1
  881.       else
  882.         set theNumber to integer(number + 1)
  883.       end if
  884.       put theNumber into char place1 to place2 of theTitle
  885.     else
  886.       set theNumber to integer(theNumber + 1)
  887.       put "(" & theNumber & ")" after theTitle
  888.     end if
  889.     noDuplicateTitles()
  890.     exit
  891.   end if
  892. end
  893.  
  894. on helpOn
  895.   global gLastHelp, gHelpLinks, gHelpActive, gHelpSprite
  896.   if gHelpActive then
  897.     helpOff()
  898.   else
  899.     set gHelpActive to 1
  900.     set gLastHelp to 0
  901.     if the frame = label("editor") then
  902.       set gHelpLinks to [5: 19, 6: 23, 7: 1, 8: 83, 9: 84, 10: 88, 11: 88, 24: 85, 28: 86, 32: 87, 41: 89, 42: 90, 43: 88, 44: 88, 45: 88, 46: 88, 47: 92, 3: 91]
  903.     else
  904.       set gHelpLinks to [5: 19, 6: 23, 7: 1, 2: 117, 3: 97, 16: 116, 17: 116, 18: 116, 19: 116, 20: 116, 22: 98, 23: 99]
  905.     end if
  906.     puppetSprite(gHelpSprite, 1)
  907.   end if
  908. end
  909.