forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with basic programming (cause i suck)

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
flypaper
Contributor
Contributor


Joined: 19 Oct 2001
Posts: 104

PostPosted: Mon Apr 04, 2005 6:43 pm    Post subject: Help with basic programming (cause i suck) Reply with quote

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
View user's profile Send private message
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Mon Apr 04, 2005 9:59 pm    Post subject: Reply with quote

Have you looked at "Option errortrap", "error" and "@error"?

Hooligan

_________________
Hooligan

Why be normal?
Back to top
View user's profile Send private message
flypaper
Contributor
Contributor


Joined: 19 Oct 2001
Posts: 104

PostPosted: Tue Apr 05, 2005 12:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Tue Apr 05, 2005 12:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
flypaper
Contributor
Contributor


Joined: 19 Oct 2001
Posts: 104

PostPosted: Tue Apr 05, 2005 12:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Tue Apr 05, 2005 2:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Wed Apr 06, 2005 2:58 am    Post subject: Reply with quote

"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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group