24 Apr
Posted by Stu as Templates, Tips (Little Bits Of Awesomeness)
The simplest template in my arsenal is the one you’d find most in the code.
I discovered early on it was a good idea to send the (offending) Procedure Name through to the error logging.
_AddError('MyAwesomeProcedure','Stupid Error Subject','Stupid Error Body');
After too long, I decided to do something about always having to string type as a parameter to the error logging function.
But what to do? You’ve probably already seen what took me at least 2 years.
I wrote a little template that places a local var (_:ProcedureName) into every procedure in the app (globally added). This var is populated with the Procedure Name, and now i never have to change that parameter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!========================================= #!= Logging Template #!========================================= #TEMPLATE(SA_Logging,'Stus Templates: Logging, Errors and Otherwise'),FAMILY('ABC'),FAMILY('CW20'),FAMILY('Legacy') #! #! #!----------------------------------------------- #!----------------------------------------------- #EXTENSION(Global_GetProcedureName,'Global Template to add the GetProcedureName template to each procedure'),APPLICATION(Local_GetProcedureName) #DISPLAY('==========================================') #DISPLAY('Global Template for GetProcedureName functionality') #DISPLAY('==========================================') #PROMPT('Disable GetProcedureName Code',CHECK),%NoGPNCode,AT(10) #AT(%DataSection) #IF(%NoGPNCode) #ELSE _:ProcedureName string('%Procedure') #ENDIF #ENDAT #!----------------------------------------------- #EXTENSION(Local_GetProcedureName,'_:ProcedureName == the Procedure Name'),PROCEDURE #!----------------------------------------------- |
Simple. Sweet. Saves me heaps of time.
clarion, template, homegrown, simple templates save time, programming
4 Responses
Jim Hrubes
April 25th, 2007 at 3:07 am
1I can’t copy the information from your template listing it doesn’t have a vertical scroll.
Thanks
JEH
Stu
April 25th, 2007 at 1:25 pm
2Jim,
Should be okay to just copy it all. This particular code only has 23 lines of code, so there’s no need for any vertical scroll.
Cheers,
Stu
Chris Laurie
April 25th, 2007 at 5:05 pm
3I use Debugview and the GlobalErrors class to log my errors and my calling routine has code along these lines:
l:Appname = ‘MyApp.’
l:ErrorString = l:AppName &GlobalErrors.GetProcedureName() &’.’ &PassedErrorString
This allows a source procedure to report who called it if there is not a GlobalErrors.GetProcedureName in my code.
(There now I too have left a comment on this blog).
Stu
April 25th, 2007 at 7:06 pm
4Thanks Chris, sounds like a pretty good method.
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)
Meta
Pimp My Clarion is proudly powered by WordPress - BloggingPro theme by: Design Disease