Qbasicnews.com

Full Version: Allegro help with []'s
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to create several bitmaps in Allegro, but declaring all of them seperately would take forever. How could I use the []'s in bitmap pointers? Example:

DIM pic[256] AS BITMAP ptr

It comes up with an error because of the []'s. I have seen them used in the starfields demo for allegro. How could I use those?
Might wanna try using () instead of []. [] has another purpose in FB. You can't directly port C code to FB.
[]'s are only used for pointer indexing, () should be used to declare and access arrays, array[idx] is a shortcut for *(array + idx).
Quote:[]'s are only used for pointer indexing, () should be used to declare and access arrays, array[idx] is a shortcut for *(array + idx).

If i understand you right i can declare the following:
dim shared somestring as string ptr
and retrive singel chars out of it thne c way?
eg.: sometring[4] = mid$(somestring,4,1)

So Long, The Werelion!
Nope, STRING is actually a descriptor, [] will access the descriptor, not the data, but you could do:

Code:
    dim shared somestring as byte ptr
    
    somestring = strptr("abc")
    
    i = 0
    do while somestring[i] <> 0
        print chr$( somestring[i] );
        i = i + 1
    loop