Recipe management software?

For everything that's not in any way related to PureBasic. General chat etc...
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Recipe management software?

Post by infratec »

No, I have it overwritten by the new download.
So I just downloaded the 7Z again (which was changed 5 hours ago) but still...
About.rtf is not inside.

And you have 'defaults' inside of the advanced search.
I would start with a blank form.

Bernd
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: Recipe management software?

Post by heartbone »

infratec wrote:No, I have it overwritten by the new download.
So I just downloaded the 7Z again (which was changed 5 hours ago) but still...
About.rtf is not inside.

And you have 'defaults' inside of the advanced search.
I would start with a blank form.

Bernd
I figured that this utility might have been cooked long enough, and I'm curious to see if something like this might be useful, so I downloaded it about 13 hours ago.
I just checked, and About.rtf begins with the line: "This is just a simple recipe manager with just the features that my family needs."

I'll get back to you Fangbeast in the relatively near future, with some feedback. :)
Keep it BASIC.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

No, I have it overwritten by the new download.
Damn. I thought you might have kept an old archive somewhere. Okay, will update it today.
And you have 'defaults' inside of the advanced search.
I would start with a blank form.
They are not defaults. All fields in the advanced search are 'remembered' from the last time you used it and reloaded. My wife and I find ourselves wanting to remember them so that's the way I did it.

The main form 'remembers' the last field searched and last search text used as well. And also the last database opened..
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

Recipes source code project. Nothing missing, tested.

https://www.dropbox.com/s/ses2gntoukn3t ... es.7z?dl=0

External help files (DOCX, PDF, EPUB, CHM)

https://www.dropbox.com/s/u7ku4unzcmurw ... es.7z?dl=0
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

I am going to add separate windows for people to add/edit/delete or totally overwrite their title replacement characters and measure translations and in order to do it properly, I had to a:

Develop a system using preference files rather than database as we need these settings to be local to the user and not to the database because people will swap databases and we don't want our settings saved to theirs and b:

Totally write the concept as a separate program to prove that I can get this to work in the main program when it is finished.

Don't know if the code is of use to anyone but here it is anyway.

When I get some time, I will add this into the main recipes program. Just another thing I needed and it actually worked without bugs for a change.

Code: Select all

UsePNGImageDecoder()

Define EventID,  MenuID,  GadgetID,  WindowID

Enumeration 1
  #Window_Measures
  #Window_Data
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  ; Window_Measures
  #Gadget_Measures_cMeasures
  #Gadget_Measures_MeasuresList
  #Gadget_Measures_cControl
  #Gadget_Measures_Save
  #Gadget_Measures_Load
  #Gadget_Measures_fSeparator1
  #Gadget_Measures_Add
  #Gadget_Measures_Delete
  #Gadget_Measures_Edit
  #Gadget_Measures_fSeparator2
  #Gadget_Measures_Help
  #Gadget_Measures_fSeparator3
  #Gadget_Measures_Logo
  #Gadget_Measures_fSeparator4
  #Gadget_Measures_Exit
  #Gadget_Measures_lControl1

  ; Window_Data
  #Gadget_Data_cData
  #Gadget_Data_lAbbreviation
  #Gadget_Data_Abbreviation
  #Gadget_Data_lMeaning
  #Gadget_Data_Meaning
  #Gadget_Data_cControl
  #Gadget_Data_Save
  #Gadget_Data_fSeparator1
  #Gadget_Data_Logo
  #Gadget_Data_fSeparator2
  #Gadget_Data_Exit
  #Gadget_Data_lControl1
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  #Image_Measures_Save
  #Image_Measures_Load
  #Image_Measures_Add
  #Image_Measures_Delete
  #Image_Measures_Edit
  #Image_Measures_Help
  #Image_Measures_Logo
  #Image_Measures_Exit

  #Image_Data_Save
  #Image_Data_Logo
  #Image_Data_Exit
EndEnumeration

#ImageIndex = #PB_Compiler_EnumerationValue

CatchImage(#Image_Measures_Save,     ?_SMEGMeasures_Save)
CatchImage(#Image_Measures_Load,     ?_SMEGMeasures_Load)
CatchImage(#Image_Measures_Add,      ?_SMEGMeasures_Add)
CatchImage(#Image_Measures_Delete,   ?_SMEGMeasures_Delete)
CatchImage(#Image_Measures_Edit,     ?_SMEGMeasures_Edit)
CatchImage(#Image_Measures_Help,     ?_SMEGMeasures_Help)
CatchImage(#Image_Measures_Logo,     ?_SMEGMeasures_Logo)
CatchImage(#Image_Measures_Exit,     ?_SMEGMeasures_Exit)
CatchImage(#Image_Data_Save,         ?_SMEGMeasures_Save)
CatchImage(#Image_Data_Logo,         ?_SMEGMeasures_Logo)
CatchImage(#Image_Data_Exit,         ?_SMEGMeasures_Exit)

DataSection
  _SMEGMeasures_Save:   :   IncludeBinary "Images\_54x54\Save.png"
  _SMEGMeasures_Load:   :   IncludeBinary "Images\_54x54\Open.png"
  _SMEGMeasures_Add:    :   IncludeBinary "Images\_54x54\Add.png"
  _SMEGMeasures_Delete: :   IncludeBinary "Images\_54x54\Delete.png"
  _SMEGMeasures_Edit:   :   IncludeBinary "Images\_54x54\Edit.png"
  _SMEGMeasures_Help:   :   IncludeBinary "Images\_54x54\Help.png"
  _SMEGMeasures_Logo:   :   IncludeBinary "Images\_Other\Banner1.png"
  _SMEGMeasures_Exit:   :   IncludeBinary "Images\_54x54\Exit.png"
EndDataSection

Procedure.i Window_Measures()
  If OpenWindow(#Window_Measures, 161, 106, 620, 650, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
      SetWindowColor(#Window_Measures, $FFFFFF)
      ContainerGadget(#Gadget_Measures_cMeasures, 5, 5, 610, 550, #PB_Container_Flat|#PB_Container_BorderLess)
        SetGadgetColor(#Gadget_Measures_cMeasures, #PB_Gadget_BackColor, $FFFFFF)
      ListIconGadget(#Gadget_Measures_MeasuresList, 0, 0, 610, 548, "Search for this string in measure", 290, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        SetGadgetColor(#Gadget_Measures_MeasuresList, #PB_Gadget_BackColor, $F2F2F2)
        AddGadgetColumn(#Gadget_Measures_MeasuresList, 1, "Recplace this string in measure", 290)
        SetGadgetFont(#Gadget_Measures_MeasuresList, LoadFont(#Gadget_Measures_MeasuresList, "Comic Sans MS", 10, 0))
      CloseGadgetList()
      ContainerGadget(#Gadget_Measures_cControl, 5, 557, 610, 85, #PB_Container_Flat|#PB_Container_BorderLess)
        SetGadgetColor(#Gadget_Measures_cControl, #PB_Gadget_BackColor, $FFFFFF)
      ImageGadget(#Gadget_Measures_Save, 5, 5, 54, 54, ImageID(#Image_Measures_Save))
      ImageGadget(#Gadget_Measures_Load, 65, 5, 54, 54, ImageID(#Image_Measures_Load))
      FrameGadget(#Gadget_Measures_fSeparator1, 130, 5, 5, 55, "", #PB_Frame_Double)
      ImageGadget(#Gadget_Measures_Add, 140, 5, 54, 54, ImageID(#Image_Measures_Add))
      ImageGadget(#Gadget_Measures_Delete, 200, 5, 54, 54, ImageID(#Image_Measures_Delete))
      ImageGadget(#Gadget_Measures_Edit, 260, 5, 54, 54, ImageID(#Image_Measures_Edit))
      FrameGadget(#Gadget_Measures_fSeparator2, 320, 5, 5, 55, "", #PB_Frame_Double)
      ImageGadget(#Gadget_Measures_Help, 330, 5, 54, 54, ImageID(#Image_Measures_Help))
      FrameGadget(#Gadget_Measures_fSeparator3, 390, 5, 5, 55, "", #PB_Frame_Double)
      ImageGadget(#Gadget_Measures_Logo, 405, 0, 124, 64, ImageID(#Image_Measures_Logo))
      ResizeGadget(#Gadget_Measures_Logo, 405, 0, 124, 64)
      ResizeImage(#Image_Measures_Logo, 124, 64)
      SetGadgetState(#Gadget_Measures_Logo, ImageID(#Image_Measures_Logo))
      FrameGadget(#Gadget_Measures_fSeparator4, 535, 5, 5, 55, "", #PB_Frame_Double)
      ImageGadget(#Gadget_Measures_Exit, 545, 5, 54, 54, ImageID(#Image_Measures_Exit))
      TextGadget(#Gadget_Measures_lControl1, 0, 65, 605, 15, "      Save            Load                  Add          Delete            Edit                Help                                                                Exit")
        SetGadgetColor(#Gadget_Measures_lControl1, #PB_Gadget_BackColor, $FFFFFF)
        SetGadgetFont(#Gadget_Measures_lControl1, LoadFont(#Gadget_Measures_lControl1, "Comic Sans MS", 8, 0))
      CloseGadgetList()
      HideWindow(#Window_Measures, 0)
    ProcedureReturn WindowID(#Window_Measures)
  EndIf
EndProcedure

Procedure.i Window_Data()
  If OpenWindow(#Window_Data, 382, 239, 455, 180, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible, WindowID(#Window_Measures))
      SetWindowColor(#Window_Data, $FFFFFF)
      ContainerGadget(#Gadget_Data_cData, 5, 5, 445, 80, #PB_Container_Flat|#PB_Container_BorderLess)
        SetGadgetColor(#Gadget_Data_cData, #PB_Gadget_BackColor, $FFFFFF)
      TextGadget(#Gadget_Data_lAbbreviation, 10, 10, 95, 25, "Abbreviation", #PB_Text_Center)
        SetGadgetColor(#Gadget_Data_lAbbreviation, #PB_Gadget_BackColor, $FFFFFF)
        SetGadgetFont(#Gadget_Data_lAbbreviation, LoadFont(#Gadget_Data_lAbbreviation, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_Data_Abbreviation, 110, 10, 325, 25, "", #PB_String_BorderLess)
        SetGadgetColor(#Gadget_Data_Abbreviation, #PB_Gadget_BackColor, $F2F2F2)
        SetGadgetFont(#Gadget_Data_Abbreviation, LoadFont(#Gadget_Data_Abbreviation, "Comic Sans MS", 10, 0))
      TextGadget(#Gadget_Data_lMeaning, 10, 40, 95, 25, "Meaning", #PB_Text_Center)
        SetGadgetColor(#Gadget_Data_lMeaning, #PB_Gadget_BackColor, $FFFFFF)
        SetGadgetFont(#Gadget_Data_lMeaning, LoadFont(#Gadget_Data_lMeaning, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_Data_Meaning, 110, 40, 325, 25, "", #PB_String_BorderLess)
        SetGadgetColor(#Gadget_Data_Meaning, #PB_Gadget_BackColor, $F2F2F2)
        SetGadgetFont(#Gadget_Data_Meaning, LoadFont(#Gadget_Data_Meaning, "Comic Sans MS", 10, 0))
      CloseGadgetList()
      ContainerGadget(#Gadget_Data_cControl, 5, 90, 445, 85, #PB_Container_Flat|#PB_Container_BorderLess)
        SetGadgetColor(#Gadget_Data_cControl, #PB_Gadget_BackColor, $FFFFFF)
      ImageGadget(#Gadget_Data_Save, 5, 5, 54, 54, ImageID(#Image_Data_Save))
      FrameGadget(#Gadget_Data_fSeparator1, 65, 5, 5, 55, "", #PB_Frame_Double)
      ImageGadget(#Gadget_Data_Logo, 230, 0, 124, 64, ImageID(#Image_Data_Logo))
      ResizeGadget(#Gadget_Data_Logo, 230, 0, 124, 64)
      ResizeImage(#Image_Data_Logo, 124, 64)
      SetGadgetState(#Gadget_Data_Logo, ImageID(#Image_Data_Logo))
      FrameGadget(#Gadget_Data_fSeparator2, 370, 5, 5, 55, "", #PB_Frame_Double)
      ImageGadget(#Gadget_Data_Exit, 380, 5, 54, 54, ImageID(#Image_Data_Exit))
      TextGadget(#Gadget_Data_lControl1, 0, 65, 443, 15, "      Save                                                                                                                     Exit")
        SetGadgetColor(#Gadget_Data_lControl1, #PB_Gadget_BackColor, $FFFFFF)
        SetGadgetFont(#Gadget_Data_lControl1, LoadFont(#Gadget_Data_lControl1, "Comic Sans MS", 8, 0))
      CloseGadgetList()
      HideWindow(#Window_Data, 0)
    ProcedureReturn WindowID(#Window_Data)
  EndIf
EndProcedure

Declare   MakePreferences()
Declare   ListPreferences()

Declare   AddMEasure()
Declare   DeleteMeasure()
Declare   EditMeasure()
Declare   SaveMeasure()

Declare   SavePreferencesToFile()
Declare   LoadPreferencesFromFile()

#MeasuresListCharacterColumn  = 0                                                                     ;
#MeasuresListReplaceColumn    = 1                                                                     ;

#AtTheEndOfTheList            = -1                                                                    ; 
#FileDoesNotExist             = -1                                                                    ; 
#NoFileHandle                 = 0                                                                     ; 
#EmptyString                  = ""                                                                    ; 
#NothingSelected              = -1                                                                    ; 
#NoItems                      = 0                                                                     ; 

Structure ProgramData
  QuitValue.i                                                                                         ; 
  LastWindow.s                                                                                        ; 
  WindowMutex.i                                                                                       ; 
  
  CurrentLine.i                                                                                       ; 
  CurrentDirectory.s                                                                                  ; 
  
  PreferencesFile.s                                                                                   ; 
  
  OldSearchWord.s                                                                                     ; 
  OldReplaceWord.s                                                                                    ; 
EndStructure

Structure MeasuresListData
  SearchWord.s                                                                                        ; 
  ReplaceWord.s                                                                                       ; 
  RecordNumber.s                                                                                      ; 
EndStructure

Global Program.ProgramData                                                                            ; 
Global NewList MeasuresList.MeasuresListData()                                                       ; 

Program\CurrentDirectory = GetCurrentDirectory()                                                      ; 
Program\PreferencesFile  = Program\CurrentDirectory  + "Measures.prefs"                               ; 

DataSection
  
  BeginMeasures:
  
  Data.s "sl",              "Slice"
  Data.s "c",               "Cup"
  Data.s "g",               "Gram"
  Data.s "gms",             "Grams"
  Data.s "kg",              "Kilogram"
  Data.s "kil",             "Kilogram"
  Data.s "l",               "Litre"
  Data.s "lb",              "Pound"
  Data.s "ml",              "Millilitre"
  Data.s "oz",              "Ounce"
  Data.s "pt",              "Pint"
  Data.s "pn",              "Pinch"
  Data.s "ts",              "Teaspoon"
  Data.s "tbsp",            "Tablespoon"
  Data.s "cl",              "Clove"
  Data.s "lg",              "Large"
  Data.s "bn",              "Bunch"
  Data.s "ds",              "Dash"
  Data.s "tb",              "Tub"
  Data.s "doz",             "Dozen"
  Data.s "gal",             "Gallons"
  Data.s "pkg",             "Package"
  Data.s "pk",              "Packet"
  Data.s "pkt",             "Packet"
  Data.s "qt",              "Quart"
  Data.s "sm",              "Small"
  Data.s  "_EndMeasures_",  "_EndMeasures_"
  
EndDataSection

; These are the default preferences created at program start

Procedure MakePreferences()
  CreatePreferences(Program\PreferencesFile, #PB_Preference_GroupSeparator)
  PreferenceComment(#EmptyString)
  PreferenceGroup("Measure correction")
  PreferenceComment(#EmptyString)
  Restore BeginMeasures
  While StringToFind.s <> "_EndMeasures_"  And StringToReplace.s <> "_EndMeasures_"
    Read.s StringToFind.s
    Read.s StringToReplace.s
    If StringToFind.s <> "_EndMeasures_"  And StringToReplace.s <> "_EndMeasures_"
      WritePreferenceString(StringToFind.s, StringToReplace.s)
      AddGadgetItem(#Gadget_Measures_MeasuresList, #AtTheEndOfTheList, StringToFind.s + #LF$ +  StringToReplace.s)
    EndIf
  Wend
  StringToFind.s = "<>"
EndProcedure

; 

Procedure ListPreferences()
  OpenPreferences(Program\PreferencesFile)
  PreferenceGroup("Measure correction")
  ExaminePreferenceKeys()
  While  NextPreferenceKey()
    AddGadgetItem(#Gadget_Measures_MeasuresList, #AtTheEndOfTheList, PreferenceKeyName() + #LF$ +  PreferenceKeyValue())
  Wend
  ClosePreferences()
EndProcedure

; 

Procedure AddMeasure()
  If Program\WindowMutex  <> #True
    Program\WindowMutex  = #True
    If Window_Data()
      Program\LastWindow = "Add"
      SetActiveGadget(#Gadget_Data_Abbreviation)
    Else
      ; Cannot open the program window
    EndIf
  Else
    ; Another window is open and must be closed first
  EndIf
EndProcedure

; 

Procedure DeleteMeasure()
  If Program\CurrentLine  <> #NothingSelected
    OldSearchWord.s   = GetGadgetItemText(#Gadget_Measures_MeasuresList, Program\CurrentLine, #MeasuresListCharacterColumn)
    OldReplaceWord.s  = GetGadgetItemText(#Gadget_Measures_MeasuresList, Program\CurrentLine, #MeasuresListReplaceColumn)
    OpenPreferences(Program\PreferencesFile)
    PreferenceGroup("Measure correction")
    RemovePreferenceKey(OldSearchWord.s)
    ClosePreferences()
 Else
    ; Nothing to do as there is no current line selected
  EndIf
EndProcedure

; 

Procedure EditMeasure()
  Program\CurrentLine = GetGadgetState(#Gadget_Measures_MeasuresList)
  If Program\CurrentLine  <> #NothingSelected
    If Program\WindowMutex  <> #True
      Program\WindowMutex  = #True
      If Window_Data()
        Program\LastWindow = "Edit"
        Program\OldSearchWord   = GetGadgetItemText(#Gadget_Measures_MeasuresList, Program\CurrentLine, #MeasuresListCharacterColumn)
        Program\OldReplaceWord  = GetGadgetItemText(#Gadget_Measures_MeasuresList, Program\CurrentLine, #MeasuresListReplaceColumn)
        SetGadgetText(#Gadget_Data_Abbreviation,  Program\OldSearchWord)
        SetGadgetText(#Gadget_Data_Meaning,       Program\OldReplaceWord)
      Else
        ; Cannot open the program window
      EndIf
    Else
      ; Another window is open and must be closed first
    EndIf
  Else
    ; Nothing to do as there is no current line selected
  EndIf
EndProcedure

; 

Procedure SaveMeasure()
  SearchWord.s  = GetGadgetText(#Gadget_Data_Abbreviation)
  ReplaceWord.s = GetGadgetText(#Gadget_Data_Meaning)
  Select Program\LastWindow
    Case "Add"
      OpenPreferences(Program\PreferencesFile)
      PreferenceGroup("Measure correction")
      WritePreferenceString(SearchWord.s,  ReplaceWord.s)
      ClosePreferences()
    Case  "Edit"
      OpenPreferences(Program\PreferencesFile)
      PreferenceGroup("Measure correction")
      If SearchWord.s <> Program\OldSearchWord
        RemovePreferenceKey(Program\OldSearchWord)
        WritePreferenceString(SearchWord.s,  ReplaceWord.s)
      Else
        WritePreferenceString(SearchWord.s,  ReplaceWord.s)
      EndIf
      ClosePreferences()
  EndSelect
  SetGadgetItemText(#Gadget_Measures_MeasuresList, Program\CurrentLine, SearchWord.s, #MeasuresListCharacterColumn)
  SetGadgetItemText(#Gadget_Measures_MeasuresList, Program\CurrentLine, ReplaceWord.s, #MeasuresListReplaceColumn)
  CloseWindow(#Window_Data)
  Program\WindowMutex = #False
  Program\LastWindow = #EmptyString
EndProcedure

; 

Procedure LoadPreferencesFromFile()
  If MessageRequester("Load preferences", "Overwrite from file?", #PB_MessageRequester_YesNo)  = #PB_MessageRequester_Yes
    PreferencesFileName.s = OpenFileRequester("Import Measures", "", "Text (*.txt)|*.txt", 0)
    If PreferencesFileName.s  <> #EmptyString
      PreferencesFileHandle.i = ReadFile(#PB_Any, PreferencesFileName.s)
      If PreferencesFileHandle.i  <> #NoFileHandle
        OpenPreferences(Program\PreferencesFile)
        PreferenceGroup("Measure correction")
        ExaminePreferenceKeys()
        While  NextPreferenceKey()
          RemovePreferenceKey(PreferenceKeyName())
        Wend
        While Eof(PreferencesFileHandle.i)  = #NotEndOfFile
          PreferenceString.s   = ReadString(PreferencesFileHandle.i, #PB_UTF8)
          StringToFind.s    = StringField(PreferenceString.s, 1, ",")
          StringToReplace.s = StringField(PreferenceString.s, 1, ",")
          AddGadgetItem(#Gadget_Measures_MeasuresList, #AtTheEndOfTheLine, StringToFind.s + #LF$  + StringToReplace.s)
          WritePreferenceString(StringToFind.s, StringToReplace.s)
        Wend
        CloseFile(PreferencesFileHandle.i)
        ClosePreferences()        
      Else
        ; Could not create a file on disk, file I/O error
      EndIf
    Else
      ;  No file to export as user cancelled the process
    EndIf
  Else
    ; Nothing to do as user cancelled the process
  EndIf
EndProcedure  

; 

Procedure SavePreferencesToFile()
  NumberOfItems.i = CountGadgetItems(#Gadget_Measures_MeasuresList)
  If NumberOfItems.i <> #NoItems
    PreferencesFileName.s = SaveFileRequester("Export Measures", "", "Text (*.txt)|*.txt", 0)
    If PreferencesFileName.s  <> #EmptyString
      If LCase(GetExtensionPart(PreferencesFileName.s))  <>  "txt"
        PreferencesFileName.s + ".Txt"
      EndIf
      PreferencesFileHandle.i = CreateFile(#PB_Any, PreferencesFileName.s)
      If PreferencesFileHandle.i  <> #NoFileHandle
        For GetPreferenceItems.i = 0 To NumberOfItems.i - 1
          SearchWord.s   = GetGadgetItemText(#Gadget_Measures_MeasuresList, GetPreferenceItems.i, #MeasuresListCharacterColumn)  + ","
          ReplaceWord.s  = GetGadgetItemText(#Gadget_Measures_MeasuresList, GetPreferenceItems.i, #MeasuresListReplaceColumn)
          WriteStringN(PreferencesFileHandle.i, SearchWord.s  + ReplaceWord.s, #PB_UTF8)
        Next GetPreferenceItems.i
        CloseFile(PreferencesFileHandle.i)
      Else
        ; Could not create a file on disk, file I/O error
      EndIf
    Else
      ;  No file to export as user cancelled the process
    EndIf
  Else
    ; No items in the list to process
  EndIf
EndProcedure

If Window_Measures()

  ; 
  
  Program\QuitValue = #False
  
  ; 

  If FileSize(PreferencesFile.s) = #FileDoesNotExist
    MakePreferences()
  Else
    ListPreferences()
  EndIf  
  
  ; 
  
  Repeat
    EventID  = WaitWindowEvent()
    MenuID   = EventMenu()
    GadgetID = EventGadget()
    WindowID = EventWindow()
    Select EventID
      Case #PB_Event_CloseWindow
        Select WindowID
          Case #Window_Measures                     : Program\QuitValue = #True
          Case #Window_Data                         : CloseWindow(#Window_Data) : Program\WindowMutex = #False  : Program\LastWindow = #EmptyString
        EndSelect
      Case #PB_Event_Gadget
        Select GadgetID
          ; 
          Case #Gadget_Measures_MeasuresList
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    : EditMeasure()
              Case #PB_EventType_RightDoubleClick   : AddMeasure()
            EndSelect
            ; 
          Case #Gadget_Measures_Save
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    : SavePreferencesToFile()
            EndSelect
          Case #Gadget_Measures_Load
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    : LoadPreferencesFromFile()
            EndSelect
            ; 
          Case #Gadget_Measures_Add
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    : AddMeasure()
            EndSelect
          Case #Gadget_Measures_Delete
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    : DeleteMeasure() 
            EndSelect
          Case #Gadget_Measures_Edit
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    : EditMeasure() 
            EndSelect
            ; 
          Case #Gadget_Data_Save
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    :  SaveMeasure()
            EndSelect
            ; 
          Case #Gadget_Data_Exit
            Select EventType()
              Case #PB_EventType_LeftDoubleClick    :  CloseWindow(#Window_Data) : Program\WindowMutex = #False  : Program\LastWindow = #EmptyString
            EndSelect
            ; 
        EndSelect
    EndSelect
  Until Program\QuitValue = #True
  CloseWindow(#Window_Measures)
EndIf
End
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

The code I posted above has been finally integrated into 'Recipes' but I wanted to know if people wanted one big update with an 11 meg archive that contains the source and the updated CHM/EPUB/PDF/DOCX help files or two separate archives to keep the size down?

And then there is the separate 137 meg recipe database produced from the Living CookBook FDXZ compresses recipes that I get every week? (To be separately uploaded).

I am just assuming that anyone is following this:)

Would love help with this project, I am exhausted.
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

This will be my last update, I am using the program in full working mode for home. May get to upload next week.

Fixed: Ingredient measure correction was still using hard coded dictionary instead of preference file.
Fixed: Ingredient measure correction was not added to the list of preferences to be saved on setup save.
Fixed: Ingredient measure correction was not loaded from the list of saved preferences in the setup screen.
Fixed: Ingredient measure correction was not fixing the case of the measures. More to do on this.
Fixed: Ingredient measure correction was missing some translations such as Tbsp = Tablespoon etc.
Fixed: The measures window was still disabled when the add/edit sub windows were closed.
Fixed: For some reason, I had forgotten to change Title to Recipetitle in one of my code blocks so the database sent back confused results.
Fixed: A problem in the generated SQL when using the OR operator was causing all records to be returned. Hope it's fixed now.
Fixed: Lots of spelling mistakes.

Added: Formatting of recipe numbers and current recipe with commas in the right places.
Added: During import, the display will scroll downwards to keep each addition in view. This is only if the visible counter option is enabled.
Added: The import window remembers the last directory imported from and the last import type used.
Added: A window to list all used keyboard shortcuts.
Added: Missing option in the titles list popup menu for CreateRecipes..
Added: Missing option in the events list CreateRecipes.
Added: Counter now updates as records and displayed during a 'find' or category load.
Added: Separate ingredient measure editor and manager.
Added: Separate recipe title bad string editor and manager.
Added: Searching and higlighting of strings in keyboard shortcuts screen.
Added: Last keyboard shortcut text is saved immediately on use and restored when shortcut form is opened.

Changed: Only index is on RecipeTitle field now, save space and time. 42,000 records in the program gives reasonable performance. Could be better.
Changed: No more searching on all fields at once. It was causing a massive drain on performance. Just select the field you want to search and go from there.
Changed: Procedures that are sub-procedures of others are placed under them as subdirectories for better reading.
Changed: CloseMyWindow and CloseMySubWindow procedures have all been smartly merged.
Changed: Keyboard shortcut search text is saved to local preference file instead of being a temporary program variable.

Removed: The "Delete import file after import" was removed from the menu and put into setup where it belonged.
Removed: All screen and gadget locking. They were the cause of all that lockup and slowdown. They just don't work here. For me, a While WindowEvent() : Wend works.

Jack, anything on the testing you promised?
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

Current recipes project

https://www.dropbox.com/sh/pqj0fi4g4nuz ... LnOMa?dl=0

Recipes-Database.7z 110Meg Sample database from the Living CookBook recipe forum.
Recipes-Helpfiles.7z 11.5Meg PDF, EPUB, DOC, CHM help files
Recipes.7z 1.65Meg Current project source
Amateur Radio, D-STAR/VK3HAF
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Recipe management software?

Post by jack »

hi Fangbeast, thanks for the update. :)
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

jack wrote:hi Fangbeast, thanks for the update. :)
That's okay but where is the testing you promised to do??
Amateur Radio, D-STAR/VK3HAF
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Recipe management software?

Post by jack »

the recipe list population method has changed in your latest version, the list is displayed/updated as it reads the database, in previous version it would display the list after reading the database, the previous method was quite a bit faster though it might take a couple of seconds before the recipe list would be displayed on start-up.
will test a bit more later.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

the recipe list population method has changed in your latest version, the list is displayed/updated as it reads the database
Not at all. In the previous iterations, with huge databases of up to a gigabyte, I found that the slowdown was so bad that the menubar didn't show up, the statusbar didn't show up and the list 'blinked' and showed the round ms circle meant to show us that something was happening.

And god forbid that you click on the form, then it would stop responding alltogether.

I had to stop using the LockWindowUpdate (and another one, WM_REDRAW) because they were not helping here.

Right or wrong, I use WhileWindowevent():Wend here and a SendMessage API to scroll to the last line added as it's being added but the database read hasn't changed, just the method of populating the screen.

Just had enough of the lockups and slowness.

I also put a limit of displaying 100 records on startup, that also helped a lot.
the previous method was quite a bit faster though it might take a couple of seconds before the recipe list would be displayed on start-up.
That's the frustrating part, here it was incredibly slow, the bigger the database.

And I am getting more and more convinced that Windows 10 is responsible. Since the last two O/S updates, both mozilla products may take seconds to become 'responsive' before they present themselves as ready and firefox may appear to hang just by me selecting bookmarks.

Other applications are also much slower to startup and I'll be buggered if I know why.
will test a bit more later.
Thanks, I am still cleaning out little buglets but am doing doing too much as I am in a fair bit of pain these days.

Frankly, I need the help
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

09/05/2016

Changed: All single value fields such as Deleted, Favourite etc, have been changed to BOOLEAN in database creation and read as longs from the database. (Suggestion from various people)
Changed: RecipeRating field is also handles as an integer now instead of a string.
Changed: Simple toggle fields are all handles as #True or #False instead of strings except for some very rare cases.

Fixed: Record retrieval fields were mixed up in some procedures or incorrectly handled.
Fixed: Category string check didn't agree with the message warning about the limit of character length.

Added: More missing update and status messages throughout the program.
Added: More comments to various areas of code to help people track what is going on.
Added: More literals have been replaced by wordier constants to help me keep track of what I am doing.

07/05/2016

Added: If there is a user supplied category in the recipe being saved, it gets added to the category bar if it doesn't already exist. Only the first one if there is more than one, separated by comma.

Updated: All external help files.

05/05/2016

Added: Extra details in preferences file for later database statistics reporting window.
Added: AND51's file size calculation and formatting with correct suffix for various areas.

04/05/2016

Fixed: Some hard coded column numbers existed in TransferRecipes instead of readable variable names.
Fixed: Main form search text showed double quotes instead of single. Forgot to strip them when saving to preference file.
Fixed: Removed item from transfer list only when pictures and ingredients were also saved but that was wrong if recipe transfer worked.
Fixed: Last update field in Edit Recipe was empty. This is now displayed as the record's own last update date.

Added: A display field above search/field/text box indicates what the current limit of displayed recipes in the list are.
Added: When attaching a new database, previous one is detached and the list of wanted recipes is cleared as they are no longer valid.
Added: When selecting a new database to attach, user is asked if they really want to do this and lose all their searches and wanted recipes.
Added: Better control over database attachment in the recipe transfer form and removed a redundant DatabaseHandle check.
Added: Internally, dates are stored in international ISO format "2016-04-05" as it's accurate for database searches. Shown as normal on forms (05/04/2016)
Current recipes project

https://www.dropbox.com/sh/pqj0fi4g4nuz ... LnOMa?dl=0

Recipes-Database.7z 110Meg Sample database from the Living CookBook recipe forum.
Recipes-Helpfiles.7z 11.5Meg PDF, EPUB, DOC, CHM help files
Recipes.7z 1.65Meg Current project source

Let me know if the links don't work. Give it another 40 minutes to finish uploading the updates to dropbox.

But reports and testing would be welcome.
Last edited by Fangbeast on Wed May 11, 2016 7:52 am, edited 1 time in total.
Amateur Radio, D-STAR/VK3HAF
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Recipe management software?

Post by jack »

hi Fangbeast
the download link got mangled but the link about 6 post prior works.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Recipe management software?

Post by Fangbeast »

jack wrote:hi Fangbeast
the download link got mangled but the link about 6 post prior works.
Grrr, I hate mangling!!

Fixed the link in the download.
Amateur Radio, D-STAR/VK3HAF
Post Reply