Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Documentation question on CsScript. Get List<>, collections.
#2
Quote:I'm guessing that # means number, [p] is put, and [g] is get?
Yes, # is int, [g] and [p] are used for properties.

Quote:What I want to do is return a more complex data structure
With many class objects can be used IDispatch.
However cannot return generic types, like List<>. More info: http://msdn.microsoft.com/en-us/library ... 80%29.aspx . Convert List<> to array.
Works with non-generic collections.

Macro test CScript - get collection
Code:
Copy      Help
out

CsScript x.AddCode("")
IDispatch t=x.CreateObject("Test")

;IDispatch k=t.k ;;error
ARRAY(str) b=t.GetListAsArray ;;OK
for(_i 0 b.len) out b[_i]

IDispatch a=t.a ;;OK
out a.Count
out a.Item(0)
a.Item(0)="newstring"

#ret
using System;
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Generic;

public class Test
{
public List<string> k { get; private set;}
public ArrayList a { get; private set;}

public Test()
{
k=new List<string>(); k.Add("string in List");
a=new ArrayList(); a.Add("string in ArrayList");
}

public string[] GetListAsArray() { return k.ToArray(); }
}
Here used string[] in C#, and ARRAY(str) in QM. In your case will be BodyField[] and ARRAY(IDispatch).


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)