passing memory pointers across programs

Share your advanced PureBasic knowledge/code with the community.
alokdube
Enthusiast
Enthusiast
Posts: 148
Joined: Fri Nov 02, 2007 10:55 am
Location: India
Contact:

passing memory pointers across programs

Post by alokdube »

anyone has a successful example of passing memory pointers across programs in purebasic (like runprogram X and the output of X is a memory pointer which the parent can access??)
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

See ReadProcessMemory on MSDN. PureBasic supports this function natively as "ReadProcessMemory_" (note the underscore).
alokdube
Enthusiast
Enthusiast
Posts: 148
Joined: Fri Nov 02, 2007 10:55 am
Location: India
Contact:

Post by alokdube »

the X program execution is already over and it actually computes a huge array result, I need to pass back this huge array to the caller program, but will readprocessmemory_ still be around if the program execution is over?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

All memory for your application is freed once the program ends. I'm sure ReadProcessMemory will fail if you attempt to call it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You could consider using shared memory.
I may look like a mule, but I'm not a complete ass.
alokdube
Enthusiast
Enthusiast
Posts: 148
Joined: Fri Nov 02, 2007 10:55 am
Location: India
Contact:

Post by alokdube »

well there are 2 things here
1. i generate the source of the child file from the parent file
2. the array is defined along with its values which i dump into the child filed
3. similar to your esgrid, i simply write back the values/formulas given in a grid back to the child file (so X43 is already given a formula back in the child file as X43=X41+X32)
4. I then run the child file and it dumps back the actual values in the grid
5. i print the grid in the parent file
6. for every sheet/grid i make, i generate a new child file and wait for it's output which update's back the parent

so for example in a cell I should be able to type a purebasic formula/code snippet and the child file should throw back the values and the parent should print it back.
One option is back to back unix sockets. but i need it to "actually run those formulas", so rather than write my own interpreter i decided to poach back on PB itself
So I have
Parent-->has a Dim(x,y), inputs at parent-->generate child code-->child code executes and throws back values to parent-->parent simply displays the grid...
hope that helps clarify my point
alokdube
Enthusiast
Enthusiast
Posts: 148
Joined: Fri Nov 02, 2007 10:55 am
Location: India
Contact:

Post by alokdube »

the other option is dont DIM,
simply change the view on top with the scroll bar below
for example the rows and column "numbers" are fixed gadgets/text gadgets
when you move the scrollbar gadget/click on it, it increments by 1 cell size as it increments in windows :o)
Post Reply