MealMaster: Decoding text file format to database
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Moderator, Please remove this post, outdated.
Last edited by Fangbeast on Mon Jan 14, 2013 1:48 am, edited 2 times in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Whoever uploaded the icon, it looks good even in 48x48 view on my desktop, thanks for that.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
-
- New User
- Posts: 3
- Joined: Thu Jul 10, 2008 12:29 am
- Location: USA
Re: MealMaster: Decoding text file format to database
Change this line:
to this:
Remove the comment marks in these lines;
to get just one recipe. Other wise it will run thru the whole file.
Some very good work, open my eyes to a different way of coding.
Thanks, hope this helps.
Charles556
P.S. this is from the code snippet on page 4 by Fangbeast
Code: Select all
If Len(Line.s) = 5 And (Line.s = "MMMMM" Or Line.s = "-----")
Code: Select all
If Line.s = "MMMMM" Or Line.s = "-----"
Code: Select all
Debug "----------**********//////////\\\\\\\\\\**********----------"
;CloseFile(RecipeFileHandle.i )
;ProcedureReturn
State = #RecipeNone
Some very good work, open my eyes to a different way of coding.
Thanks, hope this helps.
Charles556
P.S. this is from the code snippet on page 4 by Fangbeast
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
I do want it to go through the whole file. It's doing that but not ending when it has finished and I don't know why.to get just one recipe. Other wise it will run thru the whole file.
Logic isn't my strong suit:)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
- OldSkoolGamer
- Enthusiast
- Posts: 150
- Joined: Mon Dec 15, 2008 11:15 pm
- Location: Nashville, TN
- Contact:
Re: MealMaster: Decoding text file format to database
That was me, found it on a free icon site when I first d/l the program, been meaning to upload it, but kept forgetting....Fangbeast wrote:Whoever uploaded the icon, it looks good even in 48x48 view on my desktop, thanks for that.

Unfortunately I haven't had any time to take a good look at the source this weekend, but maybe this week at work I can.....
Re: MealMaster: Decoding text file format to database
Nice job guys, I love to cook!
Hope you don't mind if I butt in.. I pasted the code from the forum into my PB it and works very well. I found a bug where you load a file. If you then cancel the action it will no longer display a recepie that you click on. I fixed the bug, and I wanted to upload my fix to box but now everything has changed. Not only that but the program no longer works for me. Am I downloading the wrong file perhaps?
Thanks for the code!
Jack
Hope you don't mind if I butt in.. I pasted the code from the forum into my PB it and works very well. I found a bug where you load a file. If you then cancel the action it will no longer display a recepie that you click on. I fixed the bug, and I wanted to upload my fix to box but now everything has changed. Not only that but the program no longer works for me. Am I downloading the wrong file perhaps?
Thanks for the code!
Jack

Make everything as simple as possible, but not simpler. ~Albert Einstein
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Moderator, Please remove this post, outdated.
Last edited by Fangbeast on Mon Jan 14, 2013 1:49 am, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Re: MealMaster: Decoding text file format to database
Great project, I'm planning to take a look at it when time permits.
Fangbeast, like LuCiFeR[SD] said, BitBucket is probably the best place to host the code. That way anyone can easily download the lastest version of the code.
Fangbeast, like LuCiFeR[SD] said, BitBucket is probably the best place to host the code. That way anyone can easily download the lastest version of the code.
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Moderator, Please remove this post, outdated.
Last edited by Fangbeast on Mon Jan 14, 2013 1:49 am, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Re: MealMaster: Decoding text file format to database
Code: Select all
Enumeration
#RecipeNone
#RecipeVersion
#RecipeCategory
#RecipeServes
#RecipeIngredients
#RecipeInstructions
EndEnumeration
; Get and display recipe details when a title is clicked on
Procedure ImportMealMaster()
;
Protected.i Result.i, File.i, State.i, Pos.i, Count, i
Protected Line.s, Text.s, Version.s, Title.s, Category.s, Yield.s, Ingredients.s, Method.s
;
RecipeFileName.s = OpenFileRequester("Choose a Meal-Master file", "", "MealMasterFile|*.mmf|TextFile|*.txt|All|*.*", 1)
;
If RecipeFileName.s <> ""
;
RecipeFileHandle.i = ReadFile(#PB_Any, RecipeFileName.s)
;
If RecipeFileHandle.i
;
While Not Eof(RecipeFileHandle.i)
; Read a line of text from the file
Line.s = ReadString(RecipeFileHandle.i)
; Check which part of the file we are processing
Select State
; No recipe found yet
Case #RecipeNone
Pos = FindString(Line.s, "Meal-Master")
If Pos
Version.s = Trim(Mid(Line.s, Pos + 11))
For i = 1 To Len(Version)
If ValF(Mid(Version, i)) > 0
Version = Mid(Version, i)
Break
EndIf
Next i
Title.s = ""
Category.s = ""
Yield.s = ""
Ingredients.s = ""
Method.s = ""
State = #RecipeVersion
EndIf
; Recipe version number found
Case #RecipeVersion
Pos = FindString(Line.s, "Title:")
If Pos
Title.s = Trim(Mid(Line.s, Pos + 7))
State = #RecipeCategory
EndIf
; Recipe category found
Case #RecipeCategory
Pos = FindString(Line.s, "Categories:")
If Pos
Category.s = Trim(Mid(Line.s, Pos + 12))
State = #RecipeServes
EndIf
; Recipe yield found
Case #RecipeServes
Count = Len(Line.s)
For i = 1 To Count
If Val(Mid(Line.s, i)) > 0
Yield.s = Trim(Mid(Line.s, i))
State = #RecipeIngredients
Break
EndIf
Next i
; Recipe ingredients found
Case #RecipeIngredients
If Trim(Line) <> ""
If Val(Trim(Line.s)) > 0
Line.s = Trim(Line.s)
Pos = FindString(Line.s, " ")
If Pos
Ingredients.s + Trim(Left(Line.s, Pos)) + " "
Ingredients.s + Trim(Mid(Line.s, Pos)) + #LF$
Else
Ingredients.s + Trim(Line.s) + #LF$
EndIf
Else
If Trim(Left(Line.s, 3)) <> ""
If Left(Line.s, 5) = "MMMMM"
Ingredients.s + Trim(Mid(Line.s, 6), "-") + #LF$
Else
Method.s = Line.s + #LF$
State = #RecipeInstructions
EndIf
Else
Line.s = Trim(Line.s)
If Left(Line.s, 1) = "-"
Ingredients.s = Left(Ingredients.s, Len(Ingredients.s) - 2) + " " + Trim(Mid(Line.s, Pos), "-") + #LF$
Else
Ingredients.s + Trim(Mid(Line.s, Pos), "-") + #LF$
EndIf
EndIf
EndIf
EndIf
; Recipe method found
Case #RecipeInstructions
If Len(Line.s) = 5 And (Line.s = "MMMMM" Or Line.s = "-----")
;Debug Version.s
;Debug Title.s
;Debug Category.s
;Debug Ingredients.s
;Debug Yield.s
;Debug Method.s
;Debug "----------**********//////////\\\\\\\\\\**********----------"
RecipeCounter + 1
Debug Str(RecipeCounter.i) + " Recipes"
State = #RecipeNone
Else
If Len(Line.s) <> 0
Method.s + Line.s + #LF$
EndIf
EndIf
; No more headings to see
EndSelect
; Continue processing the current recipe until the end marker is found
Wend
CloseFile(RecipeFileHandle.i)
Else
Debug "File wasn't opened slughead, no file handle"
EndIf
Else
Debug "User cancelled the file open operation"
EndIf
EndProcedure
ImportMealMaster()
Re: MealMaster: Decoding text file format to database
No worries mate. I ended up registering an account with Box and downloaded your code.Fangbeast wrote:@Lost I just had a quick look at BitBucket and it's not for me. Way, way too complicated for my life!!!
@Everyone else. I have uploaded the latest version 'RecipeMuncher0.00b.7z' to Box.com, same link as before.
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Moderator, Please remove this post, outdated.
Last edited by Fangbeast on Mon Jan 14, 2013 1:49 am, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Moderator, Please remove this post, outdated.
Last edited by Fangbeast on Mon Jan 14, 2013 1:50 am, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Moderator, Please remove this post, outdated.
Last edited by Fangbeast on Mon Jan 14, 2013 1:50 am, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: MealMaster: Decoding text file format to database
Moderator, Please remove this post, outdated.
Last edited by Fangbeast on Mon Jan 14, 2013 1:50 am, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet