![]() Chapter Contents |
![]() Previous |
![]() Next |
| Image Data Model: _onError |
| Syntax | |
| Details | |
| Example |
Syntax |
| CALL SEND (object-id, '_onError'<message><abort>); |
| Argument | Type | Description |
|---|---|---|
| message |
C | the string MESSAGE or NOMESSAGE to indicate whether a message should be written when an error occurs |
| abort |
C | the string ABORT or NOABORT to indicate whether the program should abort when an error occurs |
| Details |
If you specify either message or abort but
not both, the omitted action defaults to its current value, which is the value
last specified. For example, if you specify
'MESSAGE NOABORT
'
and later you specify
'NOMESSAGE
', the NOABORT remains
in effect.
| Example |
This example shows how to override the default behavior so that the SCL program does not abort. When you do this, make sure to check SYSRC to see if each method completed successfully.
/* Create the nondisplay object */
image_class =loadclass('sashelp.fsp.imgdat.
class');
imgdat_id=instance(image_class);
filename='/usr/local/color/misc/candy.jif';
/* Set _onError state to not abort so
we can */
/* do our own error recovery if
_read fails. */
call send(imgdat_id, '_getOnErrorOptions',
prevoptions);
call send(imgdat_id, '_onError', 'NOMESSAGE
NOABORT');
read:
call send(imgdat_id, '_read', filename);
sysrc();
put filename= ;
if (rc ne 0) then goto error;
/* Set _onError back to the original
state so we don't have to */
/* check return codes every time since
the code below shouldn't */
/* fail and we don't know how to recover
even if it does (only */
/* cases are out-of-memory
and file I/O errors).
*/
call send(imgdat_id, '_onError',
prevoptions);
call send(imgdat_id, '_quantize', 100);
call send(imgdat_id, '_rotate', 90);
call send(imgdat_id, '_negate');
call send(imgdat_id, '_scale', 100, 100);
call send(imgdat_id, '_write',
'output.gif', 'format=gif');
return;
error:
/* Error handling may reprompt user
for new image filename to read */
put 'Replacing JIF in filename with TIFF -
and retrying the _read';
filename='/usr/local/color/misc/candy.tif';
/* Now continue with the _read
method again. */
goto read;
return;
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.