Author Topic: vlisp-compile returns 1, 2, ...4  (Read 2706 times)

0 Members and 1 Guest are viewing this topic.

@_Bilal

  • Mosquito
  • Posts: 19
vlisp-compile returns 1, 2, ...4
« on: February 16, 2019, 04:48:09 PM »
Greetings,

The vlisp-compile as per Autodesk Knowledge networks

Return Values
Type: T or nil

T, if compilation is successful; otherwise nil.

in this example vlisp-compile return 2!   why 2?
these two lisp files run correctly

sum24.lsp

(defun sum24 ( a b / )
   (setq result
      (+ (* 2 a) (* 4 b))
   )
);sum24

score.lsp

(defun score ( arg1 arg2 / func funcid)
   (setq funcid
      (eval
         (read (strcat arg1 arg2))
      )
   )
   (funcid 4 5)
);score

When compiling score.lsp to fas
(vlisp-compile 'st "C:\\......\\score.LSP")
the return of vlisp-compile is 2

is someone have an explanation of what happened?  where is the error?

thank you

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: vlisp-compile returns 1, 2, ...4
« Reply #1 on: February 16, 2019, 05:51:53 PM »
The compiler is reporting the quantum of warnings it produces.
In this case :

; warning: run time evaluated expression: (READ (STRCAT ARG1 ARG2))   <<== caused by the EVAL I assume
; warning: local variable used as function: FUNCID

If you modify sum24 to
Code - Auto/Visual Lisp: [Select]
  1. (defun sum24 (a b / ) (setq result (eval (+ (* 2 a) (* 4 b)))) )
you will get 3 returned from the compiler.

As an aside :
The score function will generate a runtime error because you are passing integers to be evaluated as strings.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

@_Bilal

  • Mosquito
  • Posts: 19
Re: vlisp-compile returns 1, 2, ...4
« Reply #2 on: February 16, 2019, 07:10:05 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun sum24 ( a b / )
  2.         (setq result
  3.                 (+ (* 2 a) (* 4 b))
  4.         )
  5. );sum24
  6.  
  7.  
  8. (defun score ( arg1 arg2 / func funcid)
  9.         (setq funcid
  10.                 (eval
  11.                         (read (strcat arg1 arg2))
  12.                 )
  13.         )
  14.         (funcid 4 5)
  15. );score
  16.  
  17. ;|  
  18. In AutoCAD commandline
  19.      command: (sum24 4 5)
  20.      28
  21.  
  22.      The arguments passed to function score are string not integers
  23.      command: (score "sum" "24")
  24.      28
  25.  
  26. These two functions run properly....!
  27. when compiling score.lsp
  28.      command: (vlisp-compile 'st "C:\\Folders\\score.LSP")
  29.      2
  30.    ............!
  31.  
  32. I am trying to run the first function sum24 from score function, the name of the first function is variable
  33. let say we have a lot of function sum24, sum34, sum38........ How to run these functions from score function?
  34.  
  35. |;
  36.  
  37.  

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: vlisp-compile returns 1, 2, ...4
« Reply #3 on: February 16, 2019, 07:41:24 PM »
Something like :-- ??

Code - Auto/Visual Lisp: [Select]
  1. (defun sum24 (a b / ) (setq result (+ (* 2 a) (* 4 b))) )
  2. (defun sum25 (a b / ) (setq result (+ (* 2 a) (* 5 b))) )
  3. (defun sum26 (a b / ) (setq result (+ (* 2 a) (* 6 b))) )
  4. (defun sum27 (a b / ) (setq result (+ (* 2 a) (* 7 b))) )
  5.  
  6.  
  7. (defun score (arg1 arg2 valA valB/)
  8.   (eval (read (strcat "(" arg1 arg2 " " (itoa valA) " " (itoa valB) ")")))
  9. )
  10.  

_$ (score "sum" "24" 4 2)
16
_$ (score "sum" "25" 4 2)
18
_$ (score "sum" "26" 4 2)
20
_$ (score "sum" "27" 4 2)
22

« Last Edit: February 16, 2019, 08:31:51 PM by kdub »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

@_Bilal

  • Mosquito
  • Posts: 19
Re: vlisp-compile returns 1, 2, ...4
« Reply #4 on: February 16, 2019, 08:16:36 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun score (arg1 arg2 valA valB/)
  2.   (eval (read (strcat "(" arg1 arg2 " " (itoa valA) " " (itoa valB) ")")))
  3. )
  4.  
  5. ;;           When compiling score.lsp
  6.  
  7. ;;     command: (vlisp-compile 'st "C:\\Folders\\score.LSP")
  8. ;;      1
  9. ;;      The compilation return 1, does 1 means an error or not? because according to Autodesk help the vlisp-compile should return T if success
  10.  
  11.  

Thank you for your cooperation

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: vlisp-compile returns 1, 2, ...4
« Reply #5 on: February 16, 2019, 08:38:26 PM »
Quote

;;           When compiling score.lsp 
;;     command: (vlisp-compile 'st "C:\\Folders\\score.LSP")
;;      1
;;      The compilation return 1, does 1 means an error or not? because according to Autodesk help the vlisp-compile should return T if success
 

Please re-read my first post.
>>>  The compiler is reporting the quantum of warnings it produces.
This is a warning (advisory ), NOT an error


Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

@_Bilal

  • Mosquito
  • Posts: 19
Re: vlisp-compile returns 1, 2, ...4
« Reply #6 on: February 17, 2019, 09:46:48 AM »
Thank you Kdub for the detailed explanation, maybe my question wasn't clear enough
The vlisp-compile of the below codes returns T without warning.

Code - Auto/Visual Lisp: [Select]
  1. (defun sum24 ( a b / )
  2.         (setq result
  3.                 (+ (* 2 a) (* 4 b))
  4.         )
  5. );sum24
  6.  
  7. (sum24 4 5)   ; Return 28
  8.  
  9. ;;      Compile sum24.lsp
  10.         (vlisp-compile 'st "C:\\...............\\sum24.LSP")      ; Return T without warning
  11.  
  12.  
  13.  
  14. (defun score ( arg1 arg2 / )
  15.         ((vl-symbol-value (read (strcat arg1 arg2))) 4 5)
  16. );score
  17.  
  18. (score "sum" "24")    ; Return  28
  19.  
  20. ;;      Compile score.lsp
  21.         (vlisp-compile 'st "C:\\...............\\score.LSP")       ; Return T  without warning
  22.  
  23.  

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: vlisp-compile returns 1, 2, ...4
« Reply #7 on: February 17, 2019, 02:44:21 PM »

Your question was perfectly clear.

I have no intimate knowledge of the inner workings of the compile functionality and can only guess why the AutoCad documentation does not align with reality.
Perhaps you could express your concerns to AutoDesk by submitting a support ticket.

//==========

I like your use of vl-symbol-value. ... much more elegant than the solution I cobbled together.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

@_Bilal

  • Mosquito
  • Posts: 19
Re: vlisp-compile returns 1, 2, ...4
« Reply #8 on: February 17, 2019, 03:56:28 PM »
Thank you Kdub for your cooperation.
Really, theswamp site get below the surface