Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>New Idea: Do you have range checking on in this unit? Add {$R+}</strong></p> <p>If you want to use a dynamic array type, you must explicity set its length in the constructor before you access it, and when copying/assigning, you must be very careful as well. </p> <p>Not only must you call SetLength on each TByteDynArray before accessing its elements:</p> <pre><code>SetLength(Fdata, MyDesiredLengthWhichIsGreaterThanZero): </code></pre> <p>You must also be careful here, I think this could get you in trouble:</p> <pre><code> property data: TByteDynArray read Fdata write Fdata; </code></pre> <p>Your auto-generator made that code for you, and if you really know you want a dynamic array, you apparently CAN make it published. (Updated: I was wrong about that initially). </p> <p>TRemotable, as Rob points out, does not work with indexed properties but does work fine with "array of byte" (TByteDynArray) properties, so if you do everything right, you do not need to stop using TByteDynArray (I was wrong about that initially). </p> <p>If it was me writing this from scratch, I would use a "string" type instead like TBytes. I am wondering why it didn't use TBytes, but I understand that you are implementing a SOAP client using some auto-generated WSDL-generator-code. So given that, it should be eminently possible to make your code not crash.</p> <p><a href="https://stackoverflow.com/questions/3154879/delphi-problem-setting-length-of-a-tbytedynarray">see also this Related question</a></p> <p>I do not know how to write a SOAP client, but it looks like your code does some dodgy things. It looks like you need to fix your dynamic array handling, including the "uh-oh, why are you doing a Cast here" problem Rob pointed out to you. However, it does not look like you are free to just change types either, as it looks like you must use types that are known by and handled by your TRemotable mechanisms.</p> <p>As for your request, this should work:</p> <pre><code> procedure TestMe( whatever:TWhatever ); var FData:TByteDynArray; begin SetLength(FData,2); FData[0] := 10; FData[1] := 20; sendMessage(FData, whatever); end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload