LispFunction attribute might be of some interest, allows for sending / returning lists and other goodies
[LispFunction("lisp01")]
...
Thanks nullptr, it looks quite interesting -
_$ lisp01
#<SUBR @000000f9c7658908 <EXRXSUBR>>
_$ (lisp01 5)
(5)
_$ (lisp01 1 2 3 4)
(1 2 3 4)
_$ (lisp01)
nil
_$ (lisp01 '("A" "B" "C" "D"))
("A" "B" "C" "D")
_$ (lisp01 '((00 01 02 03)(10 11 12 13)(20 21 22 23)(30 31 32 33)))
((0 1 2 3) (10 11.0 12.0 13.0) (20 21 22 23) (30 31 32 33))
_$ (lisp01 1 2 3 '(1 2 3) '(4 5 6))
(1 2 3 (1.0 2.0 3.0) (4.0 5.0 6.0))
Although, I'm not sure about its purpose. Also seems to throw exceptions when symbols, or list of symbols are passed: (lisp01 'abc) or (lisp01 '(a b c))
BTW it reminds me of the
list LISP function, which provides similar returns.
If the issue is about dialog boxes, you can build the dialog box with .NET and expose it to LISP via a LispFunction (i.e. a method which is decored with the LispFunction attribute). If I had to mix .NET and LISP I'd rather do it this way
Indeed thats the issue!
Now I know a bit more (about the LispFunction attribute)..
Indeed I now prefer your way of mixing .NET and LISP.. still I'm happy that you revealed the alternative approach per my original question!
Here's a trivial example with a simple dialog box containing a TextBox and a NumericUpDown:
Thanks for this example, gile - Highly appreciated!
Although I got some errors on declaring the public variables from the dialog class -
public string TextValue => textBox1.Text;
public int NumericValue => (int)numericUpDown1.Value;
Error 9 'LispDialogSample_Gile.Dialog.numericUpDown1' is a 'field' but is used like a 'type'
Managed to fix it, by defining them as properties inside of that class -
using System.Windows.Forms;
namespace LispDialogSample_Gile
{
public partial class Dialog : Form
{
public string TextValue { get; }
public int NumericValue { get; }
public Dialog()
{
InitializeComponent();
// the following properties can be set in the [Design] tab
btnOk.DialogResult = DialogResult.OK;
btnCancel.DialogResult = DialogResult.Cancel;
}
private void btnOk_Click(object sender, EventArgs e)
{
TextValue = textBox1.Text;
NumericValue = (int)numericUpDown1.Value;
} // btnOk_Click
}
}
Learned alot from your posts.. and sorry for my late reply (took me some time to digest).
If you guys don't mind an additional question appeared:
As you probably guessed I'm a lisp guy, that used DCL to collect user inputs.
But the main
reason for me to decide a switch, aside of all the fancy control events and the unique form design was because of some of the controls, that DCL doesn't seem to have.
I'm talking about the
datagridview control, that would build a string[,] type of array, or in LISP I'd call it matrix list of strings.
In other words
prompting user with a table (which is nearly impossible to do with DCL).
So my question is how would you pass a string[,] array to the ResultBuffer(); to the LispDataType enum? (say if I initially constructed the string[,] from the DGV's cell values)
Sorry for asking again (don't want to spam the .NET forum section with LISP-related question threads).