Archive: Possible bug with Afrow UKs Array Script Header


Possible bug with Afrow UKs Array Script Header
Hello all.

I'm using Afrow UKs script header, Array.nsh. It is very helpful, but I have run into a problem. When using the command:

${myArray->Exists} Value GotoIfExists GotoIfNotExists

and the item does not exist, I get a endless loop lock up. Compile the below code, it should work, and find "SecondItem" in the array. Then change:

${MyArray->Exists} "SecondItem" Label1 Label2

to

${MyArray->Exists} "SecondItemxxx" Label1 Label2

and you should see the problem. It should just goto Label2, when it does not find SecondItemxxx in the array. FYI, I'm using nsis 2.06.

Help! Thanks all.

Jnuw



!include "Array.nsh"

Name "ArrayTest"
OutFile ArrayTest.exe
InstallDir "$EXEDIR"
ShowInstDetails show

${Array} MyArray


Section ""

${MyArray->Init}

${MyArray->Shift} "FirstItem"
${MyArray->Shift} "SecondItem"
${MyArray->Shift} "ThirdItem"

${MyArray->Exists} "SecondItem" Label1 Label2

Label1:
MessageBox MB_OK "Exists"
Goto End

Label2:
MessageBox MB_OK "Not Exists"

End:
SectionEnd

Thanks, I'll fix tomorrow. You should try my array plugin instead though which has been tested more thoroughly.

-Stu


Sounds good, thanks for taking a look at it.

Jnuw


${myArray->Exists} Value GotoIfExists GotoIfNotExists

"Checks whether Value exists in myArray, and
jumps to label GotoIfExists: if it exists
or GotoIfNotExists: if it does not.
Note GotoIfExists and GotoIfNotExists must
be label names, not relative (e.g. +4)"

-Stu


Hi Afrow UK. I'm confused. Was I not using your array header correctly? Or are you saying that you fixed it? Thanks for your help.

Jnuw


You weren't using the function correctly. It doesn't check if the array exists but if the value exists in the array.

-Stu


Hey Stu. I believe that I was using it correctly to check if "SecondItem" is a value within MyArray. When using the above code, "${MyArray->Exists} "SecondItem" Label1 Label2" it would find SecondItem, and go to Label1. However when changing the line to "${MyArray->Exists} "SecondItemxxxxx" Label1 Label2" it does not go to Label2 as it should, it enters an endless loop.

Does the code work on your PC? Sorry if i'm still missing something. Thanks for your help.

Jnuw


Sorry, my mistake you are using it correctly but on my machine it works. I get an "Exists" message.

I've uploaded the Zip again.
I'm guessing that you downloaded it from the first mirror (hosted by Wiki) which may have been out of date.

http://myweb.tiscali.co.uk/imker/downloads/Array.zip

I would still recommend using the array plugin instead as it is much faster on run-time but of course it will use a little more space in your installer.

-Stu


No worries, thanks for looking at it. I downloaded the new zip file from above, and re-compiled. I still get the endless loop. Compile the below code, and you should too.


!include "Array.nsh"

Name "ArrayTest"
OutFile ArrayTest.exe
InstallDir "$EXEDIR"
ShowInstDetails show

${Array} MyArray


Section ""

${MyArray->Init}

${MyArray->Shift} "FirstItem"
${MyArray->Shift} "SecondItem"
${MyArray->Shift} "ThirdItem"

${MyArray->Exists} "SecItem" Label1 Label2

Label1:
MessageBox MB_OK "Exists"
Goto End

Label2:
MessageBox MB_OK "Not Exists"

End:
SectionEnd

Ah yes you're right!
I had a small typo in the code (2 occurances in the Exists function):
"$${Array}_UBound}" which should be "$${Array}_UBound"
Uploaded fixed version.

-Stu


That did the trick, thanks so much! And I will check out the plugin ASAP.

Jnuw


Hey Stu, I switched over to your array plugin (NSISArray.nsh) because I found another problem with the array.nsh header. The ${MyArray->Exists} command above still enters an endless loop if you check for the existence of value in an array when the array is empty, or only has 1 item in it. Just thought I would pass that along.

The array plugin (NSISArray.nsh) though is working perfectly, so thank you for the advice to switch over to it, I'm very happy with it. I do have 1 question though, after compiling my installer with the plugin, I get a warning in HM NIS Edit that says, "Variable "ArrayVal" not referenced, wasting memory!" I am not using a variable by that name, so I thinking it is being declared within the plugin somewhere. Should I be concerned about this? Thanks so much for your help, I really do appreciate it.

Jnuw


Thanks, I'll look into both of those things tonight when I get home (in 2 hours).

-Stu


Thanks Stu, I'll have to buy you a beer next time I'm over in England!


That would be nice! I will be able to drink legally in a few months (18).

I can't find out why the old script header Exists function is infinitely looping. Are you sure you have the latest version? It will say Last modified: 6th September 2005 in Include\Array.nsh
As for the NSISArray plugin, download the new version:
http://nsis.sourceforge.net/wiki/File:NSISArray.zip
See section 1.2.1 of the documentation.

-Stu


Thanks Stu, the new version of the NSISArray plugin with the !define ArrayNoValVar command did the trick, runs perfectly, thanks again!

Jnuw