trying to extract a slice
BlitzMax Forums/BlitzMax Programming/trying to extract a slice
| ||
Local a$[3] a[1] = "harry" a[2] = "franky" Local b$[3] b[1] = "harry" b[2] = "franky" Local temp_a$[a.length] Local temp_b$[b.length] temp_a=a[1..2] temp_b=b[1..2] Print "a length: "+a.length Print a[1] Print temp_a[0] Print temp_a[1] Print b[1] Print temp_b[0] Print temp_b[1] I set up 2 arrays a[3] and b[3] then I setup 2 more to hold some slices temp_a[a.length] and temp_b[b.length] but when I try to access temp_a[1] it doesnt seem to exist |
| ||
From the Slices doc : The length of the returned slice is always ( EndIndex - StartIndex ) elements long, even if StartIndex is less than 0 or EndIndex is greater than the length of the string or array. You're slicing 1 array entry from index 1 and writing it to Temp_a position 0 |
| ||
oh ok so 1->2 is really just 1 thanks |