Hey Guys look at this code
if (Drive.IsReady)= false then
filesys.GetFile("MergeSessionIncomplete.exe").Delete True
filesys.copyfile "DynamicMergeDriveNotReady", "DynamicMergeDriveNotReady.txt", True
Exit
else
Set filetxt = filesys.CreateTextFile("CDDriveReady.log", True)
End If
When I run the exe file it generates an Invalid Exit because the code is inside the VBStart and VBEnd tags - but when I create an object using set WShell = CreateObject("Scripting.FileSystemObject") it ignores it because MSched does not use wscript.quit. Any ideas???
VBScript Quit versus Exit
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You really want to put the code into a VBScript function. Then you can call it from outside the VBSTART/VBEND block and act accordingly. I might not have followed what your code is meant to do entirely but the general idea would be something like this:
VBSTART
Function IsReady
'whatever
if (Drive.IsReady)= false then
filesys.GetFile("MergeSessionIncomplete.exe").Delete True
filesys.copyfile "DynamicMergeDriveNotReady", "DynamicMergeDriveNotReady.txt", True
IsReady = false
else
Set filetxt = filesys.CreateTextFile("CDDriveReady.log", True)
IsReady = true
End if
End Function
VBEND
VBEvaL>IsReady,done
If>done=TRUE
//do other stuff
//call other functions here
Endif
//terminate
VBSTART
Function IsReady
'whatever
if (Drive.IsReady)= false then
filesys.GetFile("MergeSessionIncomplete.exe").Delete True
filesys.copyfile "DynamicMergeDriveNotReady", "DynamicMergeDriveNotReady.txt", True
IsReady = false
else
Set filetxt = filesys.CreateTextFile("CDDriveReady.log", True)
IsReady = true
End if
End Function
VBEND
VBEvaL>IsReady,done
If>done=TRUE
//do other stuff
//call other functions here
Endif
//terminate
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 58
- Joined: Thu Oct 16, 2003 12:53 am
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Surely instead of Exit you just need more organised logic .... 
Can't you if/then/else/endif around what should/shouldn't happen according to certain conditions?

Can't you if/then/else/endif around what should/shouldn't happen according to certain conditions?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 58
- Joined: Thu Oct 16, 2003 12:53 am
mtettmar you are correct but I guess Im still stuck with my previous dilema:
As I understand it VBScript does not use any goto or Label options. I atempted to use MSched label options inside the script but VBScript throws and error. What Im bassically trying to do is terminate the script if the Drive tray is open. If I dont, the logic below it creates a folder, this is what Im trying to avoid.
As I understand it VBScript does not use any goto or Label options. I atempted to use MSched label options inside the script but VBScript throws and error. What Im bassically trying to do is terminate the script if the Drive tray is open. If I dont, the logic below it creates a folder, this is what Im trying to avoid.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Ok, well I must be missing something here because surely you'd just use the following construction:
If drivetray NOT open
.. create the folder
.. and do whatever you need to do
Else
.. clean up code if required
EndIf
Split the code up into manageable subroutines and functions if it helps but I really can't see why you can't just use a simple bit of boolean logic to do everything if the drivetray is not open but do nothing if it is.
E.g. why not put all the code you already have into a subroutine called Main:
Sub Main
.. all the code that you want to do if the drive tray is not open
End Sub
Maybe also have one that has the code you want to do if the drive tray IS open:
Sub TrayOpen
.. stuff here
End Sub
Leave any objects and variables that they both need to use declared above them as globals.
And then just do the following:
If drive tray is open
TrayOpen
Else
Main
Endif
And as suggested in my last post, if you are using MacroScript code too then why not either put the VBScript code in a function that returns true if the tray was closed and the operation completed, false if not. That way you can determine after running the VBScript code whether you should exit the script or not. Or just make a VBScript function that returns whether or not the tray is open. E.g.
VBSTART
Function IsTrayOpen
.. Result = true or false depending
End Function
Sub DoStuff
... do what you need if the tray is closed
End Sub
VBEND
VBEval>IsTrayOpen,res
If>res=TRUE
VBRun>DoStuf
.. any other code here
.. bla bla
Endif
//END OF SCRIPT
If you are no further forward it may help if we can see your actual code.
If drivetray NOT open
.. create the folder
.. and do whatever you need to do
Else
.. clean up code if required
EndIf
Split the code up into manageable subroutines and functions if it helps but I really can't see why you can't just use a simple bit of boolean logic to do everything if the drivetray is not open but do nothing if it is.
E.g. why not put all the code you already have into a subroutine called Main:
Sub Main
.. all the code that you want to do if the drive tray is not open
End Sub
Maybe also have one that has the code you want to do if the drive tray IS open:
Sub TrayOpen
.. stuff here
End Sub
Leave any objects and variables that they both need to use declared above them as globals.
And then just do the following:
If drive tray is open
TrayOpen
Else
Main
Endif
And as suggested in my last post, if you are using MacroScript code too then why not either put the VBScript code in a function that returns true if the tray was closed and the operation completed, false if not. That way you can determine after running the VBScript code whether you should exit the script or not. Or just make a VBScript function that returns whether or not the tray is open. E.g.
VBSTART
Function IsTrayOpen
.. Result = true or false depending
End Function
Sub DoStuff
... do what you need if the tray is closed
End Sub
VBEND
VBEval>IsTrayOpen,res
If>res=TRUE
VBRun>DoStuf
.. any other code here
.. bla bla
Endif
//END OF SCRIPT
If you are no further forward it may help if we can see your actual code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?