${TestArray->Sort} "" are exactly the same.Has anyone had this problem?
Thanks for your help.
20 posts
${TestArray->Sort} "" are exactly the same.Thanks to your help, my installer is now almost complete!StrCmp $ArrayErr "3" flush 0
I looked at $ArrayErr and it holds the first item (zero).
item 0:
item 1: one
item 2:
item 3:two
at the beginning, it works. If I change the range back to 0 -1 and leave the !define, I get error message (3)index out of range. I hope this helps you find the problem.
!define ArrayErrorMsgBox
The WriteList and WriteListC functions do not seem to care about the 32 items limit. The debug screen shows all 36 items and all of them are passed to the concatenation function.
!define FuncName 'Is Functions'
name '${FuncName}'
outfile 'ArrayExample - ${FuncName}.exe'
caption '${FuncName}'
!define ArrayErrorMsgBox
!include NSISArray.nsh
showinstdetails show
${Array} "TestArray"
Section
DetailPrint "Initializing array..."
${TestArray->Init}
DetailPrint "Testing 'WriteList'..."
${TestArray->WriteList} "'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' '1' '2' '3' '4' '5' '6' '7' '8' '9' '0'"
${TestArray->Debug}
${TestArray->Concat} $0 "&"
DetailPrint "$0"
DetailPrint "Testing 'IsEmpty'..."
${TestArray->IsEmpty} +2 0
DetailPrint "TestArray is NOT empty!"
DetailPrint "Testing 'IsFull'..."
${TestArray->IsFull} +2 0
DetailPrint "TestArray is NOT full!"
DetailPrint "Testing 'IsInRange'..."
${TestArray->IsInRange} 3 0 +2
DetailPrint "Index of 3 is in range of TestArray!"
DetailPrint "Testing 'IsInRange' again..."
${TestArray->IsInRange} 4 +2 0
DetailPrint "Index of 4 is NOT in range of TestArray!"
${TestArray->Delete}
${ArrayUnload}
SectionEnd
page instfiles
When I change the range to 0 3 I get all empty strings. This is the opposite behavior from when I mentioned it to you in the first place.
Item 0:
Item 1: one
Item 2:
Item 3: two
!define FuncName 'SearchI'
name '${FuncName}'
outfile 'ArrayExample - ${FuncName}.exe'
caption '${FuncName}'
!define ArrayNoValVar
!include NSISArray.nsh
!include StrFunc.nsh
showinstdetails show
${StrTrimNewLines}
${Array} "TestArray"
Function .onInit
GetTempFileName $R9
FileOpen $R2 $R9 w
FileWrite $R2 "Cat$\r$\n"
FileWrite $R2 "catt$\r$\n"
FileWrite $R2 "cate$\r$\n"
FileWrite $R2 "catherine$\r$\n"
FileWrite $R2 "CaDog$\r$\n"
FileWrite $R2 "CaHippo$\r$\n"
FileClose $R2
CopyFiles /SILENT $R9 "animals.txt"
Delete $R9
FunctionEnd
Section
DetailPrint "Initializing array.."
${TestArray->Init}
FileOpen $R0 animals.txt r
Loop:
ClearErrors
FileRead $R0 $0
IfErrors End
Push $0
Call StrTrimNewLines
Pop $0
DetailPrint "ArrayItem:$0"
${TestArray->SearchI} $1 "$0" 0
DetailPrint "Index:$1"
StrCmp $1 "-1" 0 same
${TestArray->Shift} "$0"
Goto Loop
Same:
DetailPrint "Item previously added"
Goto Loop
End:
DetailPrint "TestArray should contain:Cat, catt, cate, catherine, CaDog and CaHippo"
${TestArray->Debug}
${TestArray->Delete}
${ArrayUnload}
FileClose $R0
Delete "$EXEDIR\animals.txt"
SectionEnd
page instfiles
This test script shows weird characters at the end of the first item. The problem appears when used with WriteListC only. The 128 plugin seems to have a similar behaviour in this test script .EDIT: for the 128 plugin, only the first array has this problem. The second and subsequent arrays in your script will be fine.: WriteList, Push and Shift work OK
Name "WriteListC"
OutFile "WriteListC_test.exe"
Caption "$(^Name)"
!define ArrayPlugin 256
!define ArrayNoValVar
!include NSISArray.nsh
${Array} SoftList
XPStyle on
ShowInstDetails show
Section
${SoftList->Init}
DetailPrint "Writing one, two, three..."
${SoftList->WriteListC} "one|two|three" "|"
${SoftList->Debug}
${SoftList->Delete}
${ArrayUnload}
SectionEnd
sorts in this order: (1, 13, 2, 21, 3) this is not really what we usually want for numbers. Is there any way you could modify this? That's about it for now.
!define FuncName 'Sort'
name '${FuncName}'
outfile 'ArrayExample - ${FuncName}.exe'
caption '${FuncName}'
!define ArrayNoValVar
!include NSISArray.nsh
showinstdetails show
${Array} "TestArray"
Section
DetailPrint "Initializing array..."
${TestArray->Init}
${TestArray->WriteList} "'1' '2' '3' '13' '21'"
DetailPrint "Sorting..."
DetailPrint "Now View the sorted version:"
${TestArray->Sort} ""
${TestArray->Debug}
${TestArray->Delete}
${ArrayUnload}
SectionEnd
page instfiles