RTC Forums

Subscription => Support => Topic started by: sfarmer on February 05, 2014, 09:50:43 PM



Title: How to return more than one value in TRtcFunction
Post by: sfarmer on February 05, 2014, 09:50:43 PM
Hi,

We are trying to replace DataSnap with RealThinClient. We have created a Client and Server app with TRtcFunctions. In one of the functions I need to return a Stream and a set of parameters that define information about the stream such as Type, etc. How can I return the stream and additional return value(s)?

Thanks

Simon


Title: Re: How to return more than one value in TRtcFunction
Post by: D.Tkalcec (RTC) on February 05, 2014, 09:54:15 PM
Check this FAQ Topic (http://realthinclient.com/sdkarchive/index2ccb2ccb.html).

For more information, please go through these topics (https://rtcforum.teppi.net/index.php?topic=311.0).

Best Regards,
Danijel Tkalcec


Title: Re: How to return more than one value in TRtcFunction
Post by: sfarmer on February 06, 2014, 07:02:59 AM
Hi,

I got this working in 2 ways:-

  with Result.NewRecord() do
  begin
    asInteger['Type'] := 1234;
    NewByteStream('Stream').WriteBuffer(MemoryStream.Memory^,MemoryStream.Size);
  end;

and

  with (Result.NewArray()) do
  begin
    asInteger[0] := 1234;
    NewByteStream(1).WriteBuffer(MemoryStream.Memory^,MemoryStream.Size);
  end;

I was wondering is there any benefit to using an Array or Record?

Thanks

Simon


Title: Re: How to return more than one value in TRtcFunction
Post by: D.Tkalcec (RTC) on February 06, 2014, 09:15:10 AM
Records have fields with names, Arrays have fields with integer values and start at index 0. You will use one or the other based on your requirements.

Best Regards,
Danijel Tkalcec


Title: Re: How to return more than one value in TRtcFunction
Post by: sfarmer on February 06, 2014, 12:24:17 PM
Hi,

I'm using TRtcHTTPClient in blocking mode with the following function:-

  procedure TdmClient.GetSpecialData(var Data: string);
  begin
    with ClientModule do
    begin
      with Data.newFunction('GetSpecialData') do
      begin
        Call(GetSpecialDataResult);

        // Can I get at the Result here so that I can set Data?
      end;
    end;
  end;

Is it possible to get at the result after the Call(GetSpecialDataResult) as I want to be able to return the Data value?

I know I can store the result with a TRtcResult but i'm going to have lots of these calls and it makes it a little messy.

Thanks

Simon


Title: Re: How to return more than one value in TRtcFunction
Post by: D.Tkalcec (RTC) on February 06, 2014, 12:41:33 PM
You are asking questions which are all answered in the FAQ topic I've posted above. Please read it through and you will find all your answers. You can not start using the components, without having at least the basic understanding of how they work.

Before you dive into your Project and start asking questions on the Forums, please take a few days to go through Quick Start lessons and examples.

Thank you.

Best Regards,
Danijel Tkalcec


Title: Re: How to return more than one value in TRtcFunction
Post by: sfarmer on February 06, 2014, 02:09:11 PM
Hi,

Yes you are right, sorry about that. I have everything working now.

Thanks

Simon