Copy Array Strangeness
I have 2 arrays, array1[16][3] & array2[16][3]
I'd like to copy array 1 to 2 which I used
If I do
Any idea why one works and not the other. I would assume I could do a straight copy of an array as in the first example.
I'd like to copy array 1 to 2 which I used
array2 = array1But this does not work.
If I do
for (i=1; i<=16; i++)
{
array2[i] = array1[i]
}
works.Any idea why one works and not the other. I would assume I could do a straight copy of an array as in the first example.
0
Comments
Andy
I've only made copies of structs for legibility purposes, so I'm curious.
Here on a back button I use a stack_var which initializes all elements to 0 or '' to clear a level of a structure before taking the step back:
if(nLevel > 0 && nLevel <= MAX_UI_Level) { STACK_VAR _sLevelList sZeroLevelList ; STACK_VAR _sLevel sZeroLevel ; STACK_VAR INTEGER nAllowCompile;//only purpose is to allow this code to complile, otherwise throws an error nAllowCompile = 1;//only purpose is to allow this code to complile, otherwise throws an error sLevelList[nLevel] = sZeroLevelList ; sLevel[nLevel] = sZeroLevel ; }Likewise you can copy one level to another or copy zone data to another.Here I create a stack_var of a structure to load parsed data. Once I successfully complete the parsing I transfer the stack to the global structure:
DEFINE_FUNCTION fnParse_SongInfo(CHAR iCmdParams[][]) { STACK_VAR _sPlayList myPlaylist ; ACTIVE(cTag == 'count'): myPlaylist.nCount = atoi(cStrSeg) ; ACTIVE(cTag == 'genre'): myPlaylist.cGenre = cStrSeg ; ACTIVE(cTag == 'genre_id'): myPlaylist.cGenre_ID = cStrSeg ; ACTIVE(cTag == 'coverid'): myPlaylist.cCoverID = cStrSeg ; ACTIVE(cTag == 'artist'): myPlaylist.cArtist = cStrSeg ; ACTIVE(cTag == 'artist_id'): myPlaylist.cArtist_ID = cStrSeg ; ACTIVE(cTag == 'album'): myPlaylist.cAlbum = cStrSeg ; ACTIVE(cTag == 'album_id'): myPlaylist.cAlbum_ID = cStrSeg ; ACTIVE(cTag == 'title'): myPlaylist.cTitle = cStrSeg ; cont....................... sSBS.sPlaylist[nIndx] = myPlaylist ;So you can basically copy the entire structure or just certain segments of the structure as needed as long as the structures or segement of the structures have the same architecture.