LISP Loading / Command Alias Problem

I have a LISP function that I use a lot, and I have it set to load along with a bunch of others on startup. Here's the line from the LISP autoload file:

(defun c:br () (load "br") (c:br))

I have close to 500 such loading functions in that file, and all of them work except this one.

I know that "br" is a common alias for the BREAK command, so I've gone through every PGP file I can find on my system and removed that alias and then REINITed the PGP file. However, when I enter br at the command line, I get nothing -- neither my br function nor the BREAK command, just the command prompt as though a null function had been executed.

If I explicitly load the br function at the command line:

(load "br")

thereafter the function responds as expected.

Reloading the autoload file doesn't change the situation.

Thoughts?

Comments

  • My guess would be there is a problem with the 'autload' file.
    Potential next debugging steps:

    1. Check all occurrences of 'br' in that file.
    2. Create a temporary 'autload' file with just the c:br stub.
    3. Rename 'br' using a unique string that is not an existing alias (Note: change the 'br' file as well).
  • Jim,
    I believe the problem is created in the line of code that you posted. When you have (defun c:br () (load "br") (c:br)) in your on_doc-load.lsp file you are defining the function "br" and then calling "br", which loads "br". Since you defined "br" with that line of code including c:, any time you enter "br" at that command line it is simply running that function again and loading "br" again. In your on_doc-load.lsp file I would simply have (load "br") to load your lisp file. Then you should be able to use it as expected. I hope this helps.

    Thanks,
    Kevin

  • I'm skeptical that the loading code is the problem, as it works fine with almost 500 other functions defined in the same way.

    Just now I altered the autoload file as an experiment. In addition to the line:

    (defun c:br () (load "br") (c:br))

    I added the line:

    (defun c:brx () (load "br") (c:br))

    The latter line does the same thing as the former, it loads the br function as a command. Calling brx at the command line executed the br code as intended, and thereafter entering br at the command line worked, too.

  • Why do you use this 'stub' concept instead of the standard autoload function? But, having said that, even that function is somewhat archaic. Loading 500 Lisp function on startup is hardly problematic for the average modern computer.

    4th debugging step/tip:
    Try switching off AutoComplete.

  • Why do you use this 'stub' concept

    Probably because I've been using it since 1990 or so and haven't seen a need to change.

    Try switching off AutoComplete.

    Just tried it, no change. :(

  • Here's what I tried next: I commented out both the br and brx function definitions in my stub file (I was previously calling that an autoload file, but that was before I knew there was an autoload command) so that they wouldn't be loaded with a new drawing. I then opened a new drawing and used the autoload command to load the br function:

    : (autoload "br" '("br"))

    Then I tried the br command:

    : br

    As before, I got nothing but a new command prompt. Just to be sure the old definition wasn't loading, I tried the brx command:

    : brx
    Unable to recognize command "BRX". Please try again.

    Next I saved br.lsp as test.lsp and changed the function name from br to brz. I opened a new drawing and did an autoload:

    : (autoload "test" '("brz"))
    BRZ

    The function executed as intended.

    Sooooo.....while I think it's likely that something on my system is interfering with the use of br as a function name until the file is explicitly loaded, I'm perplexed as to what it is. The less likely scenario is that there's something coded into BricsCAD that's intercepting the br call, but the only way I can think of to rule that out is for someone to try that with a test function on their system. Any takers?

  • One more thing: As mentioned above, executing br after autoloading or stub loading does nothing apparent. But when I issue at the command line:

    (type br)

    the response is SUBR, so BricsCAD recognizes br as a function. Only after I load it at the command line via (load "br") does it perform as designed.

  • Your last post indicates that a Lisp function named 'br' exists. But your command function is called 'c:br'.

  • @Roy Klein Gebbinck said:
    Your last post indicates that a Lisp function named 'br' exists. But your command function is called 'c:br'.

    Hmmm, this morning (type br) produces nil, even after loading the command function br. I don't know how I got SUBR from it yesterday.

This discussion has been closed.