Author Topic: metric/imperial conversion at command line input  (Read 6035 times)

0 Members and 1 Guest are viewing this topic.

Spike Wilbury

  • Guest
Re: metric/imperial conversion at command line input
« Reply #15 on: August 31, 2009, 10:56:59 PM »
That's right, if I remember correctly lisp prints the result of the last function to the command line, how do I get it to send it to the command line once calculated but before it resets the modes??

Like this?

;; Imperial string to mm converter
(defun c:IMP()
  ;save the currnet polar mode [if used we can set it back]
  (setq polmode (getvar "polarmode"))
  ;set orthomode on
  (setvar "orthomode" 1)
  (setq ds (getstring t "\nEnter Imperial Distance: "))
  (setq value (cvunit (distof ds 4) "inch" "mm"))
;this is where it falls down -
  (setvar "orthomode" 0)
  (setvar "polarmode" polmode)
  value
 )

MickD

  • King Gator
  • Posts: 3666
  • (x-in)->[process]->(y-out) ... simples!
Re: metric/imperial conversion at command line input
« Reply #16 on: August 31, 2009, 11:13:47 PM »
That's the one Luis :) :)

I had to change polarmode to autosnap though now it works as expected.

Thanks Heaps Guys.

Code: [Select]
;; Imperial string to mm converter
(defun c:IMP()
  ;save the currnet polar and osmode [if used we can set it back]
  (setq asmode (getvar "autosnap"))
  (setq ormode (getvar "orthomode"))
  ;set orthomode on
  (setvar "orthomode" 1)
  (setq ds (getstring t "\nEnter Imperial Distance: "))
  (setq value (cvunit (distof ds 4) "inch" "mm"))
  ;set our modes back as they were
  (setvar "autosnap" asmode)
  (setvar "orthomode" ormode)
  ;send the value to the command line as input
  value
 )

<edit> added code to reset orthomode as well and comments
« Last Edit: August 31, 2009, 11:31:16 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Spike Wilbury

  • Guest
Re: metric/imperial conversion at command line input
« Reply #17 on: August 31, 2009, 11:37:10 PM »
perfect sir!  :-)