I’m trying to create a plot command that reads settings in from a variable stored in a text file but its becoming muddled up somewhere.
(defun c:MYPLOT () ;Setting nessesary variables... (setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYOUTPUTDEVICE.PEN") (if(setq f(open fname "r")) (while (setq MYOUTPUTDEVICE (read-line f)) (close))) (setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERSIZE.PEN") (if(setq f(open fname "r")) (while (setq MYPAPERSIZE (read-line f)) (close))) (setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERORIENTATION.PEN") (if(setq f(open fname "r")) (while (setq MYPAPERORIENTATION (read-line f)) (close))) (setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERPLOTSTYLE.PEN") (if(setq f(open fname "r")) (while (setq MYPAPERPLOTSTYLE (read-line f)) (close))) (setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERLINEWEIGHTS.PEN") (if(setq f(open fname "r")) (while (setq MYPAPERLINEWEIGHTS (read-line f)) (close))) ;this line works... ;(Command "-Plot" "Y" X "\\\\dcmar02\\A03P17A4ZW" "A4 (210 x 297 mm)" "Millimeters" "Landscape" "No" "layout" "1:1" "0.00,0.00" "n" "" "Yes" "No" "Yes" "No" "No" "No" "yes") ;this line dosnt.. (command "-Plot" "Yes" X MYOUTPUTDEVICE MYPAPERSIZE MYPAPERUNITS MYPAPERORIENTATION "no" "Layout" "Fit" "0.00,0.00" "Yes" MYPAPERPLOTSTYLE "No" "No" MYPAPERLINEWEIGHTS "yes" "yes" "no" "no" "no" "yes") ) )
Solved! Go to Solution.
Solved by martti.halminen. Go to Solution.
Solved by The_Caddie. Go to Solution.
Try (close f) instead of (close).
- The debug>Break on Error setting in VLIDE would help in finding these.
--
After correcting the CLOSE bug you'll notice the program has further problems:
- closing the file inside the loop doesn't make much sense.
- doing a SETQ to the final variable in the test of the WHILE loop isn't useful, as the value after the loop will always be NIL. Use a temporary variable in the test and set the final variable in the loop body:
(if (setq f (open fname "r")) (while (setq temp (read-line f)) (setq MYOUTPUTDEVICE temp))) (close f)
- Also, make sure you don't have an empty last line in your file: that loop reads every line in the file, saving the last one as value.
--
yes how stuipid of me BTW I'm custom to ussing ust notepad to write all my lisp, i did however seek the use of Vlide after a while but because of my unfamiliaraty with the Vlide program I was unable to locate the problem
Thankyou for your help
actually I see where the whole problem is occurring its when the plot device is being selected the plot device we have is named \\dcmar02\A03P19 in lisp I tried it as \\\\dcmar02\\A03P19 though that didnt work either
i have a more simple way to demonstrait this lasve the following lisp and you will see exactly wher my problem lies qua the slashes in the MYOUTPUTDEVICE variable.
(defun C:test () (setq MYOUTPUTDEVICE (getstring "\\dcmar02\a03p19")) (alert MYOUTPUTDEVICE ) )
how do I manage to include the slashes?
@The_Caddie wrote:actually I see where the whole problem is occurring its when the plot device is being selected the plot device we have is named \\dcmar02\A03P19 in lisp I tried it as \\\\dcmar02\\A03P19 though that didnt work either
i have a more simple way to demonstrait this lasve the following lisp and you will see exactly wher my problem lies qua the slashes in the MYOUTPUTDEVICE variable.
(defun C:test () (setq MYOUTPUTDEVICE (getstring "\\dcmar02\a03p19")) (alert MYOUTPUTDEVICE ) )how do I manage to include the slashes?
The rule of thumb is: whenever you are using explicit quotation marks, you need to use doubled backslashes - and only then.
GETSTRING uses PRINC to output its prompt, so your example shows as \dcmar02a03p19,
and reads your answer without quotation, so you don't need to use the Lisp-style doubled backslashes yourself here.
The ALERT call also uses PRINC, so it shows only the actual data, not the escape characters.
--