No announcement yet.

What does this translate to...

  • Filter
  • Time
  • Show
Clear All
new posts

  • What does this translate to...


    I'm kinda brain dead today, can somebody please help me convert/translate this to PB?

    unsigned char** imagefiles;
    I'm just not sure how to deal with the "char**" its a pointer to a pointer but how would you write that in PB

    imagefiles as asciiz ptr ptr

    Thanks in advance!


  • #2

    I'm not a C guy, so someone may shoot me down on this one, but I
    did run into that sort of thing with a dll I was using.

    I think it's really:
    Char **imagefiles
    and what you do is:
    dim MyString as asciiz * 256
    dim MyStPtr as String Ptr
    dim MyP2P as long
    MystPtr = varptr(Mystring)
    MyP2P = MyStPtr
    declare Whatever(byref MyP2P as long)
    Call Whatever(MyP2P)

    Why they do this is beyond me. I certainly never got a straight
    answer when I asked. And the dll I was calling had plenty of
    pointers to string (so they could fill with data), but only one
    pointer to a pointer. Please, Oh gurus of C, explain it to all
    of us!

    Russ Srole

    "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


    • #3

      This is off the top of my head and I have no way to test it but
      with the extra level of indirection, I would be inclined to try
      something like this to read it.

      ! mov eax, The_Double_Ptr
      ! mov eax, [eax] ; dereference it once
      ! mov eax, [eax] ; and once more
      ! mov Where_Its_At, eax

      To write the value if you are passing it to a function,

      First_Level_Of_Indirection = VarPtr(MyVar)
      Second_Level_Of_Indirection = VarPtr(First_Level_Of_Indirection)

      This may do the job for you but at least it gives you the general idea.


      [email protected]

      hutch at movsd dot com
      The MASM Forum - SLL Modules and PB Libraries


      • #4
        Thanks Guys!

        But here's the problem.

        typedef struct IMAGE {
            unsigned char** imagefiles;
        } IMAGE;
        How do I convert this into a PB TYPE? This is about as close as I can come up with. But this still doesn't provide the exact same thing as the C example.

        type IMAGE
            imagefiles as asciiz ptr
        end type
        How would you define a member inside a TYPE that is a pointer to another pointer?

        Thanks again guys!



        • #5
          I think in this context, char** imagefiles; represents a string
          array for imagefiles. So imagefiles[0], and imagefiles[1], etc...
          would be the array elements representing the first few files. They
          could have used char* imagefiles[] just the same. In C, you
          don't really have native strings. So you use either an array of
          characters to represent a string, or a pointer to those characters.

          Now for an array of strings, you'd need either an array of that
          array (a two-dimensional array) or a pointer to char array,
          or else a pointer to the pointer. unsigned char simply
          means that you can go from 0 255, instead -128 to 127. I'm not
          sure why people would use ** in this context. But I've seen the
          argv argument for the main() function sometimes defined as
          char **argv, and other times as char * argv[].

          Fortunately strings are much easier to deal with in BASIC.
          Although I haven't tried it, my guess would be that this would
          translate to PB simply as an ASCIIZ array.

          Daniel Corbier
          UCalc Fast Math Parser

          Daniel Corbier
          uCalc Fast Math Parser
          uCalc Language Builder