twenty_sleven Posted February 12, 2012 Share Posted February 12, 2012 Trying to concat certain values of an array of strings with a string, yet I continue to get the message "out of range", any help? program HelloWorld; var i: Integer; str: String; aRay: array of string; begin str:= 'Hello'; aRay := ['W','o','r','l','d','!']; for i := 0 to Length(aRay) do str:= str + aRay[i]; end. //str := str +'World!'; WriteLn(str+); end. Quote Link to comment Share on other sites More sharing options...
FHannes Posted February 12, 2012 Share Posted February 12, 2012 [scar]program HelloWorld; var i: Integer; str: string; aRay: array of string; begin str := 'Hello'; aRay := ['W', 'o', 'r', 'l', 'd', '!']; for i := 0 to Length(aRay) - 1 do str := str + aRay; WriteLn(str); end.[/scar] You're looping from 0 to the Length, Length returns the number of values in the array, not the index of the largest item, the index is equal to the result of High or Length - 1. Quote Link to comment Share on other sites More sharing options...