Here's a tip. Hope you find it interesting:
In a lot of langauges, you can add some code that's to be executed no matter what happens in the rest of the routine. For example, if you had coded a freeze:
ui_freeze(.t.)
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
ui_freeze(.f.)
And something happened in between the freeze and the unfreeze, your user'd be stuck. So you'd write:
ui_freeze(.t.)
try
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
except
handleError("Houston, we have a problem.")
finally
ui_freeze(.f.)
end try
The A5 code that I've seen handles it this way:
ui_freeze(.t.)
On Error Goto ErrorTrap
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
ui_freeze(.f.)
end
ErrorTrap:
ui_freeze(.f.)
handleError("Houston, we have a problem.")
But this is cumbersome, especially if your clean-up code is extensive, not just a line or two.
However, I discovered you can accomplish the same thing by taking advantage of Xbasic's...em...laxity. :-)
ui_freeze(.t.)
On Error Goto ErrorTrap
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
if .f. then 'this code only executes if there's an error
ErrorTrap:
handleError("Houston, we have a problem.")
end if
ui_freeze(.f.)
end
In some Basics, leaping into a block wouldn't be allowed (the interpeter would be confused by the END IF because it hadn't encountered an IF in the first place) but this doesn't seem to bother Xbasic!
In a lot of langauges, you can add some code that's to be executed no matter what happens in the rest of the routine. For example, if you had coded a freeze:
ui_freeze(.t.)
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
ui_freeze(.f.)
And something happened in between the freeze and the unfreeze, your user'd be stuck. So you'd write:
ui_freeze(.t.)
try
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
except
handleError("Houston, we have a problem.")
finally
ui_freeze(.f.)
end try
The A5 code that I've seen handles it this way:
ui_freeze(.t.)
On Error Goto ErrorTrap
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
ui_freeze(.f.)
end
ErrorTrap:
ui_freeze(.f.)
handleError("Houston, we have a problem.")
But this is cumbersome, especially if your clean-up code is extensive, not just a line or two.
However, I discovered you can accomplish the same thing by taking advantage of Xbasic's...em...laxity. :-)
ui_freeze(.t.)
On Error Goto ErrorTrap
parentform.close()
vformname.Index_Set(vindexnamevalue)
vformname.show()
if .f. then 'this code only executes if there's an error
ErrorTrap:
handleError("Houston, we have a problem.")
end if
ui_freeze(.f.)
end
In some Basics, leaping into a block wouldn't be allowed (the interpeter would be confused by the END IF because it hadn't encountered an IF in the first place) but this doesn't seem to bother Xbasic!
Comment