Forum > Designer

Variable array error

(1/1)

Degibbo:
G'day all,
Me again - all has been going good with various projects but this problem has me stumped:

I have defined a type TByteArray [0..49] of byte.

When the following procedure is run, the variable OutArray does not seem to exist.
The error is "Cannot access memory at address 0x0".  Why?  What have I done wrong?
(The InArray is OK).

procedure TUserForm.CopyArray(InArray : TByteArray ; var OutArray : TByteArray);
var
  I : integer;
begin
  for I := 0 to 49 do
    OutArray := InArray;
end;

molly:

--- Quote from: Degibbo on September 14, 2017, 01:52:30 am ---What have I done wrong?

--- End quote ---
for starters: not having your posted code between code tags...  :)

see how it reads differently when you use code tags:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TUserForm.CopyArray(InArray : TByteArray ; var OutArray : TByteArray);var  I : integer;begin  for I := 0 to 49 do    OutArray[I] := InArray[I];end; 
Secondly, you should be posting code in such fashion that it is able to compile. (at the least you should be showing all relevant declarations and subroutines).

That you think you've done it right doesn't exactly guarantee that you actually have done so. Unfortunately we can't see that.

So where is your actual declaration of TByteArray and how do you call this TUserForm.CopyArray() procedure ?

bytebites:
Or simply


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TUserForm.CopyArray(InArray : TByteArray ; var OutArray : TByteArray);begin    OutArray := InArray;end;

Navigation

[0] Message Index

Go to full version