Old 22nd April 2005, 08:03   #1
Huette
Member
 
Join Date: Apr 2005
Posts: 57
outsourcing functions to own "units" ?

Hi!
is there any documentation about outsourcing my own functions to external "units"?
i would like to use some functions in different projects, so it would be nice to write them in one "unit" and include it to the different projects. possible? didn't find anything about that in this forum or help / readmes.
Huette is offline   Reply With Quote
Old 22nd April 2005, 10:52   #2
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
If you mean parts of code writen in NSIS then you can use .nsh -file (NSIS header file). Put your functions in it and add this file to your script with !include command.
glory_man is offline   Reply With Quote
Old 22nd April 2005, 11:19   #3
Huette
Member
 
Join Date: Apr 2005
Posts: 57
yes, that's what i mean. sounds easy. i'll try.
Huette is offline   Reply With Quote
Old 28th April 2005, 13:18   #4
Huette
Member
 
Join Date: Apr 2005
Posts: 57
today i continued to work on my script and i got a strange error, when i try to work with functions in external nsh files:

!include: closed: "C:\Programme\NSIS\Include\CustFunctions.nsh"

Processed 1 file, writing output:
Error: invalid script: never had OutFile command
Error - aborting creation process

...i copied a function from my mainscript and saved it in a nsh-file (included Function/FunctionEnd. - nothing else above or below). when i comment the line
!include "CustFunctions.nsh" and the function i copied is still in my mainscript everything works fine. But when i comment the function and activate the !include-line, i got that outfile-error.
my include line follows the !include "mui.nsh" - line.
What am i doing wrong? Anybody got an idea?
Huette is offline   Reply With Quote
Old 28th April 2005, 13:35   #5
rasermar
Guest
 
Posts: n/a
this should not work:
code:
!include: closed: "C:\Programme\NSIS\Include\CustFunctions.nsh"


try this instead:
code:
!include "C:\Programme\NSIS\Include\CustFunctions.nsh"


The call to the functions on the included file can be done as ordinary.

And review the documentation this is explained there.

regards.
  Reply With Quote
Old 28th April 2005, 14:18   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Quote:
Originally posted by rasermar
this should not work:
code:
!include: closed: "C:\Programme\NSIS\Include\CustFunctions.nsh"


try this instead:
code:
!include "C:\Programme\NSIS\Include\CustFunctions.nsh"


The call to the functions on the included file can be done as ordinary.

And review the documentation this is explained there.

regards.
rasermar, he copied that from the compiler window (it's compiler output) where it's closed his !include after reading it.

The error is there... You're missing the OutFile command.

-Stu
Afrow UK is offline   Reply With Quote
Old 28th April 2005, 15:26   #7
Huette
Member
 
Join Date: Apr 2005
Posts: 57
you got it afrow =) it's the error-message, not my sourcecode

but the error-message doesn't make any sense imho. i got the outfile command in my mainscript....and if i don't use that function of my nsh-file, but exactly the same of my mainscript, it works.

i am not sure, but i think it already worked with the outsourced code on last friday and i didn't change any code since that day. could it be caused by some changes in preferences or something like that? tomorrow i will look into it more exactly.
Huette is offline   Reply With Quote
Old 28th April 2005, 15:28   #8
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
the out file command should be close to the beginning of the script.
any function should be after it i think.
Comm@nder21 is offline   Reply With Quote
Old 29th April 2005, 09:58   #9
Huette
Member
 
Join Date: Apr 2005
Posts: 57
well, i'm a bit confused, but now it works again. i just set the outfile-command to some different places. the order was var-lines, !include-lines, outfile-line. then i set the outfile-line above the !include-lines and compiled the script. i just got a few zeroing-code-warnings (why? no idea). then i saved both scripts and opened them again. suddenly they were working. after that i set the lines to their old positions and it still works...

sounds like a nsis-bug...but i'm not sure...maybe i overlooked something...

(sry, if my english is kinda bad - just overlook )
Huette is offline   Reply With Quote
Old 29th April 2005, 10:49   #10
Huette
Member
 
Join Date: Apr 2005
Posts: 57
i found out the cause of that problem. i try to subcribe. last week i tried to add another function (not that one i'm talkin about above) from my mainscript (there it was working correct) to my secondary-script. apparently i got an error (maybe the same) that day, deleted the function, added it back to my mainsript and stopped working. with the second function in the secondary-script i must have temporary made some chaos in nsis and nothing worked, though the function was in my main-script again. the second function is:

Function "FillLbl" ;keine Rückgabe
FindWindow $2 "#32770" "" $HWNDPARENT
GetDlgItem $2 $2 $1
CreateFont $3 "Arial" 8 0
SendMessage $2 ${WM_SETFONT} $3 0
SendMessage $2 ${WM_SETTEXT} 0 "STR:$0"
FunctionEnd

i think the exchange of the variables could be the problem....no idea...
Huette is offline   Reply With Quote
Old 24th July 2020, 01:17   #11
kayleycun
Junior Member
 
Join Date: Jul 2020
Posts: 1
RE: outsourcing functions to own "units" ?

I will start off by apologizing if this isn't the right location for this post. I tried to search for similar topics, but couldn't find anything for my specific questions and then I found this. I don't know why but I keep on getting error in this. I've put the out file command close to the beginning of the script and still got an error.
kayleycun is offline   Reply With Quote
Old 24th July 2020, 09:33   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,296
...and the error message is?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
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