Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Loading Lisps in Specific Order

  1. #1
    I could stop if I wanted to
    Join Date
    2006-10
    Posts
    236
    Login to Give a bone
    0

    Default Loading Lisps in Specific Order

    I did a quick search, but didn't find what I'm looking for.

    I inherited an old CAD system that we are phasing out as we move over to Revit, so I don't want to reinvent the wheel. We are using the AP Load Startup Suite to load one company specific lisp that in turn loads all of our other lisps.

    I added an IF statement at the bottom that looks for a specific user variable and if found, then loads some other lisps that overwrite our standard lisps (for corp jobs).

    I want that IF statement to be run AFTER all our standard lisps are loaded, however it is running first - then overwriting all of the corp lisps with our standard lisps.

    Is there an easy way to get this accomplished from within a single lisp?

    Thanks,

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    If you would post your codes or at least apart of that needed IF statement, it would be easier for all to give you the direct answer.

    Thanks.

    Tharwat

  3. #3
    I could stop if I wanted to
    Join Date
    2006-10
    Posts
    236
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    (load xxx.lsp)
    (load yyy.lsp)
    (load zzz.lsp)
    ;;;----------------------------------
    ;;;---------------------------------- blah blah blah
    ;;;----------------------------------

    (if (=(getvar "Useri5") 99)
    (load "aaa.lsp")
    )


    They all seem to be working just fine, I just want to execute the IF portion after the other lisps load, and it's currently running the IF routine first.
    Thanks,
    Last edited by gabecottam; 2010-09-23 at 09:56 PM. Reason: clarity

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    Actually your way of IF usage is for somehow kind of security. And I think it is possible to use it that way.

    Regards,

    Tharwat

  5. #5
    I could stop if I wanted to
    Join Date
    2006-10
    Posts
    236
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    The IF statement is just checking for a specific user defined sysvar. It works great. I just want to know how to run the IF statement last instead of first.

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    Here is the Cad help book shows that clearly.
    Attached Images Attached Images

  7. #7
    I could stop if I wanted to
    Join Date
    2006-10
    Posts
    236
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    I appreciate your help tharwat313, but I think you're missing the point. The IF statement is fine.

    Regardless of what the expression is, how do you tell it what order to execute?

  8. #8
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    Check this link out and let me know if you have any question.

    http://www.theswamp.org/index.php?topic=34927.0

    Good luck

    Tharwat

  9. #9
    Member
    Join Date
    2002-08
    Posts
    14
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    LISP routines are executed from top to bottom.
    Everything in a LISP file that's not part of a function (defun ....()) is executed immediately at load-time - with some exceptions. Functions in a file are loaded, but don't execute automatically - you need to call them.

    So in your example, the (load ....) commands are executed when the file is loaded and since the (If...) portion is at the bottom, it's executed last.

    Bear in mind how (IF ...) works.It executes the first statement if the evaluation is true and the second statement if it's false. Example:

    (if (= a 1)
    (print "True")
    (print "False")
    )

    If a = 1, then it will print True. In all other cases, it will print False.

    If I take your example, only (load "aaa.lsp") will be executed if the evaluation is true. Any subsequent lines will be executed if it's false.

    If you need to load several other LISP files as well if the evaluation is true, you have to use (progn ...):

    (if (=(getvar "Useri5") 99)
    (progn
    (load "aaa.lsp")
    (load "bbb.lsp")
    (.....)
    )
    )

    Simon

  10. #10
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Loading Lisps in Specific Order

    in all reality, based on my experience, the routines should run in the order that they appear in the lisp program. At my office, I have a series of loads, that contain numbers printed to the command line (for trouble shooting assistance) and they always load up in the proper number order. And yes, many of them are within IF statements. Now however, if aaa.lsp doesnt replace a specific defun in xxx.lsp, then xxx.lsp will continue to function because it has been loaded. possibly you should set up your IF statement like so:
    Code:
    (if (= (getvar "Useri5") 99)
    (progn
    (load "aaa.lsp")
    ) ;_end progn
    (progn
    (load "xxx.lsp")
    (load "yyy.lsp")
    (load "zzz.lsp")
    ) ;_end progn
    ) ;_end If

Page 1 of 2 12 LastLast

Similar Threads

  1. Lock Drawing order of Specific Objects
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 9
    Last Post: 2021-02-19, 04:47 PM
  2. 2013: Best strategy for loading LISPs?
    By Randall Temple in forum AutoCAD Customization
    Replies: 6
    Last Post: 2012-07-25, 02:17 PM
  3. Loading/Embedding LISPs
    By sam.121498 in forum AutoLISP
    Replies: 6
    Last Post: 2010-02-04, 09:33 AM
  4. Specific Levels of Draw Order
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2008-06-10, 01:17 PM
  5. loading lisps
    By moshira_hassan in forum AutoCAD General
    Replies: 1
    Last Post: 2008-05-21, 12:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •