Discussion:
Using TRY/CATCH
(too old to reply)
Mark
2008-10-22 16:23:39 UTC
Permalink
I would like to use TRY/CATCH to adjust an app for different versions, i.e., an older version may have a slightly differnt table structure and some fields will not be present even tho I use the same basic form for both versions.

I am concerned that using try/catch to avoid an error I know will happen with some versions may still create some instability in the app, and if enough try/catches fail, I could run into errors in Windows. Basically, does a try/catch always avoid any memory or other problems when an error is encountered?

Anyone know if this liberal use of try catches could pose problems?

Thanks for any ideas on this,
Mark
Greg Hill
2008-10-22 17:20:29 UTC
Permalink
Post by Mark
I would like to use TRY/CATCH to adjust an app for different versions,
i.e., an older version may have a slightly differnt table structure and
some fields will not be present even tho I use the same basic form for both
versions.
I am concerned that using try/catch to avoid an error I know will happen
with some versions may still create some instability in the app, and if
enough try/catches fail, I could run into errors in Windows. Basically,
does a try/catch always avoid any memory or other problems when an error
is encountered?
Anyone know if this liberal use of try catches could pose problems?
You can code it so that it does exactly what you want.

try
xyz
catch (exception e)
if e.code = 108
do something
endif
// if the error code is not 108, everything is ignored.
// you can reverse this logic and stop on anything but 108
endTry
Mark
2008-10-23 22:05:25 UTC
Permalink
Greg,

Thanks. My concern is whether try/catch places a demand on memory or on windows when it runs into a problem. I typically only use it to catch unusual errros. I'm considering using it to always catch a discrepancy between an older and newer version, which could put more stress on the app and cause problems later in the same session.

Thanks again for you input,
Mark
Post by Greg Hill
Post by Mark
I would like to use TRY/CATCH to adjust an app for different versions,
i.e., an older version may have a slightly differnt table structure and
some fields will not be present even tho I use the same basic form for both
versions.
I am concerned that using try/catch to avoid an error I know will happen
with some versions may still create some instability in the app, and if
enough try/catches fail, I could run into errors in Windows. Basically,
does a try/catch always avoid any memory or other problems when an error
is encountered?
Anyone know if this liberal use of try catches could pose problems?
You can code it so that it does exactly what you want.
try
xyz
catch (exception e)
if e.code = 108
do something
endif
// if the error code is not 108, everything is ignored.
// you can reverse this logic and stop on anything but 108
endTry
Lysander
2008-10-23 08:28:26 UTC
Permalink
Post by Mark
I would like to use TRY/CATCH to adjust an app for different versions, i.e., an older version may have a slightly differnt table structure and some fields will not be present even tho I use the same basic form for both versions.
Try/Catch would work for that, but it's the wrong way and will lead to
other problems when spanned over a complete application.

I had the need for a similar construction because I am mainly using
7.01, which does NOT work with more than 512MByte RAM. So I had at least
to use 7.5 for those machines with 1 GByte or more RAM.

But all later versions than 7.01 not only removed bugs but also put some
new in, so I did not want to use 7.5++ in places where it was not
necessary, and had to fork program logic for different versions.

I made good experience at that time with using a compiler directive (#)
and evaluating that in critical places.

The OLH should be able to teach you the most recent usage of the
compiler directives - I don't know if something's changed in the latest
years.

ciao,
André
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are 10 types of programmers:
those who understand binary arithmetics and those who don't.
Mark
2008-10-23 22:08:25 UTC
Permalink
Andre,

I use Plus 2.21 now, tho am updating to the latest version soon.

For some reason I just have a suspicion that frequent catches could be a problem for windows or for memory. So I don't like my current plan to use it to catch discrepancies between versions. But it does make it much simpler to handle updates.

Will probably rethink this and see what it would take to do it differetly.

Thanks,
Mark
Post by Lysander
Post by Mark
I would like to use TRY/CATCH to adjust an app for different versions, i.e., an older version may have a slightly differnt table structure and some fields will not be present even tho I use the same basic form for both versions.
Try/Catch would work for that, but it's the wrong way and will lead to
other problems when spanned over a complete application.
I had the need for a similar construction because I am mainly using
7.01, which does NOT work with more than 512MByte RAM. So I had at least
to use 7.5 for those machines with 1 GByte or more RAM.
But all later versions than 7.01 not only removed bugs but also put some
new in, so I did not want to use 7.5++ in places where it was not
necessary, and had to fork program logic for different versions.
I made good experience at that time with using a compiler directive (#)
and evaluating that in critical places.
The OLH should be able to teach you the most recent usage of the
compiler directives - I don't know if something's changed in the latest
years.
ciao,
André
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
those who understand binary arithmetics and those who don't.
Geoff Wass [dBVIPS]
2008-10-24 04:00:15 UTC
Permalink
Post by Mark
I would like to use TRY/CATCH to adjust an app for different versions, i.e., an older version may have a slightly differnt table structure and some fields will not be present even tho I use the same basic form for both versions.
I am concerned that using try/catch to avoid an error I know will happen with some versions may still create some instability in the app, and if enough try/catches fail, I could run into errors in Windows. Basically, does a
try/catch always avoid any memory or other problems when an error is encountered?
Post by Mark
Anyone know if this liberal use of try catches could pose problems?
Thanks for any ideas on this,
Mark
Mark,

There is no problem using try/catch over and over. I seem to recall
there was someone who found a certain type of error that was not getting
caught, but I think it is rare. I use them a lot and have had no
problems.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Mark
2008-10-24 13:52:57 UTC
Permalink
Thanks Geoff.

Mark
Post by Mark
Post by Mark
I would like to use TRY/CATCH to adjust an app for different versions, i.e., an older version may have a slightly differnt table structure and some fields will not be present even tho I use the same basic form for both versions.
I am concerned that using try/catch to avoid an error I know will happen with some versions may still create some instability in the app, and if enough try/catches fail, I could run into errors in Windows. Basically, does a
try/catch always avoid any memory or other problems when an error is encountered?
Post by Mark
Anyone know if this liberal use of try catches could pose problems?
Thanks for any ideas on this,
Mark
Mark,
There is no problem using try/catch over and over. I seem to recall
there was someone who found a certain type of error that was not getting
caught, but I think it is rare. I use them a lot and have had no
problems.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada
.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Loading...