1.1.1.4 - 3rd September 2012Please update your code accordingly if you switch to the new version.
* Replaced Set /list with SetList.
* Replaced Remove /list with RemoveList.
Stu
54 posts
1.1.1.4 - 3rd September 2012Please update your code accordingly if you switch to the new version.
* Replaced Set /list with SetList.
* Replaced Remove /list with RemoveList.
ClearErrors
nsArray::Get UrlTree $CompleteGroup
${If} ${Errors}
${DebugMsg} "UrlTree($CompleteGroup) is not set!"
${Else}
Pop $CompleteTotal
; There are some files
${EndIf} ClearErrors
nsArray::Get MyArray 2
Pop $R0
${If} ${Errors}
DetailPrint `Error!`
${EndIf} Because elements with no specified keyname are presumably given a keyNAME of their initial index.
nsArray::Set "myArray" "0"
nsArray::Set "myArray" "1"
nsArray::Set "myArray" "2"
nsArray::Set "myArray" "3"
;array now = {"0", "1", "2", "3"}
nsArray::Remove "myArray" /at=1
;array now = {"0", "2", "3"}
nsArray::Set "myArray" /key=2 "three"
;array now = {"0", "three", "3"}
!macro ArraySetAt arrayname index value
Push $R0
ClearErrors
nsArray::Get "${arrayname}" "/at=${index}"
${IfNot} ${Errors}
Pop $R0 ;key
Exch $R0 ;discard value
Pop $R0 ;discard value
nsArray::Set "${arrayname}" "/key=$R0" "${value}"
${EndIf}
Pop $R0
!macroend
That is correct - the readme does not show any uses of /at= with the Set instruction, but I could add it.Originally Posted by Marshallx7 View Post/at= does not work with the Set command.
This is not true. Your array after the Remove call is:Originally Posted by Marshallx7 View PostFurther more /key= only works on keynames, not indexes
myArray = {0 => 0, 2 => 2, 3 => 3}After your Set call, it becomes:myArray = {0 => 0, 2 => three, 3 => 3}There is no distinction between numeric keys and string keys. It is just that numeric keys are assigned when no key is specified when adding elements.1.1.1.5 - 26th May 2013Note that if you use iteration using the Get function (/next, /prev and /reset) you must switch to the Iterate function (see the readme for usage).
* Added /at= for Set and SetList functions.
* Fixed SetList and RemoveList not setting the error flag on error if one element was not set/added or removed successfully.
* Added Iterate function which replaces iteration using Get with /next, /prev and /reset.
1.1.1.6 - 1st June 2013Stu
* Fixed memory access violation in Iterate function due to NULL pointer when an invalid array name is supplied.
When I run nsArray.exe, the output is 'MyArray[0] is a'
!include nsArray.nsh
OutFile nsArray.exe
Name nsArray
ShowInstDetails show
XPStyle on
RequestExecutionLevel user
Page Components
Page InstFiles
Section
nsArray::SetList MyArray appbuttonc_aurora appbuttonc_blue appbuttonc_black appbuttonc_palemo appbuttonc_transp appbuttonc_green appbuttonc_gray appbuttonc_purple appbuttonc_white appbuttonc_red /end
nsArray::Get MyArray 0
Pop $R0
DetailPrint `MyArray[0] is $R0`
SectionEnd