Zipper Bug

Started by MrLeadFoot, May 13, 2016, 08:42:44 PM

Previous topic - Next topic

USMuscle

Quote from: td on May 19, 2016, 03:11:27 PMIf you call the zZipFiles function from within a UDF with error handling,  error handling with not be in effect for the rest of your script.

Code (winbatch) Select
#DefineFunction ZipFile(Options, ZipFile, FileToZip)
   IntControl(73,1,0,0,0)
   zZipFiles(Options,ZipFile, FileToZip,"")
   return 0 ; Success
:WBErrorHandler
   return LastError() ; Failed
#EndFunction


If we were to use the above function, to determine failure would we place the structure above the call to the ZipFile function described above, and simply follow the statement that calls the function with something below the calling statement? Such as:

Code (winbatch) Select
#DefineFunction ZipFile(Options, ZipFile, FileToZip)
   IntControl(73,1,0,0,0)
   zZipFiles(Options,ZipFile, FileToZip,"")
   return 0 ; Success
:WBErrorHandler
   return LastError() ; Failed
#EndFunction

ZipFile("g", ZipfFile, FileToZip)

If ZipFile<> 0 Then Message ("Failed","Houston, we have a problem!")


Thank you

td

Code (winbatch) Select
nRet = ZipFile("g", ZipfFile, FileToZip)
If nRet Then Message ("Failed","Houston, we have a problem!")

;; Or

If ZipFile("g", ZipfFile, FileToZip)  Then Message ("Failed","Houston, we have a problem!")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

USMuscle

Thank you, but just so I know, what does nRet represent? Is it some kind of variable, or built in function, or something that doesn't need to be defined? I don't see it referenced in the code structure we're referencing anywhere.

Thanks again.

EDIT: Whoops, never mind, I see it defined in the statement that calls the function. Sorry about that.  :P

I also notice that in either statement, there is nothing after the If before the Then. Was that a typo? I thought the If needs to evaluate something with an operator, such as:

If nRet == xx (or<>, or another operator)

Am I wrong here?

td

It is not a typo.  A function call is an expression and that expression's evaluation is the function's return value.   Many and more likely almost all modern procedural and object-oriented programming and scripting languages work this way.  The 'if' flow of control statement simply requires that the expression following it evaluate to an entity that is either zero or a non-zero integer.  All relational operators also evaluate to either zero or a non-zero integer.   This concept is again common to many programming languages. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Code (winbatch) Select
#DefineFunction FooBarTrue()
   return 2 > 1
#EndFunction

if FooBarTrue() then Pause('FooBarTrue', 'Is an expression')

Pause('Relational Operators', 'Evaluate to ':FooBarTrue():' when true')

#DefineFunction FooBarTrue2()
   return 12356789
#EndFunction

if FooBarTrue2() then Pause('FooBarTrue2', 'Is also a true expression.')

exit

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

USMuscle

Thank you for providing the example elaborating what you were saying. I THINK I am starting to understand.

BTW, I guess I should have asked this first, but do you think the error trapping we've been talking about recently here work to address the weird Zipper 8004 error, being that it is an "unknown error"? If my thinking is correct, as you said, the script itself really doesn't "Crash" per se, since WB is displaying the error rather than the system displaying the error, so as long as I trap for an error (any error, not specifically an 8004 error), I should be able to do something so the script doesn't halt, correct?

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade