Run external LISP within a LISP

Discussion in 'AutoCAD' started by Xolo, Jun 17, 2004.

  1. Xolo

    Xolo Guest

    Hey there,

    I've seen only 1 post on this and it didn't make any sense to me. How do you
    call up a LISP routine while in a running LISP routine? And once the
    external LISP finishes running, the original routine will finish running.

    Also, can you make the variables from the one routine to be set for
    variables in the newly ran LISP? If so, how do you do that?

    P.S. - I'm a newbie at the LISP game, so please explain your answers.

    Thanks a lot,

    Xolo
     
    Xolo, Jun 17, 2004
    #1
  2. Xolo

    Rudy Tovar Guest

    The following example shows a function that calls 3 variables. But as you
    can see only 2 are declared locals, var1 and var2. 'Var3' is not contain
    within the list as being local, and now is global. Actually any variable you
    don't declare local, within the parenthesis is considered global, and can be
    used in another utility.

    (defun c:fun1 (/ var1 var2)
    (do_this_or_that)
    (princ)
    )

    To call a separate function within one, simply call it from the funcion as
    illustrated.

    (defun C:main (/)
    (callnext)
    (callafter)
    (callnow)
    (do_what_ever)
    (princ)
    )
    (defun callafter (/)
    (do_this_or_that)
    (princ)
    )
    (defun callnow (/)
    (do_this_or_that)
    (princ)
    )
    (defun callnext (/)
    (do_this_or_that)
    (princ)
    )
    (defun do_what_ever (/)
    ;etc.
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jun 17, 2004
    #2
  3. Here are 3 examples on how to run a lisp program from another program

    Example #1 -
    (defun C:TEST1 ()
    (Princ "\nThis is Test1 line 1.")
    (C:TEST1A)
    (Princ "\nThis is Test1 line 2.")
    (princ)
    )
    (defun C:TEST1A ()
    (princ "\nThis is Test2 line 1.")
    (princ)
    )
    Save both programs in File name TEST1.lsp
    At command prompt type -
    (load "Test1")
    TEST1
    watch prints to screen
    ----------------------------------------------------------
    Example #2 -
    (defun C:TEST2 ()
    (Princ "\nThis is Test2 line 1.")
    (TEST2a)
    (Princ "\nThis is Test2 line 2.")
    (princ)
    )
    (defun TEST2a ()
    (princ "\nThis is Test2a line 1.")
    (princ)
    )
    Save both programs in File name TEST2.lsp
    At command prompt type -
    (load "Test2")
    TEST2
    watch prints to screen
    ----------------------------------------------------------
    Example #3 -
    (defun C:TEST3 ()
    (Princ "\nThis is Test3 line 1.")
    (TEST3a "3a" "1")
    (Princ "\nThis is Test3 line 2.")
    (princ)
    )
    (defun TEST3a (Text1 Text2 /)
    (princ (strcat "\nThis is Test" Text1 " line " Text2 "."))
    (princ)
    )
    Save both programs in File name TEST3.lsp
    At command prompt type -
    (load "Test3")
    TEST3
     
    Alan Henderson @ A'cad Solutions, Jun 17, 2004
    #3
  4. Xolo

    Xolo Guest

    Thanks guys,

    I'll try incorporating this info when I get a chance to look more thoroughly
    at it later tonight.

    I love this newsgroup, there's always someone who has an answer or a
    workaround.

    Xolo
    message Here are 3 examples on how to run a lisp program from another program

    Example #1 -
    (defun C:TEST1 ()
    (Princ "\nThis is Test1 line 1.")
    (C:TEST1A)
    (Princ "\nThis is Test1 line 2.")
    (princ)
    )
    (defun C:TEST1A ()
    (princ "\nThis is Test2 line 1.")
    (princ)
    )
    Save both programs in File name TEST1.lsp
    At command prompt type -
    (load "Test1")
    TEST1
    watch prints to screen
    ----------------------------------------------------------
    Example #2 -
    (defun C:TEST2 ()
    (Princ "\nThis is Test2 line 1.")
    (TEST2a)
    (Princ "\nThis is Test2 line 2.")
    (princ)
    )
    (defun TEST2a ()
    (princ "\nThis is Test2a line 1.")
    (princ)
    )
    Save both programs in File name TEST2.lsp
    At command prompt type -
    (load "Test2")
    TEST2
    watch prints to screen
    ----------------------------------------------------------
    Example #3 -
    (defun C:TEST3 ()
    (Princ "\nThis is Test3 line 1.")
    (TEST3a "3a" "1")
    (Princ "\nThis is Test3 line 2.")
    (princ)
    )
    (defun TEST3a (Text1 Text2 /)
    (princ (strcat "\nThis is Test" Text1 " line " Text2 "."))
    (princ)
    )
    Save both programs in File name TEST3.lsp
    At command prompt type -
    (load "Test3")
    TEST3
     
    Xolo, Jun 18, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.