Announcement

Collapse
No announcement yet.

Just another idea...

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

  • Just another idea...

    Hello,

    Here are some idea's (wishlist). I dont't quite know how to put this into words so I will give examples instead!


    request #1
    ----------
    dim buffer(2048) as byte
    dim buffptr as byte ptr

    GET? #1,2048,buffer() read 2048 bytes into array
    PUT? #1,2048,buffer() write 2048 bytes from array
    GET?? #1,1024,buffer() read 1024 words into array
    PUT?? #1,1024,buffer() write 1024 words from array

    GET? #1,2048,@buffptr read 2048 bytes into buffer pointer
    PUT? #1,2048,@buffptr write 2048 bytes from buffer pointer
    GET?? #1,1024,@buffptr read 1024 words into buffer pointer
    PUT?? #1,1024,@buffptr write 1024 words from buffer pionter


    request #2
    ----------
    dim buffer as word
    dim strbuff as string

    &buffer == varptr(buffer)
    &strbuff == strptr(strbuff)

    allow the use of '&' before variable to indicate "pointer of variable"

    What do you guy's think?



    ------------------
    Cheers

  • #2
    Code:
    UNION B
      Buffer (1 to 2048) AS BYTE
      SBuffer AS STRING * 2048
    END UNION
    DIM BX AS B
    ...
      GET #1,loc,BX.SBuffer
      FOR I& = 1 TO 2048
        PRINT "Byte Value=";BX.Buffer(I&)
      NEXT I&
    As far as "&" for "address of", PB always passes "address of" unless you go out of your way to do elsewise.

    You can also accomplish the first thing with absolute arrays:

    Code:
    DIM FileBuff AS STRING * 2048
    DIM Buffer(1 to 2048) AS BYTE AT VARTPR(FileBuff)
    GET #1,loc,FileBuff
      FOR I& = 1 to 2048
        same as above...



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

    Comment


    • #3
      Hello Michael!

      I understand what your saying about the UNION but what if you want to use dynamic arrays, you can't REDIM an array in a UNION and I have found that UNIONS and TYPES have limits to how big they can be. That brings us to the next suggestion...It just looks messy! and once again what happens when you use REDIM on the array? About the "&", If PowerBasic always passes an address by default what is the proper way to get that address in a function? would this be correct?

      Code:
      type MARKSTRUCT
          Hours as long
          Minutes as long
          Seconds as long
      end type
      
      dim Time as TIMESTRUCT  <------------------------\
      dim Result as long                               |
                                                       |
      Result = GetTime(Time)                           |
                                                       |
                                                       |
      function GetTime(Time as TIMESTRUCT) as long     |
          dim Address as long                          |
                                                       |
          Address = varptr(Time) rem IS THIS CORRECT?  |
                                                       |
          rem Address = pointer of --------------------/
      end function

      ------------------
      Cheers

      Comment


      • #4
        Yes, that would be a valid pointer to the UDT that was defined in the calling code.

        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          As far as "arrays" in UNIONS (and UDTs):

          I sincerely hope PB changes its nomenclature starting with the next release of all the compilers.

          TYPE/UNION Foo
          J (1 to 100) AS LONG
          K (1 to 200) AS INTEGER
          END TYPE/UNION

          J and K in the above are NOT arrays: they are statically sized TABLEs.

          I suspect they were called "arrays" as a marketing decision.

          MCM

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

          Comment

          Working...
          X