Page 9 of 10

Re: MealMaster: Decoding text file format to database

Posted: Wed Feb 06, 2013 4:05 am
by Fangbeast
Will be uploading a minor fix or two shortly and a resorted (and added to) FDX archive.

Who is good at making printing routines? That needs to be done for RecipeMuncher yet and that's not something that I have ever got into without severely cheating with the webgadget (and the results were never quite pretty).

Re: MealMaster: Decoding text file format to database

Posted: Fri Feb 08, 2013 3:49 am
by yrreti
Hi Fangbeast

I'm sorry, I've been so busy lately I've not been much help at all. But your programs starting to look pretty
good.
As to printing. I use and really like these two by ABBKlaus
Check out Printer_Lib110 http://www.purebasicpower.de/?PrinterLib
Also check out PurePDF http://www.purebasicpower.de/?PurePDF
They both work real great for printing to paper or to PDF. The only problem I found, is that the PurePDF lib
does not work with PB5.10. But it works great by using the included code in the examples directory.
Just don't install that lib, and include this at your codes beginning:

Code: Select all

#PurePDF_Include=1
XIncludeFile #PB_Compiler_Home +"Examples\PurePDF\PurePDF.pb"
And in PurePDF.pb in the examples directory. Look for Procedure.l ipdf_ASCII85_Decode ana change the
line to the following.

Code: Select all

Procedure.l ipdf_ASCII85_Decode(*InputBuffer,InputLength,*OutputBuffer,*OutputLength)
  Protected tuple.q,c.l,count.l,err.l,*IPos,*OPos,i.l

The PurePDF code and PrinterLib have to be told where to print. So the following is an example template program
that can be used to help you with text placement. Once you start using it, it's not bad at all. The pdf program
just uses different command names, and is coded very similar. The first part of this code finds your printer,
and then it prints the template.

Code: Select all

#MR_SIMPLESILENT0 = $C0  ;this gives you the silent ok box when using MessageRequester
Global selprn$
;selprn$="WorkForce 610(Network)" 

Procedure.s check_startup_printer(selprn$)
  ;First check if there is a printer. Then check if there is more than one printer.
  ;If there is, allow printer selection.
  If selprn$="Print to PDF"
    ProcedureReturn selprn$
  Else
    printer_exist=0
    Options=#PRINTER_ENUM_LOCAL|#PRINTER_ENUM_CONNECTIONS;|#PRINTER_ENUM_REMOTE
    EnumPrinters_(Options, 0, 1, #Null, 0, @dwNeeded, @dwReturned)
    ;Debug GetLastError_()
    If dwNeeded
      *buffer = AllocateMemory(dwNeeded)
      EnumPrinters_(Options, 0, 1, *buffer, dwNeeded, @dwNeeded, @count)
      ;FreeMemory(*buffer)
    EndIf
    If Trim(dfpn$)=""
      ;this gets default at startup, but if you change the printer, it stays selected until you restart program
      ;or reselect another printer.
      dfpn$=Print_GetDefaultPrinter()
    EndIf
    
    If count=1; if count = 1 there is only one printer found
      i=count
      pointer=PeekI(*buffer+(i-1)*SizeOf(PRINTER_INFO_1)+OffsetOf(PRINTER_INFO_1\pName))
      pn$=PeekS(pointer)
      ;Debug pn$
      If pn$=selprn$
        printer_exist=1
      EndIf
      FreeMemory(*buffer)
      If printer_exist=1
        ProcedureReturn selprn$
      Else
        ;your cfg printer does not exists. changing to system default found printer
        selprn$=dfpn$
;         CreateFile(1,pp$+"printer.cfg")
;         WriteStringN(1,"Printer:"+selprn$)
;         CloseFile(1)
        ProcedureReturn selprn$
      EndIf
    EndIf
    If count>1
      For i = 1 To count
        pointer=PeekI(*buffer+(i-1)*SizeOf(PRINTER_INFO_1)+OffsetOf(PRINTER_INFO_1\pName))
        pn$=PeekS(pointer)
        ;Debug pn$
        If pn$=selprn$
          printer_exist=1
          Break
        EndIf
      Next
      FreeMemory(*buffer)
      If printer_exist=1
        ProcedureReturn selprn$
      Else
        ;your cfg printer does not exists. changing to system default printer
        selprn$=dfpn$
        CreateFile(1,pp$+"printer.cfg")
        WriteStringN(1,"Printer:"+selprn$)
        CloseFile(1)
        ProcedureReturn selprn$
      EndIf
      
    EndIf
    
    If count<1
      FreeMemory(*buffer)
      MessageRequester(" Printer Error Message", "Can Not Locate Printer!  Prints to PDF Only", #PB_MessageRequester_Ok|#MR_SIMPLESILENT0|#MB_TOPMOST|#MB_SYSTEMMODAL)
      selprn$="Print to PDF"
      dpn$=selprn$
      ProcedureReturn selprn$
    EndIf
  EndIf
EndProcedure
;-

Procedure AP_PSA(poscnt)
If Print_OpenPrinter(selprn$,"PAPERSIZE="+Str(#DMPAPER_LETTER)+",ORIENTATION="+Str(#DMORIENT_PORTRAIT))
    ;When paperHeight and paperWidth are specified, paperSize shall be ignored.
    Print_StartPrinting("MyData")
    Print_Font("Arial",10)
    
    x=0
    
    ;Horizontal Lines
    For z=0 To 240 Step 10;210 is the max x position 'line' that can be printed.
      Print_Text(x,z,Str(z))
      Print_Line(x,z,210,0)
    Next z
    
    ;Vertical Lines
    For z=0 To 240 Step 10
      Print_Text(z,5,Str(z))
      Print_Line(z,0,0,240)
    Next z
    Print_Line(70,250,5,0)
    Print_Line(70,250,0,5)
    Print_Font("Arial",16)
    Print_Text(70,250,"70,250   PB Printing Template")
    
    ;If y>240  ;set point where you want new page set.  
    ;Notes: You should only use Print_NewPage() if you intent to print on the next page.
    ;You can even just print a space.  But if you don't, then it will not print anythings.
    ;       Print_NewPage()
    ;       Print_Text(5,208,"                                  ");:y=y+3
    While WindowEvent():Wend;needed or printer locks up
    ;     y=4
    ;EndIf
       
    ;Next pos
    ;If y=4
    ;  Print_EndDocPrinter()  ; this stops and ends the print job if nothing to print.
    ;Else
    Print_StopPrinting()
    ;EndIf
  Else
    err$=Print_GetLastError()
    MessageRequester(" Print_StartPrinting()",err$,0)
  EndIf
  While WindowEvent():Wend;needed or printer locks up
EndProcedure

;{- Enumerations / DataSections
;{ Windows
Enumeration
  #Window_0
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 450, 200, 400, 400, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
  EndIf
EndProcedure

OpenWindow_Window_0()

selprn$=check_startup_printer(selprn$)
poscnt=1
AP_PSA(poscnt)
;{- Event loop
Repeat
  Event = WaitWindowEvent(5)
  Select Event
    ; ///////////////////
  Case #PB_Event_Gadget
    EventGadget = EventGadget()
    EventType = EventType()
    ; ////////////////////////
  Case #PB_Event_CloseWindow
    EventWindow = EventWindow()
    If EventWindow = #Window_0
      CloseWindow(#Window_0)
      Break
    EndIf
  EndSelect
ForEver
;
;}
Hope that provides some help for you.

yrreti

Re: MealMaster: Decoding text file format to database

Posted: Sat Feb 09, 2013 2:07 pm
by Fangbeast
I know that I said that I had finished, but it was a hot day and I couldn't do anything else so...

I tried to figure out a way to stop the form 'greying' out on startup because it was happening *before* the data got loaded.

So I experimented with the order of startup items to make sure all form preparation was done first before anything else and that helped a little.

So I decided to be brave enough to try a thread on FindRecipes() (The main culprit of slowdown) and blow me down, it worked properly.

Until I tried to exit the program in the middle of loading the data at which RecipeMuncher promptly locked the screen and crashed.

That's when I remembered to check for a running thread and waiting for it to finish *before* closing the window. Whew! Solved that problem.

I've also added some CompilerIf statements to allow the old SendMessage for versions of PB 5 and lower. Just remember to use the new wrapping constant for editorgadgets on versions 5.1 and higher.

I'll upload a new perversion in the next few days to see what people think.

Re: MealMaster: Decoding text file format to database

Posted: Thu Feb 14, 2013 1:18 am
by Fangbeast
Hurro, uproaded rots morr retzipes for peepulz. enyboddy vant to uproadz sum morr 4 meyz?

Can't doo it awl muyshelf!!!

Rub muy ingrish sow mutch!

:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:

Re: MealMaster: Decoding text file format to database

Posted: Thu Feb 14, 2013 6:06 am
by idle
Fangbeast wrote:Hurro, uproaded rots morr retzipes for peepulz. enyboddy vant to uproadz sum morr 4 meyz?

Can't doo it awl muyshelf!!!

Rub muy ingrish sow mutch!

:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
typing with your elbows again, must be good recipes!
but I know what you mean. :lol:

Re: MealMaster: Decoding text file format to database

Posted: Tue Feb 19, 2013 1:58 am
by Fangbeast
typing with your elbows again, must be good recipes!
but I know what you mean. :lol:
And you notice that nobody answered?? Shock! Horror! Gasp!! Knickers!!

Now in Engrish: Does anybody want anything else done to/for/in RecipeMuncher? Or can I go study for my next exam???

Re: MealMaster: Decoding text file format to database

Posted: Tue Feb 19, 2013 2:47 am
by electrochrisso
Sorry I have been a bit slack on this one Fang, I have been busy trying to finish off my Cert 4 business course and also have my business plan completed by the 27th, as usual I leave everything till the last minute. :lol:
Once I get myself sorted out I will make some time to have a good look at what you have done. :)

Re: MealMaster: Decoding text file format to database

Posted: Tue Feb 19, 2013 5:18 am
by Fangbeast
electrochrisso wrote:Sorry I have been a bit slack on this one Fang, I have been busy trying to finish off my Cert 4 business course and also have my business plan completed by the 27th, as usual I leave everything till the last minute. :lol:
Once I get myself sorted out I will make some time to have a good look at what you have done. :)
It was more of a general "does anyone want anything else", not specifically aimed at you:):)

If nothing else, then I can go and study for my advanced amateur license and with my brain, that's going to take a lot of work and stress. I'm currently at my standard (level 2) and that was hard enough for my bad eyesight and memory.

Re: MealMaster: Decoding text file format to database

Posted: Tue Feb 19, 2013 10:33 am
by electrochrisso
It was more of a general "does anyone want anything else", not specifically aimed at you: :)
I know, I have not even got that far to know even if I needed anything, I will let you know when I do though. :)
If nothing else, then I can go and study for my advanced amateur license and with my brain, that's going to take a lot of work and stress. I'm currently at my standard (level 2) and that was hard enough for my bad eyesight and memory.
I used to be a member of the Woomera Amateur Radio Club (VK5WC) in the late 70's, was going to get a license, but never did, so that will be the next thing I will get, I will start off with the Foundation license.

So when you get your Advanced license you can do the lot, Good Luck Fang. :)

Re: MealMaster: Decoding text file format to database

Posted: Tue Feb 19, 2013 12:09 pm
by Fangbeast
I used to be a member of the Woomera Amateur Radio Club (VK5WC) in the late 70's, was going to get a license, but never did, so that will be the next thing I will get, I will start off with the Foundation license.
I didn't do mine in the 7's because back then, the cost of gear was beyond my factory wages so I got into cb's instead. We are spoiled for choice now though.
So when you get your Advanced license you can do the lot, Good Luck Fang. :)
Don't you mean, 'if'????? I'm stressed out doing mock exams, reading material, trying formulas, it's getting harder.

Oh well, I have to try, don't want to be stuck on standard, want more bands!!!

Re: MealMaster: Decoding text file format to database

Posted: Tue Feb 19, 2013 11:55 pm
by electrochrisso
I didn't do mine in the 7's because back then, the cost of gear was beyond my factory wages so I got into cb's instead. We are spoiled for choice now though.
Same here, I just went to the club once a week and chatted to a lot of hams around the world, since the club had all the gear, a huge antennae, and the license. I had a cheap sideband CB, with a long wire dipole, and I used to be able to get in contact with heaps of people around Australia and the world too, not bad for 12 watts.
Don't you mean, 'if'????? I'm stressed out doing mock exams, reading material, trying formulas, it's getting harder.

Oh well, I have to try, don't want to be stuck on standard, want more bands!!!
It's not the question of if, it's more of when, it would be great to get it the first time, and hopefully you will, but the final tests are meant to be really hard, you are trying to get into an exclusive club, I remember people telling me it took them a couple of goes to get it, I suppose it depends on which questions you get on the day, and hope it matches up with what is in your memory, anyway don't stress out too much and best of luck. :)

Re: MealMaster: Decoding text file format to database

Posted: Sun Feb 24, 2013 11:12 am
by Fangbeast
the first time, and hopefully you will, but the final tests are meant to be really hard, you are trying to get into an exclusive club
Not hard so much but more of the same that I had to do for the first two exams (Foundation and standard) and a bit trickier.
I remember people telling me it took them a couple of goes to get it,
Hope not, it's so bloody expensive in this country to pass your exam, the fees are killers.
I suppose it depends on which questions you get on the day,
Hell yes, no two exams have the same questions.
anyway don't stress out too much and best of luck. :)
\

Too late, I am stressing every day, trying to remember what I read. Grrr, memory is shot.

Re: MealMaster: Decoding text file format to database

Posted: Mon Feb 25, 2013 12:01 pm
by Fangbeast
1. Could someone work on the rtf help files? I've already done a full, proper CHM, don't want to do that as well.

2. Could a MOD please move this entire thread to Applications?? It's gone past questions and tips & tricks:):)

Re: MealMaster: Decoding text file format to database

Posted: Thu Jul 31, 2014 1:52 pm
by Fangbeast
I'm still collectings hundreds of recipes and eventually have to sort them out and post them somewhere if people still want more?

Re: MealMaster: Decoding text file format to database

Posted: Fri Aug 01, 2014 2:30 am
by electrochrisso
Hey Fang you have so many recipes to sort out you have no time to cook. :lol:
I will keep an eye out for your post. :)