lilkittenz Posted August 4, 2012 Share Posted August 4, 2012 I'm still fairly new to programming concepts, especially arrays. what I want to do is set an array of values within a 2D array equal to another array This is an example of what I mean: program New; var SomeArray: Array[0..9] of Integer; Some2DArray: Array[0..9] of Array[0..9] of integer; begin Some2DArray[0]:= SomeArray; end. I am currently getting a type Mismatch, but if Some2DArray[0] holds an array than why can't I set it equal to another array? Or am I misunderstanding how 2D arrays work? Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted August 4, 2012 Share Posted August 4, 2012 Thats because your treating you 2d array like a 1d array. Also you never specified which array you want to set. Heres a working example [scar] program New; var SomeArray: Array[0..9] of Integer; Some2DArray: Array[0..9] of Array[0..9] of integer; I: Integer; begin Some2DArray[0][0]:= SomeArray[0]; For I := 0 to High(SomeArray) do Some2DArray[0] := SomeArray; end. [/scar] Quote Link to comment Share on other sites More sharing options...
FHannes Posted August 4, 2012 Share Posted August 4, 2012 It judges your 2 declarations of the base array of Integer as different types, you need to declare the array as a type first, then it will work. [scar]type T10Ints = array[0..9] of Integer; var SomeArray: T10Ints; Some2DArray: array[0..9] of T10Ints; begin Some2DArray[0]:= SomeArray; end.[/scar] Quote Link to comment Share on other sites More sharing options...
lilkittenz Posted August 4, 2012 Author Share Posted August 4, 2012 Ah I see why it didn't work now. Thanks Guys. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted August 5, 2012 Share Posted August 5, 2012 It judges your 2 declarations of the base array of Integer as different types, you need to declare the array as a type first, then it will work. [scar]type T10Ints = array[0..9] of Integer; var SomeArray: T10Ints; Some2DArray: array[0..9] of T10Ints; begin Some2DArray[0]:= SomeArray; end.[/scar] Never tried it in a type before. Bookmarked! Thanks Freddy Quote Link to comment Share on other sites More sharing options...