Click to See Complete Forum and Search --> : Elegant Solution Needed
Simon_R
Jul 10th, 2002, 02:27 AM
I have a Com project, to print an invoice.
The type and layout may change (thus use of com).
I use an Array to load Header and Detail information
I have a Header Module and a Detail Module.
For some Invoice types it will be necessary to include header
information on the detail line.
Ok, here goes
I have defined the arrays as static within each function.
I could just pass the header information needed into the detail line, or call the header function with a special code to retrieve the relevant data (hokey), or put them both (Header and Detail) into the same function, but I want to keep the functions small and readable.
is there a way for my invoice detail line function to access the data held in the invoice header function, or am I scr*wed
:(
Thanks in Advance
Simon
Edneeis
Jul 10th, 2002, 10:06 AM
What are you using for your reports? Data Reports? Crystal Reports? Printer Object?
patrickfitzg
Jul 10th, 2002, 04:12 PM
More a design of code than a line of code issue.
I would keep modules separate. Here is how I would deal with this.
Have header in module - lets call it PrintHeader. Have detail in module called PrintDetail.
Then I would have a function that mediates and calls either of these - say
if sameline = true
call PrintHeader
call PrintDetail
else
call PrintDetail
end if
for eg.
Now - you might not like this as you dont want to be passing arrays over and over again to separate modules.
If that were the case, I would create an invoice class and pass in each array as a variant property (assuming you are not using .Net).
Then the aforementioned modules would be methods of the class. So you can create and execute the modules against the arrays depending on a key value recorded in another property.
You can then pass the object around so you have persistence - hell, you can even serialise it if you want.
I hope this made some sense.
;)
Simon_R
Jul 11th, 2002, 02:17 AM
:) Pat, that made a lot of sence, I was assuming this would be the answer, but I had hoped for a 'magical' solution:rolleyes:
Sadly I waited until 16:00 and then 'went for it'
what I have is
two functions header and detail each has a boolean parameter (to print or not to print that is the question) and a value, (to load the array) , the array index variable is a property set independently of the function.
When the Detail wants a header value, it invokes the header routine with the index set to 0, the print to False and the value set to the index number of the headers array it wishes to recieve, this is then put into the value and .... exit function, and bobs your uncle !!!!.
A bit clunky, but this is my first ever com widget, previously RPG etc etc.
thanks for the reply though
Simon
patrickfitzg
Jul 11th, 2002, 03:23 PM
but have a crack at doing it with your own classes.
VB world had a really good series on doing this if you can fight your way through the javascript prompts telling you that the site has been revamped (but ypou won't be able to find this article).
;)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.