Results 1 to 5 of 5

Thread: Elegant Solution Needed

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Posts
    211

    Elegant Solution Needed

    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

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What are you using for your reports? Data Reports? Crystal Reports? Printer Object?

  3. #3
    New Member
    Join Date
    Jul 2002
    Posts
    12

    Arranging this

    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.


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Posts
    211
    Pat, that made a lot of sence, I was assuming this would be the answer, but I had hoped for a 'magical' solution

    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

  5. #5
    New Member
    Join Date
    Jul 2002
    Posts
    12

    That sounds about right ...

    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).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width