Archive: Invalid Command: ${StrLoc}


Invalid Command: ${StrLoc}
I am trying to manage a condition in my install. I want to check a string for occurencies of a certain substring, for example "XD1".
But when i call the StrLoc function the system either returns "Invalid Command ${StrLoc}" or says it is having problems resolving install function StrLoc. Then it gives me the tip that uninstall functions must begin with "un." and install functions must not.

I have included LogicLib.nsh and I am running version 2.07.

Please help me, I am stuck!


!include "StrFunc.nsh"

StrFunc.nsh has to be inside Include directory, so you don't have to
specify a path.

You have to put this command before any command used in this header file.
Find it at: NSIS\Docs\StrFunc\StrFunc.txt :-)

Hmm, strange that the page about StrLoc tells me that i need the LogicLic header file but not the StrFunc...


Ok, I got one step further, but now I am stopped by this:
!insertmacro: FUNCTION_STRING_StrLoc
!insertmacro: macro "FUNCTION_STRING_StrLoc" requires 0 parameter(s), passed 4!

I make the call of the function like this:
${StrLoc} $0 $%MITRION_LICENSE% "xd1" ">"
and according to the nsis homepage it should work, but it doesn't.


in case you use ${if} ${else} ${unless} etc statements you need LogicLib as well :-)


I know, I use both now, but why does the StrLoc-function say that it needs zero arguments instead of four?


in deed it says this. maybe a bug?


Perhaps, it seems very strange to me so I have decided to solve the problem by using our perl-script and send a parameter to the nsis-script instead...

If anyone comes up with an idea, please post it.


nope! we both did not read the doc deeply!
now it works!

!include "StrFunc.nsh"
${StrLoc}

section -

${StrLoc} $0 "This is just an example" "just" "<"
detailprint '$0'

sectionEnd


Did you put ${StrLoc} (with no parameters) after !include StrFunc.nsh? I don't think you did, because that causes the problem that you described.
It shows this in the readme and in the example script.

-Stu


Is it supposed to be directly after? Because I make all my includes in the beginning of the file...


it is supposed to be this:

3.1 How To Use Commands In Install Sections and Functions
---------------------------------------------------------

Every command used in install sections and functions have to be called
first before and out of any sections and functions, and without
parameters.

Example:
--------

${StrStr}

3.2 How To Use Commands In Uninstall Sections and Functions
-----------------------------------------------------------

Commands with Uninstall Sections and Functions support have "Un" before
the words inside curly brackets "{}".

Example:
--------

${UnStrStr}

A complete example with both Install and Uninstall Commands:
------------------------------------------------------------


!include "StrFunc.nsh"

${StrStr} # Supportable for Install Sections and Functions

${UnStrStr} # Supportable for Uninstall Sections and Functions

Section

${StrStr} $0 "OK! Now what?" "wh"

SectionEnd

Section Uninstall

${UnStrStr} $0 "OK! Now what?" "wh"

SectionEnd

Ahhhhh
NOW I get it!
I guess I haven't got enough patience to find that in a readme.
Thanks a lot guys!