global gPersonalIDDB, gPersonalBrowser, gCurrentBook, gCFTBook
loadPersonalIndexes()
if (count(gPersonalIDDB) > 0) and (count(gPersonalBrowser) > 0) then
nothing()
else
set gCurrentBook to gCFTBook
end if
saveCategoryNames()
saveRecipe()
cleanLegos()
end
on Index
global gEditorType
saveRecipe()
set gEditorType to #new
put " " into field "indexScroll"
indexPhotoOff()
cleanLegos()
go("index")
set the selEnd to 0
makeIndexScrolls()
makeIndexButtons()
set gInBSnotMade to 1
setCategoryButton()
end
on indexNoSave
global gEditorType
set gEditorType to #new
put " " into field "indexScroll"
indexPhotoOff()
cleanLegos()
go("index")
set the selEnd to 0
makeIndexScrolls()
makeIndexButtons()
set gInBSnotMade to 1
setCategoryButton()
end
on editor
global gEditorType, gLastTitle, gLastCategory, gCurrentCategory, gIngredientsScroll, gInstructionsScroll
editorOff()
cleanCategoryNames()
clearEditor()
if gEditorType = #book then
DBBookToPersonal()
else
if gEditorType = #personal then
DBEditPersonal()
else
put "Untitled" into field "title"
end if
end if
set gLastTitle to field "title"
set gLastCategory to gCurrentCategory
cleanLegos()
go("editor")
set the selEnd to 0
makeEditorScrolls()
makeEditorButtons()
set gEdBSnotMade to 1
categoriesMenu()
dishesMenu()
timesMenu()
setCategoryMenu()
if (gEditorType = #book) or (gEditorType = #personal) then
setCurrentMenus()
end if
controlPosition(gIngredientsScroll, 0.0)
controlPosition(gInstructionsScroll, 0.0)
editorOn()
end
on category1
global gCurrentCategory, gCategory1
clearLastLine()
set gCurrentCategory to 1
if gCategory1 = EMPTY then
put "Empty" into field "indexScroll"
else
if gCategory1 = "Empty" then
put "Empty" into field "indexScroll"
else
put gCategory1 into field "indexScroll"
end if
end if
selectRecipe(1)
end
on category2
global gCurrentCategory, gCategory2
clearLastLine()
set gCurrentCategory to 2
if gCategory2 = EMPTY then
put "Empty" into field "indexScroll"
else
if gCategory2 = "Empty" then
put "Empty" into field "indexScroll"
else
put gCategory2 into field "indexScroll"
end if
end if
selectRecipe(1)
end
on category3
global gCurrentCategory, gCategory3
clearLastLine()
set gCurrentCategory to 3
if gCategory3 = EMPTY then
put "Empty" into field "indexScroll"
else
if gCategory3 = "Empty" then
put "Empty" into field "indexScroll"
else
put gCategory3 into field "indexScroll"
end if
end if
selectRecipe(1)
end
on category4
global gCurrentCategory, gCategory4
clearLastLine()
set gCurrentCategory to 4
if gCategory4 = EMPTY then
put "Empty" into field "indexScroll"
else
if gCategory4 = "Empty" then
put "Empty" into field "indexScroll"
else
put gCategory4 into field "indexScroll"
end if
end if
selectRecipe(1)
end
on category5
global gCurrentCategory, gCategory5
clearLastLine()
set gCurrentCategory to 5
if gCategory5 = EMPTY then
put "Empty" into field "indexScroll"
else
if gCategory5 = "Empty" then
put "Empty" into field "indexScroll"
else
put gCategory5 into field "indexScroll"
end if
end if
selectRecipe(1)
end
on updateRecipes
global gPersonalRecipes
loadPersonalIndexes()
set sentList to EMPTY
set number to count(gPersonalRecipes)
if number = 0 then
set sentList to "(send recipes here from recipe screen)"
else
if number = 1 then
set sentList to getAt(gPersonalRecipes, 1) & RETURN
else
set sentList to getAt(gPersonalRecipes, 1) & RETURN
repeat with i = 2 to number
put getAt(gPersonalRecipes, i) & RETURN after sentList
end repeat
end if
end if
put sentList into field "sentScroll"
end
on selectRecipe lineNum
global gCurrentBook, gCurrentRecipe, gLastRecipeLine, gRecipeIDDB, gPersonalIDDB, gPhotoSprite
if lineNum < 1 then
exit
end if
if gLastRecipeLine = lineNum then
exit
end if
set theRecipe to line lineNum of field "indexScroll"
if (theRecipe = EMPTY) or (theRecipe = "Empty") then
exit
end if
set the textStyle of line gLastRecipeLine of field "indexScroll" to "plain"
set gLastRecipeLine to lineNum
set gCurrentRecipe to getaProp(gRecipeIDDB, theRecipe)
if gCurrentRecipe = 0 then
set gCurrentBook to "personal"
set gCurrentRecipe to getaProp(gPersonalIDDB, theRecipe)
else
if (gCurrentRecipe > 1700) and (gCurrentRecipe < 1772) then
set gCurrentBook to "Pasta"
set the castNum of sprite gPhotoSprite to the number of cast "index photo"
else
if (gCurrentRecipe > 1800) and (gCurrentRecipe < 1869) then
set gCurrentBook to "Vegi"
set the castNum of sprite gPhotoSprite to the number of cast "index photo"
else
if (gCurrentRecipe > 1900) and (gCurrentRecipe < 1969) then
set gCurrentBook to "Stir"
set the castNum of sprite gPhotoSprite to the number of cast "index photo"
else
if (gCurrentRecipe > 2000) and (gCurrentRecipe < 2069) then
set gCurrentBook to "Chick"
set the castNum of sprite gPhotoSprite to the number of cast "index photo"
end if
end if
end if
end if
end if
updateIndexPhoto()
set gCurrentBook to "personal"
set the visible of sprite gPhotoSprite to 1
set the textStyle of line lineNum of field "indexScroll" to "bold"
end
on addRecipe
global gCurrentCategory, gPersonalIDDB
loadPersonalIndexes()
set lineNum to the mouseLine
if lineNum < 1 then
exit
end if
set aLine to line lineNum of field "sentScroll"
if (aLine = EMPTY) or (aLine = "(send recipes here from recipe screen)") then
exit
end if
clearLastLine()
DBBeginSaveSession()
set newID to DBSetRecord("personal recipe", "0^" & aLine & "^0^" & gCurrentCategory & "^cat^1^2^inst^0^cup^nil^ingr^0")
addProp(gPersonalIDDB, aLine, newID)
DBEndSession()
if field "indexScroll" = "Empty" then
put aLine into field "indexScroll"
else
set Index to stringToList(removeReturns2(field "indexScroll"))
add(Index, aLine)
sort(Index)
put listToString2(Index) into field "indexScroll"
end if
updateCurrentCategory()
selectRecipe(1)
end
on editRecipe
global gCurrentRecipe, gLastRecipeLine, gEditorType
loadPersonalIndexes()
helpOff()
if field "indexScroll" = "Empty" then
set gEditorType to #new
else
if gCurrentRecipe < 2069 then
set gEditorType to #book
put line gLastRecipeLine of field "indexScroll" into field "title"
else
if gCurrentRecipe >= 6000 then
set gEditorType to #personal
put line gLastRecipeLine of field "indexScroll" into field "title"
end if
end if
end if
editor()
end
on deleteRecipe
global gLastRecipeLine, gRecipeIDDB, gPersonalIDDB, gCurrentCategory
loadPersonalIndexes()
if field "indexScroll" = "Empty" then
exit
end if
set theRecipe to line gLastRecipeLine of field "indexScroll"
set num to count(gPersonalIDDB)
repeat with i = 1 to num
set title to getPropAt(gPersonalIDDB, i)
if title = theRecipe then
set id to getAt(gPersonalIDDB, i)
DBBeginSaveSession()
DBGetSetRecord(id, "personal recipe")
set category to integer(DBGetSetField(3004))
DBEndSession()
if category = gCurrentCategory then
deleteProp(gPersonalIDDB, theRecipe)
DBBeginSaveSession()
DBDeleteRecord("personal recipe", integer(id))
DBEndSession()
delete line gLastRecipeLine of field "indexScroll"
delete line gLastRecipeLine of field "indexScroll"
clearLastLine()
if (field "indexScroll" = EMPTY) or (field "indexScroll" = RETURN) then
set the textStyle of line gLastRecipeLine of field "indexScroll" to "plain"
put "Empty" into field "indexScroll"
indexPhotoOff()
else
set gLastRecipeLine to 0
selectRecipe(1)
end if
updateCurrentCategory()
exit repeat
end if
end if
end repeat
end
on addIngredient
global gIngredientsScroll
cleanEditor()
if (field "fraction" = 0) and (field "quantity" = 0) then
set quantity to EMPTY
else
if field "fraction" = 0 then
set quantity to field "quantity" & " "
else
if field "quantity" = "0" then
set quantity to field "fraction" & " "
else
set quantity to field "quantity" & "-" & field "fraction" & " "
end if
end if
end if
if (field "unit" = "empty") or (removeSpace(field "unit") = EMPTY) then
set unit to " "
else
set unit to field "unit" & " "
end if
if (field "ingredient" = "empty") or (removeSpace(field "ingredient") = EMPTY) then
set ingredient to " "
else
set ingredient to field "ingredient"
end if
set aLine to quantity & unit & ingredient
if aLine <> " " then
put aLine & RETURN & RETURN before field "ingredients"
end if
controlPosition(gIngredientsScroll, 0.0)
end
on checkUnit
if the selStart = 0 then
put " " into field "unit"
exit
end if
set theWord to char 1 to the selStart of field "unit"
put theWord into field "unit"
set theField to field "units"
set fieldNum to length(theField)
set num to length(theWord)
repeat with i = 1 to fieldNum
if theWord = char 1 to num of line i of theField then
put line i of theField into field "unit"
exit repeat
end if
end repeat
end
on quantityUp
set num to integer(field "quantity")
set doOnce to 1
repeat while the mouseDown or doOnce
if num < 9999 then
set num to num + 1
end if
put num into field "quantity"
waste()
set doOnce to 0
end repeat
end
on quantityDown
set num to integer(field "quantity")
set doOnce to 1
repeat while the mouseDown or doOnce
if num > 0 then
set num to num - 1
end if
put num into field "quantity"
waste()
set doOnce to 0
end repeat
end
on fractionUp
global gFractions
set num to getPos(gFractions, field "fraction")
set doOnce to 1
repeat while the mouseDown or doOnce
if num < 18 then
set num to num + 1
end if
put getAt(gFractions, num) into field "fraction"
waste()
set doOnce to 0
end repeat
end
on fractionDown
global gFractions
set num to getPos(gFractions, field "fraction")
set doOnce to 1
repeat while the mouseDown or doOnce
if num > 1 then
set num to num - 1
end if
put getAt(gFractions, num) into field "fraction"
waste()
set doOnce to 0
end repeat
end
on categoriesMenu
global gCategoriesMenu
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")
end
on dishesMenu
global gDishesMenu
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")
end
on timesMenu
global gTimesMenu
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")
end
on makeIndexScrolls
global gCategoryScroll, gSentScroll
set track to new("Button", [#spriteChan: 33])
set ball to new("Button", [#spriteChan: 34, #pressedCast: 96])
set up to new("Button", [#spriteChan: 35, #pressedCast: 98])
set down to new("Button", [#spriteChan: 36, #pressedCast: 100])
set gCategoryScroll to new("ScrollBar", [#scrollSprite: 2, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
set track to new("Button", [#spriteChan: 37])
set ball to new("Button", [#spriteChan: 38, #pressedCast: 96])
set up to new("Button", [#spriteChan: 39, #pressedCast: 98])
set down to new("Button", [#spriteChan: 40, #pressedCast: 100])
set gSentScroll to new("ScrollBar", [#scrollSprite: 3, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
end
on makeEditorScrolls
global gIngredientsScroll, gInstructionsScroll
set track to new("Button", [#spriteChan: 33])
set ball to new("Button", [#spriteChan: 34, #pressedCast: 96])
set up to new("Button", [#spriteChan: 35, #pressedCast: 98])
set down to new("Button", [#spriteChan: 36, #pressedCast: 100])
set gIngredientsScroll to new("ScrollBar", [#scrollField: "ingredients", #scrollFieldOut: 2, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
set track to new("Button", [#spriteChan: 37])
set ball to new("Button", [#spriteChan: 38, #pressedCast: 96])
set up to new("Button", [#spriteChan: 39, #pressedCast: 98])
set down to new("Button", [#spriteChan: 40, #pressedCast: 100])
set gInstructionsScroll to new("ScrollBar", [#scrollField: "instructions", #scrollFieldOut: 3, #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
end
on updateCurrentCategory
global gCurrentCategory, gCategory1, gCategory2, gCategory3, gCategory4, gCategory5
if gCurrentCategory = 1 then
set gCategory1 to field "indexScroll"
else
if gCurrentCategory = 2 then
set gCategory2 to field "indexScroll"
else
if gCurrentCategory = 3 then
set gCategory3 to field "indexScroll"
else
if gCurrentCategory = 4 then
set gCategory4 to field "indexScroll"
else
if gCurrentCategory = 5 then
set gCategory5 to field "indexScroll"
end if
end if
end if
end if
end if
end
on setCurrentCategory
global gCurrentCategory, gCategory1, gCategory2, gCategory3, gCategory4, gCategory5