- NSIS Discussion
- Usage of IfError
Archive: Usage of IfError
vkumara
4th January 2002 05:32 UTC
Usage of IfError
Hello All,
Could anybody let me know the usage of IfErrors with an
example...?
My situation is I've to process for 0 & non-Zero return values
of a function in the .NSI Script. I'd like to use this IfError
command in the .nsi script.
How the same cud b used ?
Thanks In Advance for help.
Regards
Venky
Smile2Me
4th January 2002 11:15 UTC
Venky,
eg, when trying to read a file to the end:
loop:
FileRead...
IfErrors -> Exit
Goto loop
Exit:
What is it you want to do exactly???
Good luck, greetz, Hendri.
vkumara
8th January 2002 11:49 UTC
Henri,
Thanx for your response.
I'm executing "myfile.exe" thru Exec Call with some parameters.
After excuting this I need to compare the Return value of the
function of myfile.exe
The function which generates myfile.exe does return 1 if the function succeeds.
This Return Value of 1 should be checked with IfErrors statement
How can I achieve this?
Thanks In Advance for your help.
Regards
Venky
Smile2Me
8th January 2002 15:39 UTC
Hi Venky,
The function which generates myfile.exe does return 1 if the function succeeds.
Is StrCmp or IntCmp what you're looking for???
I use some exe to check a RegCode, maybe this will give you some hint how to do it (because I do not understand what you are doing exactly: a function generates an exe???). See
http://forums.winamp.com/showthread....threadid=70530 for RegCode.
Tell me if this solved the problem, good luck,
greetz, Hendri.
Schultz
8th January 2002 16:27 UTC
Are you trying to do something like this..
ClearErrors ;Make sure there isn't any previous errors.
ExecWait "C:\PathToMy\Program.exe" $0
IntCmp $0 "1" "" goto
;Does something if $0 = 1
goto:
;Comes here if something != 1 you can do other checkcs if you wish
You can also do the Iferrors call to see if an error was defined.. Because in the docs the $0 variable is undefined if you have it and an error occurs.
rainwater
8th January 2002 17:40 UTC
The IfErrors flag will be set if the exe returns a non-zero value. Zero means that the exe returned sucessfully. You need to use execwait to get the value.
Try:
ExecWait '"$INSTIDIR\myfile.exe"'
IFErrors 0 NoError
;;; Do something here when you have an error
MessageBox MB_OK "ERRORRRRRRRRRRRRRRRRRRR"
Goto EndIt
NoError:
MessageBox MB_OK "GRRRRRRRRRRRRRRRRRRREAT"
EndIt:
;; we're done
vkumara
9th January 2002 10:24 UTC
Hello All,
Thankx for your replies to the query I've posted.
Henri..sorry I did not elaborate my query.
This is I intended to do.
Execwait "myfile.exe" has been passed with some parameters.
I need to check the return values using IfErros Stmt.
I need to process some command only if the return value is 1.
I could do this by the follg. way
Execwait "myfile.exe" $0
IntCmp $0 "1" "" MyLabel
MessageBox MB_OK "Value is 1";
MyLabel:
SectionEnd.
vkumara
9th January 2002 13:00 UTC
Hello All,
Thankx for your replies to the query I've posted.
Henri..sorry I did not elaborate my query.
This is I intended to do.
Execwait "myfile.exe" has been passed with some parameters.
I need to check the return values using IfErros Stmt.
I need to process some command only if the return value is 1.
I could do this by the follg. way
Execwait "myfile.exe" $0
IntCmp $0 "1" "" MyLabel
MessageBox MB_OK "Value is 1";
MyLabel:
SectionEnd.
Thanks & Regards
Venky
petersa
9th January 2002 13:55 UTC
Hi Venky,
To get the return value, or 'error level' of a program, simply do:
ExecWait 'MyProgram.exe' $0
$0 will contain the return value.
Hope this helps!
Alex
petersa
9th January 2002 13:57 UTC
What the Heck?
The forum system has choked on my response, so:
- ExecWait 'MyProgram.exe' $0
That's the code. $0 will contain the return value of your program.
Here's the code for my above message. Who knows why it repeats. Incorrectly.
petersa
9th January 2002 14:04 UTC
vBulletin is Stuffed.
The forum system has yet again misinterpreted my response. If you type
ExecWait 'MyProg.exe' $0
then $0 will contain the return value of your program.