Author Topic: Share your ERROR subroutine to get best one  (Read 10470 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Share your ERROR subroutine to get best one
« Reply #15 on: July 07, 2010, 09:27:19 AM »
You should be flattered :)

Don't get me wrong, I am flattered when I see my code being used by others - but I just get peeved when code is blatently copy/pasted with no credit as to the source is all.


It's a generic error handler. Do you give credit to whom you got the usage of wcmatch in the error handler from?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Share your ERROR subroutine to get best one
« Reply #16 on: July 07, 2010, 09:34:32 AM »
You should be flattered :)

Don't get me wrong, I am flattered when I see my code being used by others - but I just get peeved when code is blatently copy/pasted with no credit as to the source is all.



Honestly, ask yourself: why?  
Let it go man. I'll give you a story. This one time (at band camp) I had a very sneaking suspicion that one guy i knew took my code and assembled a ``for sale program''. I was so weird about the whole situation that I started to work on a VLX and FAS decompiler so i could check. Do you have any idea how long it takes to map out a file structure like that with a hex editor (It takes a long time).  After about a week i started to make some progress and then i realized what i was doing and how much time I was wasting.  ...who cares (chin up)?

Besides, how complicated is this stuff anyways? Not very! Chances are that i could have wrote that very same thing 6 years ago and you then are the copy cat (so there :P ).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Share your ERROR subroutine to get best one
« Reply #17 on: July 07, 2010, 09:37:45 AM »
True, perhaps I'm getting worked up over nothing - I know that its only a small amount of code, and simple to write, but what got me was that there was no attempt at understanding the code that was used, clearly demonstrated by the Undomark being left in there. But you are right - I've said my piece, I'll leave it now.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Share your ERROR subroutine to get best one
« Reply #18 on: July 07, 2010, 09:40:53 AM »
Don't lie, you just want to see your name in lights as much as possible.  :lmao:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Share your ERROR subroutine to get best one
« Reply #19 on: July 07, 2010, 09:47:22 AM »
<snip> what got me was that there was no attempt at understanding the code that was used... <snip>

*Phhhttt!* Yeah tell me about it. I post genius all day and i dont even get as much as "hey thats a cool idea".
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Share your ERROR subroutine to get best one
« Reply #20 on: July 07, 2010, 09:49:03 AM »
<snip> what got me was that there was no attempt at understanding the code that was used... <snip>

*Phhhttt!* Yeah tell me about it. I post genius all day and i dont even get as much as "hey thats a cool idea".
I think everyone feels that way, at least at some point.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

pkohut

  • Guest
Re: Share your ERROR subroutine to get best one
« Reply #21 on: July 07, 2010, 10:15:27 AM »
<snip> what got me was that there was no attempt at understanding the code that was used... <snip>

*Phhhttt!* Yeah tell me about it. I post genius all day and i dont even get as much as "hey thats a cool idea".
:-D :-D :-D
U-2, eh!

But as far as what Lee is talking about, let it go. Not everyone *wants* to understand the code they use,
some just want to put together a "patchwork quilt of pieces" to get something that works for them. On the
other hand continue to educate those that want to learn and participate. BTW, how long you been programming
anyways? Cause you've got some "elite" skills.  :kewl:


Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Share your ERROR subroutine to get best one
« Reply #22 on: July 07, 2010, 10:30:25 AM »
Thanks Paul - that is high praise indeed considering the source  :-)  I started about a year and a half or so ago, but only in the relatively simple world of LISP - I'd love to do what you guys can do in C++/Arx.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Share your ERROR subroutine to get best one
« Reply #23 on: July 07, 2010, 11:02:11 AM »
When I grow up, I hope to have 'elite' skills like some here.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

pkohut

  • Guest
Re: Share your ERROR subroutine to get best one
« Reply #24 on: July 07, 2010, 11:12:47 AM »
When I grow up, I hope to have 'elite' skills like some here.

Things you lispers' can do is mazing!

LE3

  • Guest
Re: Share your ERROR subroutine to get best one
« Reply #25 on: July 07, 2010, 11:18:20 AM »
When I grow up, I hope to have 'elite' skills like some here.
Me too.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Share your ERROR subroutine to get best one
« Reply #26 on: July 07, 2010, 11:19:20 AM »
When I grow up, I hope to have 'elite' skills like some here.
Me too.
Psh, you'll never grow up.  :laugh:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Share your ERROR subroutine to get best one
« Reply #27 on: July 07, 2010, 11:48:30 AM »
"[you]" = whomever


[you] want "attempt to understand" the code?

Why did [you] choose to use OR the way you did?
Code: [Select]
(or (wcmatch (strcase errmsg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\nError: " errmsg " **")))

Why did you terminate it after the first PRINC statement (technically speaking: there would be no difference if you terminated after the second princ)?
Code: [Select]
(or (wcmatch (strcase errmsg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\nError: " errmsg " **"))
    (princ))

Why did [you] choose OR over something simpler to understand like COND?
Code: [Select]
(cond
      ((wcmatch (strcase errmsg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " errmsg " **")))
    )

The way [you] use OR in the previous is confusing. In fact it would be less confusing and more straightforward if [you] choose to use IF or COND.

Why did'nt [you] at least stop all commands?
Code: [Select]
(repeat 2 (command))
Why did [you] choose the name "*error*" and not something like "MYERRHNDLR"
...
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Share your ERROR subroutine to get best one
« Reply #28 on: July 07, 2010, 12:01:18 PM »
My answer:

Why did [you] choose to use OR the way you did?

To save from an 'if, not' - OR looks and feels tidier "Either the msg is matched with ... , OR we print it".

Why did you terminate it after the first PRINC statement (technically speaking: there would be no difference if you terminated after the second princ)?

Yes there would, if the OR was terminated after the second 'princ', the second 'princ' would not be evaluated as the previous expression returns True. And secondly, the OR would be the last function call so we would have a return of T.

Why did [you] choose OR over something simpler to understand like COND?
Code: [Select]
(cond
      ((wcmatch (strcase errmsg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " errmsg " **")))
    )

Again, just aesthetics I suppose...

Why did'nt [you] at least stop all commands?
Code: [Select]
(repeat 2 (command))

I tend not to use command statements in my code.

Why did [you] choose the name "*error*" and not something like "MYERRHNDLR"

I localise the *error* symbol in my code hence performing the same result as restoring the default handler.


How did I do?

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Share your ERROR subroutine to get best one
« Reply #29 on: July 07, 2010, 12:35:56 PM »
> I tend not to use command statements in my code.

why? There is nothing wrong with COMMAND if you are prepared for it. Besides, two commands like that means <ESCAPE> <ESCAPE>

> ...the second 'princ' would not be evaluated as the previous expression returns True...

See what i mean about confusing? `aesthetics' be damed. [you] or someone needs to maintain this. Make it easier on yourself; ditch the fancy obscure tricks and focus on the elegance.

Why even check the string if your not going to print it if it passes the check BTW? I'm actually kinda confused.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org