Old 27th May 2003, 15:01   #1
banaman8d
Junior Member
 
Join Date: May 2003
Posts: 19
SetErrors in a plugin.

Hi,

I am writing a generic application update tool using
specially formatted .ini files and a plugin used to
fill in values specified in the ini files.

For example a valid ini entry would look like:
key={INSTDIR}\somedir

and I use the plugin to replace this with the value of $INSTDIR.

I am new to writing plugins for NSIS, and NSIS for that matter, but
after digging through the sources for a number of plugins I don't see where the plugin functions set any error flags. How would I do this?

What people seem to do now is just push thier own status values onto the stack, but they are undocumented. Since people rely on a sane stack for their installs to run correctly, this could break installs.

If anyone could set me straight on this I would greatly appreciate it.

Otherwise I'll stay looking like Igor ->
banaman8d is offline   Reply With Quote
Old 27th May 2003, 15:10   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Welcome to the forum.

Plug-ins can't set the error flag yet. You have to push it on the stack. Since the NSIS stack doesn't really use the stack but allocates memory using GlobalAlloc there shouldn't be any problem of the stack "running out".

BTW, why don't you use ReadIniStr and WriteIniStr instead of writing a plug-in?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th May 2003, 17:20   #3
banaman8d
Junior Member
 
Join Date: May 2003
Posts: 19
Thanks Kichik,

I am using the (Write|Read)Ini* functions to read and write values from the ini files. I am using the plugin for utility functions like interpolating NSIS variables into ini strings after they are read.

so,
{INSTDIR}\myfile
becomes:
C:\Program Files\MyApp\myfile

This simple task could be done by scripting, but I wanted to keep the functions together logically. Also, the scripts become cumbersome fast.

The only thing I can't figure out is how to access values like
$PROGRAMFILES from the plugin. The defines in the ExDLL example include INSTDIR and friends, but not others. Is there a way to do this?
banaman8d is offline   Reply With Quote
Old 27th May 2003, 17:48   #4
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
You can write the folders to a temporary location or detect 'em yourself (just a simple registry key).
Joost Verburg is offline   Reply With Quote
Old 27th May 2003, 22:00   #5
Sunjammer
Major Dude
 
Join Date: Jun 2002
Location: Swindon, UK
Posts: 559
Why not just have a plugin function which you call giving it the values (such as $PROGRAMFILES) from the script, a kind of initialisation function so that the plugin can do its work?
Sunjammer is offline   Reply With Quote
Old 28th May 2003, 13:55   #6
banaman8d
Junior Member
 
Join Date: May 2003
Posts: 19
Thanks for the suggestion SJ,

I decided to do just that. This is the general idea of what I am doing:

; Function to interpolate 'special' values into strings.
; input: $R0
; output: $R0
; error: none set
; This will probably change so that it uses the stack.
Function Interpolate
Push $R1

; Interpolate Program Files location into string
nsmys::SearchAndReplace $R0 "{PGMFILES}" "$PROGRAMFILES"
Pop $R1 ; Get value from SearchAndReplace
StrCmp $R1 "error" +2 0
StrCpy $R0 $R1 ; replace old string with interp'ed

; Interpolate Desktop values
nsmys::SearchAndReplace $R0 "{DESKTOP}" "$DESKTOP"
Pop $R1
StrCmp $R1 "error" +2 0
StrCpy $R0 $R1

.
. ; Do other interpolations
.

Pop $R1
FunctionEnd
banaman8d 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