| View previous topic :: View next topic |
| Author |
Message |
flypaper Contributor


Joined: 19 Oct 2001 Posts: 104
|
Posted: Mon Apr 04, 2005 6:43 pm Post subject: Help with basic programming (cause i suck) |
|
|
okay, I have an errorcheck subroutine. If an error is found, I want the program to display an error and return to evloop. This was the best I could come up with to do that, but it seems cumbersome.
Is there a better way than this?
| Code: | :Stuff
gosub ErrorCheck
if @not(@null(%%stop))
%%stop =
goto evloop
end
:ErrorCheck
IF @NOT(@ZERO(@RETCODE()))
WARN Error %%error. Return code was @RETCODE()
%%stop = stop
END
EXIT |
Thanks again guys! |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Mon Apr 04, 2005 9:59 pm Post subject: |
|
|
Have you looked at "Option errortrap", "error" and "@error"?
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
flypaper Contributor


Joined: 19 Oct 2001 Posts: 104
|
Posted: Tue Apr 05, 2005 12:21 pm Post subject: |
|
|
The errortrap doesn't seem to work, as there isn't an actual error. I'm just checking the return code from a CMD box that I launch.
Unless I'm doing that wrong... |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Tue Apr 05, 2005 12:32 pm Post subject: |
|
|
Ah... I should have caught that... You didn't show the line where you call the cmd window... Did you add the wait parameter to the cmd line? If not, the script may resume before the return code has a chance to be returned.
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
flypaper Contributor


Joined: 19 Oct 2001 Posts: 104
|
Posted: Tue Apr 05, 2005 12:39 pm Post subject: |
|
|
| Sorry, I didn't want to post the whole code, as its kinda long. But yes, I have a WAIT in there. The code I posted does work, but it seems kinda goofy. I mainly wanted to see if you pros had any better suggestions... |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Tue Apr 05, 2005 2:33 pm Post subject: |
|
|
You might try assigning the errorcode to a variable rather than trying to extract it twice... Like this:
| Code: |
:Stuff
runh dir c:\xyz\,wait
%%errorcode = @retcode()
gosub ErrorCheck
if @not(@null(%%stop))
%%stop =
goto evloop
end
:ErrorCheck
IF @NOT(@ZERO(%%errorcode))
WARN Error %%error. Return code was %%errorcode
%%stop = stop
END
EXIT
|
Let me know if that helps....
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Apr 06, 2005 2:58 am Post subject: |
|
|
"if @not(@null(%%stop))" should also be equal to "if %%stop"
And
"IF @NOT(@ZERO(%%errorcode))" should work as "if %%errorcode"
Both should only pass if the variables are greater than 0 or blank. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|