Announcement

Collapse
No announcement yet.

CHAR data type

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

  • CHAR data type

    Dare I say that I have another wish? YES!


    I think it would be of great benifit to PB programmers if a new data types called CHAR were added to the already extensive collection. The CHAR data type should accept data assignment from either numerical and string. For example...
    Code:
    dim buff as char * 2048
    dim bptr as char ptr
    
    buff = "mark has silly wishes"
    buff = 0,1,2,3,4,5,6,7,8...255
    
     or
    
    bptr = HeapAlloc(etc...)
    @bptr = "PowerBasic"
    @bptr[0] = 1
    @bptr[1] = 2
    @bptr[2] = 3
    @bptr = 0,1,2,3,4,5,6,7,8...255
    I also think some sort of "type-casting" would be very usefull...


    Oh! I almost forgot. I would also like to see VOID pointers. I know this can be done with LONG's right now but I think it would be much clearer with VOID PTR.

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

    [This message has been edited by mark smit (edited January 30, 2001).]

  • #2
    Why not use:

    SET UNION
    charV AS BYTE
    charC AS STRING * 1
    END UNION



    ------------------
    Bernard Ertl
    Bernard Ertl
    InterPlan Systems

    Comment


    • #3
      Mark,

      Have I missed something here? What you are referring to is C
      syntax. We already have dynamic, fixed length and nul-terminated
      strings. I say the chances of the char type in PB is next to
      zero looking up from the bottom side of course.

      The PB equivalent of the C char type is byte.

      Type casting maybe.

      Never have liked the void type in C either. Kinda like to know
      the data type I'm dealing with.

      Cheers,
      Cecil

      ------------------

      Comment


      • #4
        think it would be of great benifit to PB programmers if a new data types called CHAR were added to the already extensive collection. The CHAR data type should accept data assignment from either numerical and string. For example...
        Code:
        dim buff as char * 2048
        dim bptr as char
        ptrbuff = "mark has silly wishes"
        buff = 0,1,2,3,4,5,6,7,8...255
        DIM BUFF AS STRING * 2048
        LSET BUFF = CHR$(0,1,2,3,4)

        MCM


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

        Comment


        • #5
          Ok I see where you are all comming from but think about it like this. PowerBasic went through the trouble of putting in TCP/UDP "features". I could have replied to that with...

          Code:
          use WINSOCK API
          WSAStartup, etc...
          So, why is it so hard to add another data type that accepts both string and numerical (byte only) assignment? Other "features" that were already available in the Windows API have been added. In my opinion too many functions have been duplicated. I'm not trying to say that its a bad thing just that little things like a CHAR data type and VOID pointers shouldn't be overlooked.


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

          [This message has been edited by mark smit (edited January 31, 2001).]

          Comment


          • #6
            VOID PTR... can you outline this a little please? What specifically would you see this useful for?

            Thanks!


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

            Comment


            • #7
              Sure Lance!


              Imagein this, you have a function that needs to pass diffrent types of structures(types). The problem is that you need to access each structure with a pointer (@). Basicly having a VOID pointer is like passing a variable/structure as ANY.

              Code:
              function DrawSomething(byval lpData as void ptr)
              end function
              
              DrawSomthing n&
              DrawSomthing n!
              DrawSomthing a$

              Maybe I'm asking for the wrong thing here, maybe it should be worded like this. I would like to be able to pass a variable or type without type checking and refrence the data via a pointer. I was thinking void because that would eliminate the type checking. I dont think I'm making much sense, I'll try and dig through my code here and give you a good example of where it would be VERY usefull.

              Thanks guys for all the input

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

              Comment

              Working...
              X