Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New VFP TRY..CATCH bug

Status
Not open for further replies.

wgcs

Programmer
Mar 31, 2002
2,056
EC
I just submitted this bug to Microsoft (as per instructions at ) and I thought that everyone may benefit from knowing about this odd behavior:

This is a Visual FoxPro bug about
FoxPro Version: 9.0 No SP
Reproduces: always

Steps to Reproduce:
(1) Open VFP
(2) Create a procedure file "TestOexc.prg" containing the following code:
Code:
TRY
  TRY
    THROW "Expected 1"
  CATCH TO oExc
    MESSAGEBOX('TestOexc Caught '+oExc.Message+'  '+TRANSFORM(oExc.UserValue) )
    cMsg = oExc.message
    DO ErrProc WITH cMsg
  ENDTRY
CATCH TO oExc
  MESSAGEBOX('NOT EXPECTED: TestOexc Outer TRY Caught '+oExc.Message+'  '+TRANSFORM(oExc.UserValue) )
ENDTRY

PROCEDURE ErrProc( cMsg )
PRIVATE oExc
  TRY
    THROW "Expected 2"
  CATCH TO oExc
    MESSAGEBOX('Errproc Caught '+oExc.Message+'  '+TRANSFORM(oExc.UserValue) )
  ENDTRY
ENDPROC

(3) Run the procedure

Observed Behavior:
First, a dialog saying "TestOexc Caught User Thrown Error . Expected 1"
Second, a dialog saying "NOT EXPECTED: TestOexc Outer TRY Caught Alias 'OEXC' is not found."

Expected Behavior:
First, a dialog saying "TestOexc Caught User Thrown Error . Expected 1"
Second, a dialog saying "ErrProc Caught User Thrown Error . Expected 2"


Additional Information:
Even though ErrProc has the statement "PRIVATE oExc", the "TRY..CATCH TO oExc" phrase that should be creating a new, private oExc variable instead seems to be accessing the hidden, original oExc variable.

If the "PRIVATE oExc" statement is removed, it works correctly (though, I expect that then that the private oExc variable that already exists gets changed, when I'd prefer it not be changed.)

If the "PRIVATE oExc" statement is changed to "LOCAL oExc", then it all works correctly. (though, then, I expect that oExc behaves as a Local, and won't be visible in called functions like a Private var would)

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Thanks, Olaf: I wasn't aware of the Product Feedback system!

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top