New TypedValue Usage (LispDataType.DottedPair)

New TypedValue Usage (LispDataType.DottedPair)

awerning
Advocate Advocate
2,029 Views
4 Replies
Message 1 of 5

New TypedValue Usage (LispDataType.DottedPair)

awerning
Advocate
Advocate
I am starting to slowly migrate some of my LISP functions into .NET. Since I obviously can't do it all at once I am migrating slowly by using the "LispFunction" class in order to write chunks of code in .NET that can be called from the "left over" LISP routine code. The return value from this class\function is a "Autodesk.AutoCAD.DatabaseServices.ResultBuffer" (which is changed into a list by the time it is returned to the LISP code). Right now I am returning a DataSet (that I have already obtained before the below code) as a "list of lists".

This code currently works just fine:
{code}
resBuf = New ResultBuffer()
'read data set
For Each dt As System.Data.DataTable In dataSet.Tables
For Each dr As DataRow In dt.Rows
'add each row into result buffer as a list
resBuf.Add(New TypedValue(LispDataType.ListBegin, -1))
For Each dc As System.Data.DataColumn In dt.Columns
resBuf.Add(New TypedValue(LispDataType.ListBegin, -1))
resBuf.Add(New TypedValue(LispDataType.Text, dc.ColumnName))
resBuf.Add(New TypedValue(LispDataType.Text, dr.Item(dc)))
resBuf.Add(New TypedValue(LispDataType.ListEnd, -1))
Next
resBuf.Add(New TypedValue(LispDataType.ListEnd, -1))
Next
Next
{code}

BUT, what I want is to return a "list of dotted pairs", which I assume would be something like this:
(because I know "LispDataType.DottedPair" is valid (value=5018)...I just don't know how to use it)
{code}
resBuf = New ResultBuffer()
'read data set
For Each dt As System.Data.DataTable In dataSet.Tables
For Each dr As DataRow In dt.Rows
'add each row into result buffer as a list
resBuf.Add(New TypedValue(LispDataType.ListBegin, -1))
For Each dc As System.Data.DataColumn In dt.Columns
resBuf.Add(New TypedValue(LispDataType.DottedPair, dc.ColumnName))
resBuf.Add(New TypedValue(LispDataType.DottedPair, dr.Item(dc)))
Next
resBuf.Add(New TypedValue(LispDataType.ListEnd, -1))
Next
Next
{code}

...but that is obviously not the right syntax because one data type of DottedPair would need 2 arguments (not 2 dotted pairs w/ one arg each).

Can anyone help?
0 Likes
2,030 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I may be way off on this
but if you're looking for the equivalent of a dotted pair (list),
use a Hashtable for your construct:

System.Colections.Hashtable MyDottedPairs = new Hashtable();

Then:

MyDottedPairs.Add(key, value);



Bill
0 Likes
Message 3 of 5

Anonymous
Not applicable
{code}[LispFunction("l2")]
public static ResultBuffer LTest2(ResultBuffer rb)
{
ResultBuffer res = new ResultBuffer();
res.Add(new TypedValue((int)LispDataType.ListBegin));
res.Add(new TypedValue((int)LispDataType.Int16, 1));
res.Add(new TypedValue((int)LispDataType.Int16 ,2));
res.Add(new TypedValue((int)LispDataType.DottedPair));
return res;
}{code} Edited by: XSFHLZH on Sep 9, 2009 2:09 PM
0 Likes
Message 4 of 5

awerning
Advocate
Advocate
Thanks XSFHLZH! That is exactly what I needed.
0 Likes
Message 5 of 5

Anonymous
Not applicable

The HashTable and ArrayList are .NET 1.x-era classes that suffer from

the performance overhead of boxing/unboxing (e.g., System.Object), and

their use should be avoided.

 

In .NET 2.0 or later, Dictionary<TKey,TValue> is the replacment for the

HashTable, and List<T> is the replacement for ArrayList.

 

 

0 Likes