Skip to content
⌘ NSIS Forum Archive

NSISArray plugin

147 posts

Afrow UK#
Uploaded v0.6 with the new $ArrayErr (stack) error support. Use !define ArrayErrorMsgBox to use the old school error message boxes.

-Stu
Comperio#
Afrow,
Just found another bug. In your header in the macro 'Array_Delete', you are undefining ${ArrayObj}.

Since ${ArrayObj} is used goblaly (meaning that more than one array can use it), it will cause the compiler to crash when you need to undefine more than one array.

(The reason I spotted it was becuase I happend to be using 2 arrays in my installation.)
Afrow UK#
For some reason I missed out the new header file which adds support for the ArrayErrorMsgBox define (and fixes that problem you've mentioned).

-Stu
Comperio#
Another issue I'm still looking into, but perhaps you could guide me:

I've noticed that NSISArray.dll is not being removed from the plugins directory. I'm using 2 arrays and I'm deleting both using the ${arrayName->delete} command in my last (hidden) section.

Should I be placing this command somewhere else (like in .onInstSuccess)? Is there another command/procedure I should be using?
Afrow UK#
I've added ${ArrayUnload} to this build (v0.6 RC3).
Also updated all your example scripts (can't use ${Array} inside a Section or Function, added ${Array->Delete} and ${ArrayUnload} to all scripts).

I found out why NSISArray.nsh wasn't included in the last Zip. It actually was, but for some reason it was put in the Plugins folder instead. So make sure you delete Plugins\NSISArray.nsh.

-Stu
Comperio#edited
Thanks! I'll check it out.

edit:
Things seem to be working great!
😁
superruzafa#
I want to use two arrays in my installer. This basic example results in a compiling error. A bug?

!include nsisarray.nsh

outfile array.exe

${Array} "array1"
${Array} "array2"

section -array

sectionend
Error: variable "ArrayErr" already declared
Error in macro Array on macroline 3
Comperio#
I did some digging and found the problem (and turned up another problem in the process). My modified header file attached should fix it. (Note that I changed the name of the header file. Afrow may have another way he'd prefer to handle it so I didn't want my modifications to be confused with the 'official' version.)

Two problems addressed (which are also commented in the attached header file):
1. the variable ArrayErr was getting defined multiple times when the array messagebox handling was turned off. To correct this, I turned the !define "ArrayErrorMsgBox" into a macro. So insted of using the "!define ArrayErrorMsgBox", I can now use "${ArrayErrorMsgBox}". (This is only if you want the plugin to generate error messages instead of you handling it the script. See the original docs for more info.)

2. ArrayUnload was also getting defined more than once. To correct this, I simply enclosed the ArrayUnload define inside an "!ifndef" block.
Afrow UK#
Thanks for helping out.
I had to go about ArrayErrorMsgBox differently though as when the ArrayErrorMsgBox is defined, all functions will do a Pop $ArrayVar. However, your code had it defined constantly and therefore it couldn't work.
With the Var ArrayErr, I've just added another define so that it isn't added twice.

(Uploaded v0.6 RC4)

-Stu
Afrow UK#
Uploaded v0.7.

Added a second parameter to ${myArray->Sort} which can specify another array name. The 2nd array will be rearranged into the same order as the sorted array (works like associative arrays). Both arrays must be of the same size initially.

Added the SetSize function to set the array to a specific size of items.

-Stu
Guest#
Hello,

It would be possible to add a function in the array plug-in that erase the elements which appear already in the array?
bholliger#
array-pop does not work

Hi Stu

This array-plugin is great! Thank you very much!

With the plugin I would like to pop some values from the array. The value returned was "2" and nothing happened to the array.

Even the provided example did not work. I would be glad, if you could investigate in this.

Thank you very much!

Have a nice Day.

-Bruno.
Afrow UK#
Thanks, fixed.
Let me know if you discover any other problems.



SuperPat:
Use ${myArrayName->Clear}

-Stu
Guest#
Hey Stu!

Your plugin is really great!
But I have a problem with your script.
For example when executing ${MyArray->Init} there seems to be a value popped from the stack but the function in your plugin doesn't push anything to the stack so the stack is getting emptier!

Some other macros do this too!

I think it's a bug, isn't it!?

-Marcy
Grimace#
Variable name length

I'm new to NSIS and gratefully using the NSISArray plugin. I stumbled upon an issue which I, by some debugging, tracked down to variable name length of arrays. I'm not sure whether this restriction is by NSIS design, or an NSISArray issue (or just me overlooking something else).

Anyway, when using the following code:


${Array} "TheObject->Foo1_"
${Array} "TheObject->Foo2_"

Section
${TheObject->Foo1_->Init}
${TheObject->Foo2_->Init}
${TheObject->Foo1_->Debug}
${TheObject->Foo2_->Debug}
SectionEnd
you'll only get a debug window for the last initialized array (you can verify that by swapping the 2 Init statements). If you remove the underscore to shorten the variable names, all works fine.

Am I stretching some limits, or is this a bug?
Grimace#
Re: Variable name length

Originally posted by Grimace

Am I stretching some limits, or is this a bug?
Ok, I took a quick look at the plugin code, and I guess this one's responsible for it:

char arrNames[ARRAY_MAX_COUNT][16];
I think I'll just recompile then 😉
Afrow UK#
Version 1.1 is available for download.

Its most notable change is support for dynamic arrays.
A complete list of changes can be found in the included documentation.



-Stu
SuperPat#edited
Hello

It there a bug with NSISArray 1.2 with the Exists and ExistsI function?

This is a peace of code that add in a array the name of all the directory contained in $SMPROGRAMS (it work well with the version 1.0):

    StrCpy $MUI_TEMP2 ""

NSISArray::New /NOUNLOAD "SMProgList"


SetShellVarContext current
FindFirst $UMUI_TEMP3 $MUI_TEMP1 "$SMPROGRAMS\*"
FindNext $UMUI_TEMP3 $MUI_TEMP1
loop:
FindNext $UMUI_TEMP3 $MUI_TEMP1
StrCmp $MUI_TEMP1 "" exit
IfFileExists $SMPROGRAMS\$MUI_TEMP1\* add
goto loop
add:
NSISArray::ExistsI /NOUNLOAD "SMProgList" "$MUI_TEMP1" 0
Pop $MUI_TEMP2
MessageBox MB_OK "$MUI_TEMP1 $MUI_TEMP2"
StrCmp $MUI_TEMP2 -1 0 NoAdd
NSISArray::Push /NOUNLOAD "SMProgList" $MUI_TEMP1
NoAdd:
goto loop
exit:
FindClose $UMUI_TEMP3
Tthe value of $MUI_TEMP2 is curiously allways "4" 😱
Consequently, no items are added in the array
SuperPat#edited
I have found an other problem:

This is a test code:

NSISArray::New /NOUNLOAD "SMProgList"

NSISArray::Push /NOUNLOAD "SMProgList" "a"
NSISArray::Push /NOUNLOAD "SMProgList" "b"
NSISArray::Push /NOUNLOAD "SMProgList" "c"
NSISArray::Push /NOUNLOAD "SMProgList" "d"
NSISArray::Push /NOUNLOAD "SMProgList" "e"
NSISArray::Push /NOUNLOAD "SMProgList" "f"
NSISArray::Push /NOUNLOAD "SMProgList" "g"

NSISArray::Concat /NOUNLOAD "SMProgList" "|"
Pop $UMUI_TEMP3
MessageBox MB_OK "$UMUI_TEMP3"

NSISArray:😁elete /NOUNLOAD "SMProgList"

NSISArray::Unload
Instead of return "a|b|c|d|e|f|g", it return "4" 🙁

Edit: apprently "4" is the error code for the array does not exist