Welcome, Guest. Please login or register.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Columbo

Pages: [1] 2 3 ... 35
1
Database programming / Re: Importing from a text file.
« on: May 13, 2019, 10:15:16 AM »
No problem Syed,  As I mentioned in the post at Purebasic Forum, I didn't understand that it recreated the database each time it was run.  It does work really well though.  Thanks

Cheers!

John

2
Database programming / Re: Importing from a text file.
« on: May 12, 2019, 11:03:16 PM »
Thanks Syed.  Actually I was thinking of having a button in my recipe program that would allow me to run your Meal-Master program to import recipes from .mmf files.  That is why I was wondering if it would return to my Master Chef program after it finished importing the recipes.  I gues befor I try that I have to find out why when importing a ,mmf file it over writes the files that are already in the database.

John


3
Database programming / Re: Importing from a text file.
« on: May 11, 2019, 08:00:20 PM »
Thanks Syed.  Works great now. Another quick question for you if you don't mind.  I know that you can run an external program from within Purebasic but once the external program ends, does it return to the Purebasic program that called it?

Thanks and as always very much appreciated.

4
Database programming / Re: Importing from a text file.
« on: May 10, 2019, 06:53:32 PM »
Yes,  thanks Syed. 

I was looking at your code and it works with your recipes.txt file but since Meal-Master files use the .mmf extension, I changed the file to recipes.mmf and changed line 29 in the code to If OpenFile(0, "recipes.mmf") but now it doesn't import anything.  Not sure why?  I checked the code and I don't see any other lines that reference the text file name that should also be changed.  The other thing is that when using the text file as recipes.txt and your code uses While Not Eof(0), it only imports 3 recipes even though there are a fairly large number of recipes in the file.  ??

Also, just so that I can understand what is happening in the code, to set the data to be inserted into the database, are you using bind variables?  (Not sure because I have never used them before).

"INSERT INTO " +
"recipes (recipe, scat, serves, ingredients, directions) " +
"VALUES (?, ?, ?, ?, ?)"     


John

5
Database programming / Importing from a text file.
« on: May 09, 2019, 04:21:51 PM »
Here is a challenge!  I have a text file that contains a number of Meal-Master recipes.  What I need to do is read the file, grab the title, category, yield, ingredients and directions and assign them to variables which will then be written to a database.  In other words I want to import all of the recipes in the text file, one at a time, into a database.

Here is the first 2 recipes in the file to show an example of the Meal-Master format:

Code: [Select]

---------- Recipe via Meal-Master (tm) v8.02
 
      Title: CAJUNIZED ORIENTAL PORK CHOPS
 Categories: Meats
      Yield: 6 servings
 
      6 ea Thick pork chops
      1 x  Salt & red cayenne pepper
  1 1/2 c  Dry white wine
      1 c  Bell pepper, chopped
      1 c  Onions, chopped
      1 ea Clove garlic, chopped
      3 T  Soy sauce
      1 cn Pinapple chunks (15 oz.)
 
  Salt and red pepper the chops.  Brown them slowly in a skillet.
  Add wine, bell pepper, onion, and garlic,  Cover and simmer for
  25 to 30 minutes.  Remove pork chops, being sure to keep them warm.
  Add the soy sauce and syrup from the pineapple.  Stir and simmer
  until more or less thick.  Add the pineapple chunks and bring to
  a boil.  Serve over pork chops and hot cooked rice.
  From Justin Wilson's "Gourmet and Gourmand Cookbook"
 
-----
 
---------- Recipe via Meal-Master (tm) v8.02
 
      Title: BARBECUED PORK CHOPS
 Categories: Meats
      Yield: 8 servings
 
    1/2 c  Water
    1/4 c  Vinegar
      2 T  Dry mustard
      3 T  Brown sugar
      4 T  Chili sauce
      8 ea Pork chops
 
  Combine ingredients and mix well.  Pour over seasoned chops
  in glass baking dish, cover and bake at 400 F degrees for
  1-1/2 hours, uncovering last 30 minutes.  Water may be added
  to make gravy.  Delicious with ribs also. 
-----



We know where each recipe begins because it starts with the following header line to indicate that it is the start of a Meal-Master recipe.
Code: [Select]
---------- Recipe via Meal-Master (tm) v8.02

The line with the 5 dashes (-----) indicates the end of that particular recipe.

I am trying to use ReadFile(#srcFile, srcFile)to read the text file a line at a time and While Eof(#srcFile) = 0 to look for the end of the file and fileLIne = Trim(ReadString(#srcFile)) to get the line read however, the problem is that I obviously do not want to save the header line, any blank lines, or the end of file marker, ď-----ď to the database. Also, the bigger problem is that the ingredients and the directions can have any number of lines which would have to be captured and written to the database.

The ingredients are preceded and followed by a blank line which Iím thinking I might be able to use to indicate the start and end of the ingredients.  The same idea for the directions.  Once the title, category, yield, ingredients and directions are assigned to variables and written to a database, it would then do the same thing again for each of the following recipes in the text file.  The database is recipes, the table is recipe and the columns are scat, recipe, ingredients, directions, serves which would be written to  category,  title, yield, ingredients and directions.


I have tried several ways to do this but I am unable to achieve the desired result.  I am able to get the title, category, and yield assigned to variables but I canít seem to come up with a way to get all of the lines in the ingredients and all of the lines in the directions saved to variables so that they can all be saved into the database.

Can someone give me an example of how best to achieve this?

Thanks.






6
General Discussion / Re: Problem with AddKeyboardShortcut()
« on: May 07, 2019, 11:07:24 PM »
Thanks Syed,  Works now.  That had me really baffles since the actual code was identical to the code I used in my PrehistoricLife program.  It worked there but not in this program.

Cheers!

John


7
General Discussion / Re: Image hidden by other image
« on: May 07, 2019, 11:01:00 PM »
I'll give it a shot Syed and let you know what happens.  I thought it a bit odd that Purebasic doesn't support z-order.  I also found it odd that it supports the If, Else but not the EsleIf statement.  Most basic languages do.  Not a big deal, of course, but just thought it odd.

Cheers!

8
General Discussion / Problem with AddKeyboardShortcut()
« on: May 07, 2019, 03:56:41 PM »
I'm having a problem getting my AddKeyboardShortcut() to work.  I want the user to be able to type a string into the StringGadget which is my #searchBox. This is the code that I used in the window setup:

Code: [Select]
wFlags = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget           ;Window flags
If OpenWindow(#MainWindow, 0, 0, 1280, 700, "", wFlags)     ;Open Main Window
  SetWindowColor(#MainWindow, RGB(255,255,255))
  AddKeyboardShortcut(#MainWindow, #PB_Shortcut_Return, #kbdSearch)     ;Trap keyboard input
 EndIf

This is the StringGadget:

Code: [Select]

 Procedure setupscreenMain()
  LoadFont(#searchFont,"Arial",11)   
  ImageGadget(#header,0,0,1206,180,ImageID(#img1))
  DisableGadget(#header,1)
  ImageGadget(#footer,0,667,1206,30,ImageID(#img2))
  ButtonImageGadget(#homeBtn, 250, 161, 99,30, ImageID(#img3))
  ButtonImageGadget(#categoriesBtn, 350, 161, 99,30, ImageID(#img5))
  ButtonImageGadget(#favouritesBtn, 450, 161, 99,30, ImageID(#img7))   
  ButtonImageGadget(#addBtn, 550, 161, 99,30, ImageID(#img9))
  ButtonImageGadget(#addCatBtn, 650, 161, 99,30, ImageID(#img30))
  ButtonImageGadget(#exitBtn, 750, 161, 99,30, ImageID(#img13))
  StringGadget(#searchBox,999, 51, 206, 25,"",#SS_CENTERIMAGE)     ; <---  The search box
  ButtonImageGadget(#searchBtn, 1212, 50, 37,26, ImageID(#searchBtn))
  SetGadgetFont(#searchBox, FontID(#searchFont))
  SetActiveGadget(#searchBox)
 
EndProcedure


And this is where I capture the event:

Code: [Select]

Repeat
    Select WaitWindowEvent()                  ;Wait for an event         
       
      Case #PB_Event_CloseWindow          ;Close window if "X" is clicked.
        run = 1                           ;Set run flag To 1       
       
       Case #PB_Event_Menu       
         Select EventMenu()
           Case #kbdSearch                   ;Check for keyboard event.
             If GetActiveGadget() = #searchBox   ;Check if searchBox box is being used.
                    hidethegadgets()
                    search()
                    HideGadget(#labelsearchLV,0)
                    HideGadget(#LVsearch,0)
                    HideGadget(#searchSelectBtn,0)
                    HideGadget(#searchCancelBtn,0)
                    SetGadgetText(#searchBox, "")          ;Clear the last search string from search box.
                    populateSearchList()
                EndIf                         
       EndSelect
       
       Select EventWindow()     
        Case #MainWindow           ;If the event is from the MainWindow
          run = 1                  ;Set run flag to 1
             
       EndSelect
       
              Case #PB_Event_Gadget
                Select EventGadget()
                    .....
                    .....


I used this same code in a previous program and it works fine.  In my current program, when I type a string into the StringGadget and press the enter key the program just quits.  Its like I had clicked the 'X' in the window.  I have placed debugs all the way through the steps and althoughy the searchString is correct, and the database finds the recipes, the Listview is not visible.  If I do a IsWindowVisible_(GadgetID(#LVsearch)) I get a 1 indicating that it is visible.

Any ideas?


9
General Discussion / Re: Image hidden by other image
« on: May 07, 2019, 01:45:43 PM »
I changed the identifier for the image to #img40 but still not working.  I have decided not to used that image as a background image and just go with a StringGadget for the search procedure.

Thanks for your suggestion though Syed

John

10
General Discussion / Re: Image hidden by other image
« on: May 05, 2019, 01:54:08 PM »
I tried a few different suggestions but second ImageGadget() continues to be hidden behind the first ImageGadget().  Strangely enough, if I place a StringGadget there instead of the ImageGadet, it is visible on top of the first ImageGadget().  A button placed there is also visible so it seems like only the ImageGadget() gets hidden behind the first ImageGadget().  So, since I couldn't get the second ImageGadget() to work, I have decided to use the StringGadget() for the search box instead of a background image.

11
General Discussion / Image hidden by other image
« on: May 04, 2019, 07:36:54 PM »
I have an ImageGadget placed on my screen and have disabled it.  I am now trying to place another smaller ImageGadget on top of it but it is always hidden behind the larger ImageGadget no matter where in the code I place the smaller ImageGadget.  How do you make the smaller ImageGadget the top most gadget?

Thanks

12
General Discussion / Re: My Recipe program for Syed
« on: May 04, 2019, 02:49:57 PM »
Once again,....   Works Perfectly!

You really are a Purebasic Guru.  :)

Thanks again my friend.

John

13
General Discussion / Re: My Recipe program for Syed
« on: May 04, 2019, 12:26:43 PM »
Thanks Syed.  Could I ask you one more question?

Is there a way to change the cursor to a hand when hovering over the TextGadget and back to the arrow when not over the TextGadget?  Just thought it would be a good indication that the TextGadget is clickable.

Thanks

John

14
General Discussion / Re: My Recipe program for Syed
« on: May 04, 2019, 10:56:08 AM »
Thanks Syed,  it works perfectly!  The main reason that I started this program was that I hadn't touched Purebasic for a year and I needed to jog my memory on how to program with it, (keywords etc,).   I was almost like learning all over again.  :)    The Listview population problem rally had me stumped though.  I played around with that for 4 or 5 days.

I'll play around a bit with that CanvasGadget() a bit as well to get to know more about it.

As always,...  Thanks my friend.


15
General Discussion / Re: My Recipe program for Syed
« on: May 04, 2019, 03:38:14 AM »
I just checked the .zip file and mine shows 4 database files which are categories.db, favourites.db, recipes.db and meats.db.  Anyway, I have re zipped the everything again and checked the new MasteChef.zip and it contains everything.  Again, for testing purposes, select the meats category and the either Beef or Pork to see the recipes.  Somehow, if either the RecipeOfTheDay image or the Welcome image is placed on the screen, the Listviews will not populate.  If I remove these, then they populate ok.  I can't figure out the connection.

Thanks, Syed.

Pages: [1] 2 3 ... 35