25 Apr
Posted by Stu as Coding, Tips (Little Bits Of Awesomeness)
When manipulating data files in code, you can check after each operation for errors.
Here’s an example:
1 2 3 4 5 6 7 8 9 10 11 | clear(peo:Record) peo:EnteredDate = _:FirstDayOfYear set(peo:keyEntered,peo:keyEntered) loop next(People) if ((errorcode() = 33) or (peo:EnteredDate > today()) break elsif errorcode() _AddError(_:ProcedureName,'routinename',subject,body) . . |
So what’s going on?
When you’re running an error check, there are certain errors that should be handled with special care, contextually based on the preceeding command.
After a next() I know that (errorcode() = 33) means “forgeddabout it, this baby is all done”.
The other errorcode()’s to watch out for are
Those three are the most frequent errors I check for.
Let’s lay them out one more time.
30 .. get() on Queue, record doesn’t exist.
33 .. next() on File, record doesn’t exist.
35 .. get() on File, record doesn’t exist.
Another quick tip from the simple minds at PimpMyClarion. Simple.
2 Responses
Brahn
April 25th, 2007 at 3:19 pm
1Also worth considering are the equates found in \LibSrc\Errors.clw
NoEntryErr EQUATE(30) ! ‘Entry Not Found’
BadRecErr EQUATE(33) ! ‘Record Not Available’
NoRecErr EQUATE(35) ! ‘Record Not Found’
etc…
Not so excited about some of the names given myself (BadRecErr = ‘Record Not Available’?) but some are more meaningful than the numbers…
Stu
April 25th, 2007 at 4:44 pm
2Nice, I guess you could just equate your own for extra-clear code :).
RSS feed for comments on this post · TrackBack URI
Leave a reply
Recent Posts
Recent Comments
RSS Feed
Email Subscription
Must Read!
Busy Posts (30 Days)
Active Folk (30 Days)