Page 1 of 1

passing memory pointers across programs

Posted: Fri Jun 19, 2009 8:00 am
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??)

Posted: Fri Jun 19, 2009 8:08 am
by Mistrel
See ReadProcessMemory on MSDN. PureBasic supports this function natively as "ReadProcessMemory_" (note the underscore).

Posted: Fri Jun 19, 2009 8:25 am
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?

Posted: Fri Jun 19, 2009 8:41 am
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.

Posted: Fri Jun 19, 2009 11:07 am
by srod
You could consider using shared memory.

Posted: Fri Jun 19, 2009 11:14 am
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

Posted: Fri Jun 19, 2009 1:35 pm
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)