Archive: How to call *only* one function and ignore all others from an include.nsh file?


How to call *only* one function and ignore all others from an include.nsh file?
Hello,

I am trying to exclude files from a recursive directive. I found one solution who's thread died two months ago, and the program unfinished without documentation. This is the approach I am taking on excluding certain files. I am not wildcarding extensions. I am only pin-pointing certain files in which I know their name and path. My target OS is 2000/NT/XP/2003.

This is what the section looks like...

Section
Call "file_move"
SetOutPath "$INSTDIR"
SetOverwrite on
File /r "C:\filepath"
SectionEnd


This is what the function in the include.nsh file looks like...


Function file_move
!system '"CMD/C|MOVE /Y "C:\filepath\file.ext" "C:\file.ext"'
FunctionEnd


The objective is to move the file before it gets recursed and included with the section. The above section, function and call work but this is the problem.

If I add a new function to the include.nsh to restore the moved file, it seems all commands within the include.nsh are executed. This is what the include.nsh file looks like...

Function file_move
!system '"CMD/C|MOVE /Y "C:\filepath\file.ext" "C:\file.ext"'
FunctionEnd


Function file_restore
!system '"CMD/C|MOVE /Y "C:\file.ext" "C:\filepath\file.ext"'
FunctionEnd


What basically happens is when I call file_move, both file_move and file_restore are executed. Is this correct? I thought by calling a single function by it's name only that function would be executed. If I am wrong, how then can I only call one function and shut out all others?

I am using a NSIS 2.05b snapshot from only a few days ago. There is no call anywhere in the entire script.nsi which calls function file_restore. Am I doing something wrong?


You are using run-time instructions (Call) to do something that you want to happen at compile-time. Your two functions should instead be macros. I.e. your .nsh file should contain

!macro file_move 
!system '"CMD/C|MOVE /Y "C:\filepath\file.ext" "C:\file.ext"'
!macroend
and your main script
Section 
!insertmacro "file_move"
SetOutPath "$INSTDIR"
SetOverwrite on
File /r "C:\filepath"
SectionEnd
etc.

Hello Eccles,

So sweet, it works like a charm. Thank's a million :)