Old 4th January 2002, 05:32   #1
vkumara
Junior Member
 
Join Date: Nov 2001
Posts: 10
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
vkumara is offline   Reply With Quote
Old 4th January 2002, 11:15   #2
Smile2Me
Guest
 
Posts: n/a
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.
  Reply With Quote
Old 8th January 2002, 11:49   #3
vkumara
Junior Member
 
Join Date: Nov 2001
Posts: 10
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
vkumara is offline   Reply With Quote
Old 8th January 2002, 15:39   #4
Smile2Me
Guest
 
Posts: n/a
Hi Venky,

Quote:
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.
  Reply With Quote
Old 8th January 2002, 16:27   #5
Schultz
Member
 
Join Date: Oct 2001
Posts: 71
Are you trying to do something like this..
code:

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.
Schultz is offline   Reply With Quote
Old 8th January 2002, 17:40   #6
rainwater
Senior Member
 
Join Date: Aug 2000
Posts: 397
Send a message via ICQ to rainwater
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
rainwater is offline   Reply With Quote
Old 9th January 2002, 10:24   #7
vkumara
Junior Member
 
Join Date: Nov 2001
Posts: 10
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 is offline   Reply With Quote
Old 9th January 2002, 13:00   #8
vkumara
Junior Member
 
Join Date: Nov 2001
Posts: 10
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
vkumara is offline   Reply With Quote
Old 9th January 2002, 13:55   #9
petersa
Senior Member
 
petersa's Avatar
 
Join Date: Apr 2001
Location: Melbourne, Australia
Posts: 207
Hi Venky,

To get the return value, or 'error level' of a program, simply do:
code:
ExecWait 'MyProgram.exe' $0
$0 will contain the return value.

Hope this helps!
Alex
petersa is offline   Reply With Quote
Old 9th January 2002, 13:57   #10
petersa
Senior Member
 
petersa's Avatar
 
Join Date: Apr 2001
Location: Melbourne, Australia
Posts: 207
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.
Attached Files
File Type: txt the_code.txt (180 Bytes, 409 views)
petersa is offline   Reply With Quote
Old 9th January 2002, 14:04   #11
petersa
Senior Member
 
petersa's Avatar
 
Join Date: Apr 2001
Location: Melbourne, Australia
Posts: 207
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.
petersa 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