Home > Software design >  Basic AutoLisp Variable, Function Passthrough
Basic AutoLisp Variable, Function Passthrough

Time:05-04

Okay, I seem to be having trouble passing a simple variable through to another variable in a function. I don't see what I'm doing wrong here. Why is passing the variable with a string converted to nil, but passing the raw strings remain unchanged?

;; Main Procedure
(defun C:Debug01(/ dirPath sResult)

    ;; Pulls and shows directory of current file
    (setq dirPath (getvar 'dwgprefix))
    (princ (strcat "\n \n" dirPath "\n \n"))

    ;; Basic Function
    (setq sResult (fcnBasic "Message 1" dirfile "Message 3" "Title"))
    (princ (strcat " \nResulting output : " sResult "\n "))
    (princ)
)

;; A Basic Function
(defun fcnBasic (message1 message2 message3 main / sReturn)

    ;; Displaying values
    (princ (type message1)) (princ (strcat " : " message1 "\n"))
    (princ (type message2)) (princ (strcat " : " message2 "\n")) ;; Message 2 should equal "C:\Users\Garrettb\Documents" with a type of STR.
    (princ (type message3)) (princ (strcat " : " message3 "\n"))
    (princ (type main))     (princ (strcat " : " main "\n"))

    ;; Returning a value
    (setq sReturn message2)
    (return sReturn)
)

Command Window's Display Output

CodePudding user response:

In line:

(setq sResult (fcnBasic "Message 1" dirfile "Message 3" "Title"))

You pass variable dirfile which is not initialized in function C:Debug01. Maye somewhere is, I don't know. You set value of variable dirPath which is not the same as dirfile ;)

  • Related