Author Topic: vl-exit-with-value  (Read 2037 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
vl-exit-with-value
« on: March 03, 2017, 04:52:58 AM »
Hi guys,
I was wondering how this vl-exit-with-value funciton works and why it doesn't return the expected result.
Here are the tests I did:

Code - Auto/Visual Lisp: [Select]
  1. ; Returns... nothing
  2. ; _$ (test) -> _$
  3. (defun test ( / )
  4. )
  5.  
  6. ; Returns... nothing
  7. ; _$ (test) -> _$
  8. (defun test ( / *error* )
  9.   (defun *error* ( m )
  10.   )
  11.   (/ 1 0)
  12. )
  13.  
  14. ; This one errors out, and returns.. nothing
  15. ; _$ (test) -> _1$
  16. (defun test ( / *error* )
  17.   (defun *error* ( m )
  18.     3
  19.   )
  20.   (/ 1 0)
  21. )
I was expecting to stop the routine and return this value of 3  :thinking:
My intention was to use it inside an 'unstoppable' iterator like foreach / repeat / vlax-for, get the required item I need - and stop the same iterator by exiting (vl-some behavior).
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: vl-exit-with-value
« Reply #1 on: March 03, 2017, 08:24:27 AM »
This function is for use specifically with VLX applications which are compiled to a separate namespace, and is used in order to return a value to the calling function (which resides in a different namespace to the VLX application) - see here for a brief explanation of namespaces.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: vl-exit-with-value
« Reply #2 on: March 04, 2017, 05:20:58 AM »
Thank you, Lee!
Looks like its not that simple as I've thought - since I didn't knew/heard about namespace(s).
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: vl-exit-with-value
« Reply #3 on: March 04, 2017, 07:08:48 AM »
You're most welcome - although you are not currently at the stage of working with namespaces, this thread at least serves as an explanation for others unsure of this function.  :-)

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: vl-exit-with-value
« Reply #4 on: March 04, 2017, 08:11:52 AM »
You're most welcome - although you are not currently at the stage of working with namespaces, this thread at least serves as an explanation for others unsure of this function.  :-)
Indeed,
I wasn't aware that some functions require additional details - thankfully you are here to explain more about LeeSP. :D
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg