PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Petrus Vorster on February 27, 2017, 04:16:17 PM

Title: Richard's PDF class
Post by: Petrus Vorster on February 27, 2017, 04:16:17 PM
I decided to seriously go into making my reports into PDF instead of using 3rd party tools.

The demo runs perfectly.
Once i use the inc in my own program i get an error.
See the attached screepclip.

This is something i really want to master and use.
Title: Re: Richard's PDF class
Post by: Paul Squires on February 27, 2017, 04:47:33 PM
What is the link to the PDF source code, or can you attach it to your post so I can try it.
Title: Re: Richard's PDF class
Post by: Petrus Vorster on February 27, 2017, 04:58:37 PM
http://www.planetsquires.com/protect/forum/index.php?action=dlattach;topic=3547.0;attach=1698 (http://www.planetsquires.com/protect/forum/index.php?action=dlattach;topic=3547.0;attach=1698)

What is weird, is that if i start a new project and add this .inc it runs just fine.
I have already managed to make a simple Pdf .

But the moment i add this to my big project i immediately get this error on startup.

Title: Re: Richard's PDF class
Post by: Paul Squires on February 27, 2017, 09:13:54 PM
Instead of putting the cPDF.inc into your project as a Module, try adding it to FF_AppStart as an #INCLUDE

Say, for example...

#Include "cPDF.inc"

See if FF complains. It probably won't because FF does not parse #Include files whereas it will parse Modules and attempt to regroup TYPE's, MACROS, etc in order to help with forward referencing.

Title: Re: Richard's PDF class
Post by: Paul Squires on February 27, 2017, 09:14:21 PM
BTW, that cPDF code is pretty awesome. Rick did a great job there.
Title: Re: Richard's PDF class
Post by: José Roca on February 28, 2017, 12:40:39 AM
The error message clearly indicates the cause: it is trying to replace the pi parameter with the value 3.14....

In cPDF.inc there is a macro:

Macro PI                    = 3.141592653589793##

that is causing the error.

I have said a LOT of times (and I mean a LOT) that the use of macros for this purpose is a can of worms. You define Macro PI and nobody else can use PI for any purpose.

Change the name for another that does not cause a conflict.
Title: Re: Richard's PDF class
Post by: Paul Squires on February 28, 2017, 08:22:25 AM
Doh! Of course! How did I not spot that in the error message. The macro is named the same as the parameter of the function. Sometimes I can't see the forest for the trees.
Title: Re: Richard's PDF class
Post by: Petrus Vorster on February 28, 2017, 12:51:29 PM
This is not helping.

As soon as i change the macro, its just the next thing again...
I think its best if i either redesign the old project, or create a workaround exe.

If i add it unchanged to a new project there is no error.
Perhaps too many duplicated string & function names in an old project.
Title: Re: Richard's PDF class
Post by: Paul Squires on February 28, 2017, 03:02:35 PM
I would think that if you changed the Macro to be an equate that it would work? Wouldn't it? Equates should not interfere with sub/function parameter naming.

Title: Re: Richard's PDF class
Post by: José Roca on February 28, 2017, 03:06:02 PM
PowerBASIC equates don't work with float numbers. Anyway, we don't know what that "next thing again" is...
Title: Re: Richard's PDF class
Post by: Petrus Vorster on February 28, 2017, 03:16:15 PM
No worries.
As soon as i changed the Macro, there is another error....and another.
Just because some of the old projects functions happen to have the exact names.

This does give the reason to stop procrastinating and redesign a project i should have done years ago.
Laaaazy..... ::)

Do it better the next time with all the new stuff i have learned from you guys, it can only get better!!
Title: Re: Richard's PDF class
Post by: Knuth Konrad on March 01, 2017, 07:30:22 AM
Quote from: Jose Roca on February 28, 2017, 03:06:02 PM
PowerBASIC equates don't work with float numbers.

That'll be the perfect place for a (class full of multiple float numbers each exposed as a) readonly property ...
Title: Re: Richard's PDF class
Post by: Petrus Vorster on March 12, 2017, 05:25:48 PM
One should not under-estimate the speed of Powerbasic combined with this class from Richard.

I have been designing a customer form to replicate the manual one used by the organisation.
It will fill data from my database on request and leave space for the customer to make changes on information.

It is quite an undertaking drawing a "million" blocks. I assume the original organisational one was drawn in Excel given the thousands of little blocks they had in there.

What is amazing, is how extremely fast this draws, and i can promise you, i have quite a number of blocks and loops in here already.
(Still a mile to go though!!)
LOL and it also reminded me why i preferred tools like Firefly for programming and PFD makers instead of going the long route...

This method called from my program designs and fills the data about 10 times faster than my previous method using Excel Macros.

Great stuff.
Title: Re: Richard's PDF class
Post by: Richard Kelly on March 13, 2017, 07:59:02 PM
Sorry about that macro. I had changed my copy of the code to wrap it in a function cmPI.

Rick Kelly