TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: deegeecees on June 07, 2004, 01:30:17 PM

Title: Passing Variables
Post by: deegeecees on June 07, 2004, 01:30:17 PM
Ok, I know this question has probably been asked, (and I did a search on this) is there a way to pass a variable from lisp to vba and vise versa?
Title: Passing Variables
Post by: Jeff_M on June 07, 2004, 02:39:45 PM
Yes.

Search for the VLAX class code that allows the use of lisp in vba. Then set/read lisp variables in lisp & vba.

Jeff
Title: Passing Variables
Post by: deegeecees on June 07, 2004, 03:09:53 PM
I'm not too familiar with vlisp, could you give me an example of how that would work? Lets say I have this in VBA:

dim test1 as string
test1 = "test"

Now, how could I retrieve the value of test1 in lisp?
Title: Passing Variables
Post by: Jeff_M on June 07, 2004, 04:18:47 PM
Here's an example using the vlax class.
Code: [Select]

Sub test()
Dim vlax As New vlax
Dim strText As String
strText = "Hello there!"

vlax.SetLispSymbol "test", strText

End Sub


Running the above will allow the symbol "test" to be used in a lisp function. Typing !test at the command line yields this:

Command: !test
"Hello there!"

HTH,
Jeff
Title: Passing Variables
Post by: Jeff_M on June 07, 2004, 04:29:16 PM
Or, to retrieve a lisp symbol.....
(setq test 1234.5432)

Code: [Select]

Sub test2()
Dim vlax As New vlax
Dim strText

strText = vlax.GetLispSymbol("test")
Debug.Print strText
End Sub
Title: Passing Variables
Post by: deegeecees on June 07, 2004, 04:29:29 PM
Just what the doctor ordered! Thanks Jeff!
Title: Passing Variables
Post by: Jeff_M on June 07, 2004, 05:20:35 PM
Glad I could help!