Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing Variable name though Data
#1
Hey, how do you pass a UInteger Array though a Data statement so that it can be used by the Get statement to store the image data to? In other words, how do you Read from the Data statement which variable to store the image data from Get to?

I know it has pointers involved, but I havent gotta it able to work.

If you dont understand then can you answer these questions:
-How do you get the memory address from an Array() (so it will be equivalant to the number returned with @Array(0))?
-How do you pass that number though the Data Statement even though you dont know what number it is?
-How do you use that number after its been read to specify the memory address of that array in the Get?


Thank You,
Thrawn
i]"But...it was so beautifully done"[/i]
Reply
#2
absolutely no way. you cannot predict how memory will be allocated, or more precisely, where it will be allocated.
Reply
#3
As Chaos said: When the program runs memory is allocated for
the variables at a suitable place which changes from time to time.
DATA on the other hand is specified at compile-time.

But to simulate what you need you could always have an ptr array
with pointers to all possible arrays you might want to access that way,
and then have the DATA statement specify which index to access.
Something like this:
[syntax="qbasic"]dim shared globaltable(0 to numindexes) as uinteger ptr
dim foo(0 to whatever) as uinteger

const ti_foo=0 'table indexes
globaltable(ti_foo)=@foo(0)

read x

*globaltable(x)=*(globaltable(ti_foo)+wantedindex)

data 0[/syntax]
Note that this is unchecked code: not tested for memory leaks and doomness.
/post]
Reply
#4
ok thank you
i]"But...it was so beautifully done"[/i]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)