Recent

Author Topic: SetLength and Length  (Read 6667 times)

mikiwoz

  • Full Member
  • ***
  • Posts: 130
SetLength and Length
« on: February 27, 2005, 02:18:45 pm »
Hello
I seem to have a strange problem here:

procedure Something(var FirstArray:array of string);
var SecondArray:array of string;
begin
    SetLength(SecondArray, 1);
    SecondArray[0]:='SomeString';
    FirstArray:=SecondArray; <- ERROR HERE "The operator is not aplicable to operand type"
end;

WTF? Both arrays are of the same type.
I tried SetLength(FirstArray, 1);, but got "Type mismatch" error. Am I missing something?

TIA
Mike

matthijs

  • Hero Member
  • *****
  • Posts: 537
SetLength and Length
« Reply #1 on: February 27, 2005, 02:59:45 pm »
FirstArray is an array of string. SecondArray however is another array of string. What may help is:
Code: [Select]

type
  TMyArrayOfString = Array of string;

procedure Something(var FirstArray, SecondArray: TMyArrayOfString);
begin
  ....

Now they are both the same. :)
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

Lightning

  • Sr. Member
  • ****
  • Posts: 422
SetLength and Length
« Reply #2 on: March 18, 2005, 12:20:06 pm »
Yes when you define complex types you have to use define another type to make them compattible.
The future must be... Fast and OpenSource so...
Think Open and Lightning Fast!

 

TinyPortal © 2005-2018