How to read an entire list using memcpy?

Q&A's, tips, howto's
Locked
ale870
Posts: 297
Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy

How to read an entire list using memcpy?

Post by ale870 »

Hello,
I need to read/write newlisp lists using an external program (like dll), so since I don't want to pass back and forth an entire list, can I read it using memcpy or similar?
I already read/write strings and numbers (float and int) but lists....

Thank you!
--

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Re: How to read an entire list using memcpy?

Post by HPW »

Hello,

Not sure waht you want to do in your DLL, but (source ..)+(eval-string ..) would be an option.

Hans-Peter
Hans-Peter

ale870
Posts: 297
Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy

Re: How to read an entire list using memcpy?

Post by ale870 »

Ok, I'm sorry, I did not post a good question :-)

I use newLisp as a DLL, and my program access to newLisp functionalities with such DLL.

My application does this:

1) My app Starts (!)
2) Open newLisp DLL
3) My app send a newlisp script to DLL
4) My app recall a newlisp function
5) This newlisp function fills a global variable (let's say, for example: (setq myVar ("a" "b" "c") )
6) Now I need to read that var myVar from My app.
7) The problem is myVar contains a list, so I need to access to list as a whole, since I don't want to access, from MyVar, to MyVar elements one by one. In order to improve performance I wish to get a reference to MyVar, then I need to access to list elements from MyVar (without newlisp intervention). So I need to access to newLisp memory using memcpy or similar.

Thank you for your help!
--

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Re: How to read an entire list using memcpy?

Post by HPW »

Hello,

I my understanding newlisp stores your list in several lisp-cells(connected via pointers).
So there is no linear memory stream which you can read easily.

So maybe a custom lisp-function can flatten it to a big string using a delimiter,
and you read this and parse it in MyApp back.

Or a lisp-function use a callback to set an array in MyApp for each list-element.

Just some thoughts.

Hans-Peter
Hans-Peter

Locked