PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Error trapping  (Read 843 times)

Bruno Biancucci

  • Member
  • **
  • Posts: 9
    • View Profile
    • BrunoBiancucci.com
Error trapping
« on: September 16, 2019, 10:53:27 AM »
I want to trap and report back any error set in PxPlus to a calling program (DOS batch file in this case).  This installation is a Windows Server 2012 with PxPlus 11.50 (base).

PxPlus is initiated in a batch file as follows:

echo off
echo We are in the batch file
echo Before: %errorlevel%
echo After: %errorlevel%

My sample PxPlus program simply generates an error (Divide by zero)
0010 CLEAR
0020 SETERR 0080
0030 PRINT "Hello World..."
0050 LET A=2/0
0060 PRINT "ok..."
0065 WAIT 1
0070 END
0080 PRINT "oops..."
0085 WAIT 1
0090 END

Removing line 20 make no difference for me in this case.  Pxplus program will crash hard and return back to the batch file.  In both cases the %errorlevel% variable is still set to 0.

The end game is to inform the batch file there was a problem with the PxPlus program.  This is for an automated process and we're simply looking for a way to know if the test.pxp program generated an error or ran clean.
TIA, Bruno.
"Do or do not. There is no try." - Yoda

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3734
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Error trapping
« Reply #1 on: September 16, 2019, 01:50:45 PM »
The RELEASE directive will terminate your application and allow you to pass an error code to the OS.