Author Topic: Please teaching me .  (Read 7631 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Please teaching me .
« Reply #30 on: July 19, 2015, 12:16:11 PM »
Thank you AIberto  :-)

DuanJinHui

  • Guest
Re: Please teaching me .
« Reply #31 on: July 19, 2015, 09:07:58 PM »

...or pass the function two quoted symbols to which the values will be assigned:

Code - Auto/Visual Lisp: [Select]
  1. (defun get_time ( outsym1 outsym2 )
  2.     (if (set outsym1 (LM:internettime "YYYYMODD"))
  3.         (set outsym2 (dtoj (atoi (eval outsym1))))
  4.         (progn
  5.             (set outsym1 (itoa (fix (getvar 'cdate))))
  6.             (set outsym2 (fix (getvar 'date)))
  7.         )
  8.     )
  9.     nil
  10. )


Lee, Why use "set" rather than "setq" ?

Because I require both arguments supplied to the set function to be evaluated: the first argument yields the symbol to which the value should be assigned (that is, the quoted symbol supplied as an argument to the 'get_time' function); the second argument yields the value (as per setq).

If setq were used, the first argument would not be evaluated and the corresponding value would be assigned to the 'outsym1' or 'outsym2' symbols.

Observe:
Code - Auto/Visual Lisp: [Select]
  1. _$ (setq a 'b)
  2. B
  3. _$ (set a 1)
  4. 1
  5. _$ a
  6. B
  7. _$ b
  8. 1

@Lee Mac
I really appreciate it.  we’re so proud of you.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Please teaching me .
« Reply #32 on: July 20, 2015, 03:31:58 AM »
You're most welcome DuanJinHui :-)