PDA

View Full Version : Simple VB Script Question?


Scotty
02-01-2006, 02:47 PM
I am trying to pass an error when 0 files are copied through the following code, in the Step tab of the script editor.

Function vbld_StepDone()
if InStr(Left(vbld_AllMacros()("LASTSTEP_OUTPUT").Value,16), "0 file(s) copied") = 0 Then
Err.Raise 1, Step.Name, "0 file(s) copied"
end if

When I rebuild VP 5.7 says :
'Error firing vbld_StepDone event: Error in Step script code at Line 3 column 3 (0 file(s) copied)

What am I doing wrong?

kinook
02-01-2006, 03:22 PM
The sample I provided in http://www.kinook.com/Forum/showthread.php?threadid=1507 provides a simpler and more robust way to determine that (using the COPYFILES_COPY_COUNT macro), but in the code you posted, I think you want to look at the end of the output (Right instead of Left) and raise the error if the string is found (<> 0 instead of = 0).

Scotty
02-01-2006, 03:27 PM
Thank you for the format help, currently I am using 5.7, so do not have access to the robustness of version 6. I have replaced the Err.Raise 1, Step.Name, "0 file(s) copied" with a MsgBox, and that runs fine. Is there some VB system file that I do not have loaded?

kinook
02-01-2006, 03:43 PM
The COPYFILES_COPY_COUNT temp macro is also available in v5.7. At any rate, it sounds like it's doing what's intended -- failing the build if the count is 0.

Scotty
02-01-2006, 03:48 PM
The code works fine, it is the trying to get the Failure Step; which is to email a user, which is not getting called. There apparently is something funky in the script line Err.Raise 1, Step.Name, "0 file(s) copied". The rebuild states 'Error firing vbld_StepDone event'. Any ideas?

kinook
02-01-2006, 03:54 PM
That's the correct error message, since you're raising an error from the vbld_StepDone event. Do you perhaps still have Ignore failure checked?

Scotty
02-01-2006, 03:57 PM
You are the wizard!
Thank you very much for your patience and time.