Prev Previous Post   Next Post Next
Old 13th July 2005, 13:08   #1
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Question define function on-demand?

I'm just trying to clean up my code a bit. I like to wrap my own functions in an NSH file that I can !include when I need them using macros and return varaibles. (I find this much more convenient than using stack commands within a section or function.)

My list of functions (and NSH files) keeps growing. I'd like to take the ones I use most often and put then into a single NSH file. However, I might not use every single function declared in an NSH file.

I'd like to know if anyone has any tricks of defining a function "on demand". In other words, I want to automatically create a function only when needed. I thought perhaps I could encapsulate the function within "!ifdef" statements, but I'm not sure if that's the right way to go.

Here's an example of a basic NSH file layout that I currently use. Any advice would be appreciated. Thanks!
______________________________________________________
!macro MyFunc Return_var Input_var
push ${Input_var}
Call MyFunc
Pop ${Return_var}
!macroend

!define CoolFunction "!insertmacro MyFunc"

Function MyFunc
Exch $0
push $1
; do stuff with $0
; store result in $1
exch $1
exch
pop $0
FunctionEnd
Comperio is offline   Reply With Quote
 
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump