Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Allegro help with []'s
#1
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?
Reply
#2
Might wanna try using () instead of []. [] has another purpose in FB. You can't directly port C code to FB.
I'd knock on wood, but my desk is particle board.
Reply
#3
[]'s are only used for pointer indexing, () should be used to declare and access arrays, array[idx] is a shortcut for *(array + idx).
Reply
#4
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!
color=red]Look at you, Hacker. A pathetic creature of meat and bone, panting and sweating as you run through my corridors. How can you challenge a perfect, immortal machine?" - Shodan, AI at Citadel Station orbiting Earth[/color]
Reply
#5
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)