You can form your structure as simple and as complex as you want. RTC uses highly flexible format, so that you can define virtually any structure you want, even call remote function which will call other remote functions to get parameters.
You can store multiple values in each element by using newRecord, newArray or newDataSet. Here is one example of creating an array called “numbers”, which will hold a number of records (here 0 to 9) with “x:integer; dt:TDateTime” and send this to a remote function named “callme”.
This is the client-side code:
with myClientModule do
begin
with Data.newFunction(’callme’) do
begin
// prepare an array to send as parameter
with NewArray(’numbers’) do
begin
for I := 0 To 9 do
begin
// each item inside this array
// will be a new record
with newRecord(I) do
begin
asInteger[’X'] := I;
asDateTime[’dt’] := Now;
end;
end;
end;
Call(myResult);
end;
And on the server side, you can access all data inside this array like this:
// need to make sure this parameter is an array …
if isType[’numbers’]=rtc_Array then
with asArray[’numbers’] do
begin
// loop through all elements
for I := 0 to Count-1 do
begin
// make sure this element is a record
if isType[i]=rtc_Record then
with asRecord[I] do
begin
// read the data inside the record
X := asInteger[’X'];
dt := asDateTime[’dt’];
end;
end;
end;
Whenever you expect to use complex types, you should use “isType” to check if that element really contains the data type you expect, so you don’t end up with access violations in case the element is not assigned (in which case asRecord, asArray and asDataSet would return NIL).
Using the same paradigm, you can write your remote function to return any complex structure back to the client. You will simply prepare the data for “Result” using the same newRecord, newArray and newD