Announcement

Collapse
No announcement yet.

UDTs and Variants

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • UDTs and Variants

    I have just returned to PB as another member asked me to look at an old PB related problem and I have run into some problems.

    I have a COM function which has more than 32 parameters, which isn't allowed in PB, so the docu tells me to use a UDT instead and pass it byref.

    The problem I have is that the parameters are a mixture of Strings and Variants. So how do I add these to a UDT..??? It seems a UDT must be fixed length and therefore can't contain Variants.

    I presume it has something to do with pointers..??

    Any help would be much appreciated..

  • #2
    >It seems a UDT must be fixed length and therefore can't contain Variants.

    ???

    Variants are fixed length (SIZEOF(type variantapi))

    But I'll be honest, i've never tried a udt with a member " X AS VARIANT." But it that didn't work, I'd just use "X AS VARIANTAPI" and build the members myself.

    I think someone who actually understands how handle this situation should create a demo and post it in the Source Code Forum as a service to all. (And then send a note to PB, suggesting inclusion of same in the next release of the help file).

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Would it be possible to have a pointer to the VARIANT as a member of the UDT?
      Erich Schulman (KT4VOL/KTN4CA)
      Go Big Orange

      Comment


      • #4
        Sure you can have a pointer (to anything) as a member of a UDT.

        The thing is, I don't know what the call (method) is looking for: a VARIANT BYVALUE or a VARIANT BYREFERENCE?

        I *think* one of the ways you can handle more than the 32-parameter limit is by using NAMED parameters and building a string like "OPTIONA=X, OPTIONB=Y, etc" and passing that single string to the method.

        But like I said, I'm no COM guy. However, I know others here ARE "COM Guys" and I'll bet they'd know how to handle this.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          The only way to workaround it is to use late binding and named parameters. I remember that some time ago we had a thread about this, but can't find it.
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            Ahh, excellent..!!!
            Thanks guys.

            I didn't know you could do NAMED parameters in PB now.
            I guess I should RTFM.

            I have done a quick test with late binding and named parameters and it seems it will work.. Thanks again.

            Comment


            • #7
              I have done a quick test with late binding and named parameters and it seems it will work.. Thanks again.
              No, thank YOU for the demo you posted in Source Code Forum (with searchable title).

              Oh, you didn't yet? Well, we can wait a day or so whilst you clean it up.

              MCM
              (C'mon, that's a very inexpensive price for the help you get here).
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Ha. Sarcasm will get you everywhere..

                Give me a day to make this problem work first, then I will put a simple example together and post in the Source Code forum...

                Comment


                • #9
                  That reminds me... someone this week or last posted a nice-looking collection of "rich text" functions... not in the Source Code forum. I'll have to find that and 'encourage' the author to put code where people look for code.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Would that someone be MEEEEeeee??? by chance? just cause I was was working on it and work in progress not ready for source code???

                    *** Edited ***
                    If it was me then maybe the code you are referring to is at http://www.powerbasic.com/support/pb...t=39407&page=2

                    Need to sort through the code if it was, cause I found another small "Bug" if it was
                    Engineer's Motto: If it aint broke take it apart and fix it

                    "If at 1st you don't succeed... call it version 1.0"

                    "Half of Programming is coding"....."The other 90% is DEBUGGING"

                    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                    Comment


                    • #11
                      oops...relooking the code..and the subject of the room...(no UDT's used)

                      But that again ("Thinking out-loud") gives me an idea for simplifying things
                      Engineer's Motto: If it aint broke take it apart and fix it

                      "If at 1st you don't succeed... call it version 1.0"

                      "Half of Programming is coding"....."The other 90% is DEBUGGING"

                      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                      Comment


                      • #12
                        I did not know that was you, nor that you didn't consider it 'ready for prime time.'

                        However, I remember seeing the basic FUNCTIONs and they looked well-designed, neatly coded and potentially quite useful. That was a lot of info to look up, eg, "{252/purple}" and other hard-to-remember character strings.

                        MCM
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Couldn't you make a udt of the strings and pass the Variants as individual parameters? Of course the numbers still have to add up to 32 or less...
                          "There are two novels that can change a bookish fourteen-year old's life: The Lord of the Rings and Atlas Shrugged. One is a childish fantasy that often engenders a lifelong obsession with its unbelievable heroes, leading to an emotionally stunted, socially crippled adulthood, unable to deal with the real world. The other, of course, involves orcs." - John Rogers

                          Comment

                          Working...
                          X