Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about _MEM blocks and arrays
#4
(06-04-2025, 09:15 AM)SMcNeill Wrote: Mem works with arrays; there's no problem with that.  The only issue is the entire array is pointed to by the mem block, so if you want to use individual elements yourself, then you have to calcaulate their position manually and fetch only what you need from that segment of the entire array mem block.

For example

DIM a(10), m AS _MEM
m = _MEM(a())  '<-- to point to the array a() and not some variable a
_MEMPUT m, m.OFFSET, 12.34 AS SINGLE
_MEMPUT m, m.OFFSET + 8, 98.76 AS SINGLE
FOR I = 0 TO 10
   PRINT a(i)
NEXT

The above will print:
12.34
0
98.76
(and several more 0s)

Notice how I moved my pointer over 8 spaces to put the data into a(2)?   If you're looking to address individual elements of your array, you have to track their position manually like above.  Wink
   Maybe I'm being THICK.

   That does Happen

   I don't see a real practical use for this outside of the normal Array Indexing notation ????      (Unless MEM pointers can be passed between
   different program instances,  which I don't think is practically possible with User Space code on most 64 bit OS's)
Reply


Messages In This Thread
RE: Question about _MEM blocks and arrays - by ahenry3068 - 06-04-2025, 01:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  _Putimage Question. Pete 11 704 01-04-2026, 09:33 PM
Last Post: Pete
  Nice simple, I hope, question Mad Axeman 4 360 12-20-2025, 09:28 PM
Last Post: SMcNeill
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,226 12-19-2025, 12:51 PM
Last Post: Heimdall
  NewBie Question niteflyer 2 345 11-06-2025, 07:11 PM
Last Post: Petr
  A Question About _MAPTRIANGLE Magdha 2 388 11-02-2025, 11:37 AM
Last Post: Magdha

Forum Jump:


Users browsing this thread: 1 Guest(s)