TummaSuklaa Posted August 13, 2016 Share Posted August 13, 2016 I'm needing to do this so that I don't make a hugely long function to go through 7 other arrays.. anyone knows how to do this? Just an example is all I need. Link to comment Share on other sites More sharing options...
khazerruss Posted August 13, 2016 Share Posted August 13, 2016 Do what? For what I understand u want to duplicate an array, yes? Link to comment Share on other sites More sharing options...
TummaSuklaa Posted August 13, 2016 Author Share Posted August 13, 2016 (edited) If you understand it that way, then yes. To further clarify, it's moving the contents of an array into another empty array. Edited August 13, 2016 by TummaSuklaa Link to comment Share on other sites More sharing options...
khazerruss Posted August 13, 2016 Share Posted August 13, 2016 You can do it with recursive function. Link to comment Share on other sites More sharing options...
TummaSuklaa Posted August 13, 2016 Author Share Posted August 13, 2016 (edited) I don't know how to do that. I'm not that far into arrays. Not that good with them.. but they are faster than typing a billion if/elseif statements.. Nevermind, I'll just think of a traditional longer way to do it. Whenever I look to arrays to make things easier, I get stuck because I can't get help with certain parts of it. It's not that well explained on the wiki, or well anywhere. Edited August 13, 2016 by TummaSuklaa Link to comment Share on other sites More sharing options...
scrivener07 Posted August 13, 2016 Share Posted August 13, 2016 Heres my untested guess. I did not use any recursive pattern. I used a loop pattern involving the current index and length of the array. For each element in "fromArray" I add it to the "toArray". I am not checking for duplicates or none elements. Function CopyTo(var[] fromArray, var[] toArray) Global If (fromArray && toArray) ; does not equal none int idx = -1 While(idx < fromArray.Length) idx += 1 toArray.Add(fromArray[idx]) EndWhile EndIf EndFunction Link to comment Share on other sites More sharing options...
Reneer Posted August 14, 2016 Share Posted August 14, 2016 (edited) Heres my untested guess. I did not use any recursive pattern. I used a loop pattern involving the current index and length of the array. For each element in "fromArray" I add it to the "toArray". I am not checking for duplicates or none elements. Function CopyTo(var[] fromArray, var[] toArray) Global If (fromArray && toArray) ; does not equal none int idx = -1 While(idx < fromArray.Length) idx += 1 toArray.Add(fromArray[idx]) EndWhile EndIf EndFunction You forgot a return statement. That function won't do anything worthwhile since Papyrus function parameters are passed by value, not reference. Other than that, it looks good. Edited August 14, 2016 by Reneer Link to comment Share on other sites More sharing options...
scrivener07 Posted August 14, 2016 Share Posted August 14, 2016 I havent tested the function or anything but the array reference says setting arrays and passing arrays are passed and assigned by reference. Link to comment Share on other sites More sharing options...
TummaSuklaa Posted August 14, 2016 Author Share Posted August 14, 2016 Thank you kindly. Link to comment Share on other sites More sharing options...
Reneer Posted August 14, 2016 Share Posted August 14, 2016 (edited) I havent tested the function or anything but the array reference says setting arrays and passing arrays are passed and assigned by reference. Well, I was wrong. Thank you for correcting me. :) Though the wording on the Wiki is very contradictory, so I would recommend a test. Edited August 14, 2016 by Reneer Link to comment Share on other sites More sharing options...
Recommended Posts