Warehouse Release 2.07.3150

10/16/2002

There is now a new release of Warehouse available (2.07.3150).

The fixes and enhancements in this release are:

TRY(expression, error-result) 

If expression evaluates without error, then the result of the TRY function is the expression. If an error or warning is encountered during the evaluation of expression, then error-result is returned. The data type family of error- expression must be the same data type family of expression. 

Examples: 

SETVAR N = TRY(CONVERT(X, "IMAGE I1"), -1) 

Tries to convert X to an IMAGE I1 and returns -1 if there is a conversion error. 

SETVAR N = TRY(NUMERIC(S), & 
TRY(NUMERIC(STR(S, 1, LEN(S)-1)), $NULL)) 

Tries to convert S to a number. If there is a conversion error, then the conversion is attempted once again without using the last character of S. If that also fails, $NULL is returned. 

NOTE: Care must be used when using the TRY function. The following are not equivalent: 

* Way 1 

TRY 
SETVAR A = B 
RECOVER 
SETVAR A = 0 
ENDTRY 

is not the same as: 

* Way 2 
SETVAR A = TRY(B, 0) 

The reason the ways are not equivalent is that before an assignment is done, the value to be assigned is converted to the data type of the recipient variable. This conversion may cause an error, which would be caught by Way 1 but not by Way 2. In way one the equal (=) operator is covered by the TRY, but in Way 2 the equal operator is outside of the TRY. A way to solve this problem is to convert the result to the target type inside of the TRY. For example, if the data type of A was an IMAGE I1, the statement would look like: 

* Way 3 
SETVAR A = TRY(CONVERT(B, "IMAGE I1"), 0) 

This solution works fine for binary integer types such as an IMAGE I1, but can still fail to catch errors for certain data types, such as IMAGE Z types. For example, if both A and B are IMAGE Z6 and you wish to catch a bad value of B, the following will *not* work: 

* Way 4 (Bad) 
SETVAR A = TRY(CONVERT(B, "IMAGE Z6"), 0) 

The reason is that since B is already type IMAGE Z6, no conversion is actually done and bad data in B is not caught. The way to catch a bad B is to perform an operation on B, such as add zero. Example: 

* Way 5 (Good) 
SETVAR A = TRY(B + 0, 0) 

To make certain there is no conversion error for the assignment and that the data is good, you can combine the convert and add zero techniques. Example: 

* Way 6 (Best) 
SETVAR A = TRY(CONVERT(B, "IMAGE Z6") + 0, 0) 

Release 2.07.3150 is available now on all supported platforms.