Prev Previous Post   Next Post Next
Old 13th July 2005, 15:12   #3
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
That's what StrFunc/UseFunc, and Instructor's header files do. The best of them would be UseFunc, because function calls and the functions themselves have less instructions than the others.

Just look at the call to StrCase now:

code:

!macro ${_FuncCall} ResultVar String Type
${_UseFunc_FuncCall_Start}
${UseFunc_Echo} `$ {${_Un}${_Name}} "${ResultVar}" "${String}" "${Type}"`
Push `${String}`
Push `${Type}`
Call `${_Un2}${_Name}`
Pop `${ResultVar}`
${_UseFunc_FuncCall_End}
!macroend



This call is suitable for both installer and uninstaller. The echo line is optional.

Or I could use your example function to create one with UseFunc. It would be built like this:

code:

${_UseFunc_DefHeader} `Cool` `NSIS Cool Functions Header File` `1` `0` `` `` `2005 Comperio`

${_UseFunc_DefFunc} `Function` `CoolFunction Function` `1` `0` `` `` `2005 Comperio`

!macro ${_FuncCall} Return_var Input_var
${_UseFunc_FuncCall_Start}
${UseFunc_Echo} `$ {${_Un}${_Name}} "${Return_var}" "${Input_var}"`
Push `${Input_var}`
Call `${_Un2}${_Name}`
Pop `${Return_var}`
${_UseFunc_FuncCall_End}
!macroend

!macro ${_Func}
${_UseFunc_Func_Start}
Exch $0
push $1
; do stuff with $0
; store result in $1
exch $1
exch
pop $0
${_UseFunc_Func_End}
!macroend



I'm just not sure if the version and credits should be necessary. Those are only used when the internal echo message when a function is included, and to create new defines just for the version and the credits.

You see there that the header has the prefix name for all its functions called "Cool". If you have a function called "Function", you would have the final function name as "CoolFunction". Also, the name of the function is used for all its posterior uses: there is no need to put it several times. You can also use the ${_Name} define for this.

The function can be included the same way as you did with StrFunc. ${CoolFunction} outside functions and sections for function definition, ${CoolFunction} "Return_var" "Input_var" inside sections or functions. Any function definition is only added to the size of the installer if you call it first.

I'll release it to public soon as it has a documentation.

My Wiki Pages

Working now on:
New projects. (language: any)

Last edited by deguix; 13th July 2005 at 15:45.
deguix 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