Sign in to follow this  
Followers 0
KXM

Help getting an error message

5 posts in this topic

#1 ·  Posted (edited)

First, I just want to say, I did search. However searching with the word 'error' is not easy. :idiot:

Here's my issue, I can't program. So I have no idea what I'm doing.

I'm trying to call one function if a given program load correctly, and another if it fails.

Here is my code:

AutoItSetOption("RunErrorsFatal", 0)
AutoItSetOption("WinTitleMatchMode", 1)

Dim $BTV = "C:\Program Files\SnapStream Media\Beyond TV 3\BTVD3DShell.exe /displaymode:fs"
Dim $Meedio = "C:\Program Files\Meedio\Meedio Essentials\Meedio.exe -no-splash -single-instance"

Main()

Func Main()
WinClose("Meedio Essentials", "")
BTV()
EndFunc

Func BTV()
runwait($BTV) 
If $BTV = 0 Then
Call ("ErrorBTV")
Else
Call ("Meedio")
EndIf
EndFunc

Func Meedio()
run($Meedio) 
MsgBox(4, "worked", "worked")
EndFunc

Func ErrorBTV()
MsgBox(4096, "Could Not Load BTV", "Loading BTV Failed, Please contack KXM on Meedio.com")
Exit
EndFunc

Any clues as to what I'm doing wrong?

TIA,

KXM

Edited by KXM

Share this post


Link to post
Share on other sites

I cleaned up your script using Tidy® and added If @error.

You know why your script didn't work as expected?

Because you didn't read help file very well. Specifically: the remarks part of the Run/RunWait function.

By default the script will terminate with a fatal error if the Run function fails. To set @error to 1 as an indication of failure, see AutoItSetOption.

AutoItSetOption("RunErrorsFatal", 0)
AutoItSetOption("WinTitleMatchMode", 1)

Dim $BTV = "C:\Program Files\SnapStream Media\Beyond TV 3\BTVD3DShell.exe /displaymode:fs"
Dim $Meedio = "C:\Program Files\Meedio\Meedio Essentials\Meedio.exe -no-splash -single-instance"

Main()

Func Main()
   WinClose("Meedio Essentials", "")
   BTV()
EndFunc  ;==>Main

Func BTV()
   RunWait($BTV)
   If @error = 1 Then
      Call("ErrorBTV")
   Else
      Call("Meedio")
   EndIf
EndFunc  ;==>BTV

Func Meedio()
   Run($Meedio)
   MsgBox(4, "worked", "worked")
EndFunc  ;==>Meedio

Func ErrorBTV()
   MsgBox(4096, "Could Not Load BTV", "Loading BTV Failed, Please contack KXM on Meedio.com")
   Exit
EndFunc  ;==>ErrorBTV

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

First THANKS for helping so quickly! Figured no one would reply until tomorrow at best.

I should have been more clear in my request, I had tried what you suggested first. However, when I did that the script does not wait for BTV to end, before calling 'Meedio', per 'RunWait'. Maybe it's a matter of another function being need, but I'm not sure how/why.

Also, what is ';==>Function Name' Is this part of Tidy®?

THANKS again for your help!

Edited by KXM

Share this post


Link to post
Share on other sites

I have no idea why the above script didn't work.

Because it should. Actually the following script works exactly like the above script.

Yes. Tidy® is a script that cleans up AutoIt3 scripts.

Available here.

AutoItSetOption("RunErrorsFatal", 0)
AutoItSetOption("WinTitleMatchMode", 1)

Dim $BTV = '"C:\Program Files\SnapStream Media\Beyond TV 3\BTVD3DShell.exe" /displaymode:fs'
Dim $Meedio = '"C:\Program Files\Meedio\Meedio Essentials\Meedio.exe" -no-splash -single-instance'

Main()

Func Main()
  WinClose("Meedio Essentials", "")
  BTV()
EndFunc ;==>Main

Func BTV()
  $PID_BTV = Run($BTV)
  If @error = 1 Then
     Call("ErrorBTV")
  Else
     ProcessWaitClose($PID_BTV)
     Call("Meedio")
  EndIf
EndFunc ;==>BTV

Func Meedio()
  Run($Meedio)
  MsgBox(4, "worked", "worked")
EndFunc ;==>Meedio

Func ErrorBTV()
  MsgBox(4096, "Could Not Load BTV", "Loading BTV Failed, Please contack KXM on Meedio.com")
  Exit
EndFunc ;==>ErrorBTV

Share this post


Link to post
Share on other sites

I'm sorry, it seems to be a problem with the program it's loading. The program being loaded seems to return an error if it's background program is not running, even though it will still load fine.

All I need to do is check if the backgroung program is running, if not load it, than load the other. Easy enough.

Sorry for being such a newbee. THNX again.

Happy Holidays.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0