Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ArrayRedim UDF UDF User Defined Function Binary Buffer Corrupted Array Global Pointer PtrGlobalDefine ptrGlobal
ARR=ArrDimension(1) BUFFER=BinaryAlloc(480000) #DefineFunction ARRAYREDIM_WORKAROUND(ARR,DIM1,DIM2,DIM3,DIM4,DIM5) ArrayRedim(ARR,DIM1,DIM2,DIM3,DIM4,DIM5) #EndFunction #DefineFunction TEST(ARR) INDEX=ArrInfo(ARR,1) ArrayRedim(ARR,INDEX+1,-1,-1,-1,-1) ; ARRAYREDIM_WORKAROUND(ARR,INDEX+1,-1,-1,-1,-1) BIN=BinaryAlloc(32) BinaryPokeStr(BIN,0,"THIS IS A TEST STRING.") ARR[INDEX]=BIN #EndFunction TEST(ARR) TEST(ARR) TEST(ARR) TEST(ARR) #DefineFunction PRINT_R(ARR) TEXT="" For X=0 To ArrInfo(ARR,1)-1 If IsDefined(ARR[X]) Then TEXT=TEXT:X:" => [":BinaryPeekStr(ARR[X],0,32):"]":@CRLF Next Return TEXT #EndFunction Message("",PRINT_R(ARR))However, if the ArrayRedim() function is placed inside of another function and called via the other function, the data corruption does not occur.
I would not count on the proposed workaround consistently working either. For now you should not use the ArrayRedim, ArrayRemove, or ArrayInsert functions inside UDF/S's on arrays passed as parameters to the UDF/S.
One safe workaround would be to define and access the array as a global pointer.
PtrGlobalDefine(arr) #DefineSubRoutine TEST() parr = PtrGlobal(arr) INDEX=ArrInfo(*parr,1) ArrayRedim(*parr,INDEX+1,-1,-1,-1,-1) BIN=BinaryAlloc(32) BinaryPokeStr(BIN,0,"THIS IS A TEST STRING.") *parr[INDEX]=BIN #EndFunctionWe really appreciate users taking the time to report problems like this and we should have it fixed in the next release.
ARR=ArrDimension(0) #DefineFunction TEST(ARR) INDEX=ArrInfo(*ARR,1) ArrayRedim(*ARR,INDEX+1,-1,-1,-1,-1) BIN=BinaryAlloc(32) BinaryPokeStr(BIN,0,"THIS IS A TEST STRING.") *ARR[INDEX]=BIN #EndFunction TEST(&ARR)
Article ID: W17657
Filename: ArrayRedim Issue.txt
File Created: 2013:09:20:08:41:06
Last Updated: 2013:09:20:08:41:06