Coding practice for better user-proofing
- Posted by fizzpopsoft May 11, 2015
- 1525 views
Hello,
I hardly ever submit and my code to this forum, as its not up to the standard of persons such as the late Jiri Babor or David Cuny..
Thier code is efficient, readable, concise.. positively elegant IMHO! No disrespect to any others not mentioned is intended.
Anyway, I have a program with 43 possible parameters, being a mixture of singular / multiple arguments, numeric and text; several controls/edittexts in a GUI too. I short, lots of opportunity where this flexibility allows a user to find a bug/undocumented feature ;)
So I write a log of everything the user does, and copy the configuration file contents to the log also, including the assumptions for missing config parameters.
But, is there a better way to do something like this:
function parse_sql_data(integer fieldnum, sequence data, sequence sql_delimiter) -- find between delimiters, drop spaces sequence s1, s2, delimiter, space integer i1, i2, i3, i4 space = " " delimiter = sql_delimiter -- "|" i3 = 0 s1 = data if debug_level > 3 then writelog("Debug 4 function 'parse_sql_data' called, using '" & data & "'") debug_reccnt = sprintf("%10d",{fieldnum}) writelog("Debug 4 function 'parse_sql_data' called, field " & debug_reccnt) end if -- where debug_level 1 is terse, 2 is normal messages, 3 is debug without proc/function names or passed vars -- the rest of this function is removed.... writelog puts date/time in front too end function
Is there a more elegant way to create/use a user debug level..?
BTW, debug level > 2 is only available when sanctioned by myself.
Regards,
Alan