Author Topic: Zipper Bug  (Read 16808 times)

USMuscle

  • Newbie
  • *
  • Posts: 23
Re: Zipper Bug
« Reply #35 on: December 15, 2016, 01:28:12 pm »
If 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
#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
#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

  • Tech Support
  • *****
  • Posts: 3460
    • WinBatch
Re: Zipper Bug
« Reply #36 on: December 15, 2016, 01:36:47 pm »
Code: Winbatch
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

  • Newbie
  • *
  • Posts: 23
Re: Zipper Bug
« Reply #37 on: December 15, 2016, 06:36:09 pm »
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

  • Tech Support
  • *****
  • Posts: 3460
    • WinBatch
Re: Zipper Bug
« Reply #38 on: December 15, 2016, 10:30:07 pm »
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

  • Tech Support
  • *****
  • Posts: 3460
    • WinBatch
Re: Zipper Bug
« Reply #39 on: December 16, 2016, 07:28:17 am »
Code: Winbatch
#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

  • Newbie
  • *
  • Posts: 23
Re: Zipper Bug
« Reply #40 on: December 16, 2016, 02:52:01 pm »
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

  • Tech Support
  • *****
  • Posts: 3460
    • WinBatch
Re: Zipper Bug
« Reply #41 on: December 16, 2016, 02:55:02 pm »
Correct.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade