TheSwamp

Code Red => .NET => Topic started by: Binky on September 21, 2011, 01:00:12 PM

Title: Getting the value of a NON-system variable in C#
Post by: Binky on September 21, 2011, 01:00:12 PM
As part of the startup routines, I set a handful of lisp varibles for use by various commands.  I am writing a C# command and I would like to read the vaule of one of the varibles that I set during startup.  All I have found anywhere are methods to retreive the value from System varibles but not NON-system

Try as I might I can seem to find a way.
Title: Re: Getting the value of a NON-system variable in C#
Post by: dgorsman on September 21, 2011, 01:19:26 PM
When you say "LISP variables" do you mean something like reading the value from (setq *global_var* "This is a string")?  If so, trying to get the two to talk to each other is more pain than its worth, IMO.  If you need to store data follow the lead of other applications: Dictionaries/XRecords, registry entries, or configuration files.
Title: Re: Getting the value of a NON-system variable in C#
Post by: Binky on September 21, 2011, 01:38:56 PM
I have 3 different setups, Main office, Satellite office, and laptops.  As part of the start up I set three varibles that that have path information based on the which machine autocad is fired up from.  I set it via a simple (setq rootpath <Path>) and a couple others based on a test of which if any network is available at the time autocad was started.  Then any command that needs the path can simply splice together that value with anything else go on it's merry way.  Merry as long as it's lisp at least.

Just read your response again, short answer, yes.
Title: Re: Getting the value of a NON-system variable in C#
Post by: Jeff H on September 21, 2011, 02:58:34 PM
http://www.theswamp.org/index.php?topic=35714.msg409451#msg409451 (http://www.theswamp.org/index.php?topic=35714.msg409451#msg409451)
Title: Re: Getting the value of a NON-system variable in C#
Post by: Binky on September 21, 2011, 06:30:40 PM
Thanks Jeff, I'll take a look at that in a bit. 
Title: Re: Getting the value of a NON-system variable in C#
Post by: Binky on September 22, 2011, 12:40:11 PM
Got it working, Thanks for the help.  I am self taught at this, if I may ask a quick question about this...

The following is a "Delegate"?  That chapter in the C# book I read was/is a bit fuzzy, but this seems like what they were getting after.

[DllImport("acad.exe", EntryPoint = "acedGetSym", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
extern static private int acedGetSym(string args, out IntPtr result);
Title: Re: Getting the value of a NON-system variable in C#
Post by: Jeff H on September 22, 2011, 01:14:50 PM
Got it working, Thanks for the help.  I am self taught at this, if I may ask a quick question about this...

The following is a "Delegate"?  That chapter in the C# book I read was/is a bit fuzzy, but this seems like what they were getting after.

[DllImport("acad.exe", EntryPoint = "acedGetSym", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
extern static private int acedGetSym(string args, out IntPtr result);

Kerry did all the work,
 
For the DllImport
http://msdn.microsoft.com/en-us/library/aa984739(v=VS.71).aspx (http://msdn.microsoft.com/en-us/library/aa984739(v=VS.71).aspx)