PDA

View Full Version : DCL locking up!



kieren
2004-12-04, 11:06 PM
Can anyone please help?

-Relevant files attached-
I have a lisp routine that calls a dcl file, but the dcl file locks up when the command (ersaprof) is run.
Have checked with VLIDE and it says lsp has "extra right paranthesis", but I'm darned if I can find the error.

The lsp also calls data from another external file, but I know that this part of the routine works ok (I have another very similar routine calling very similar data and that works ok as a comparison, but cannot seem to get this particular dcl to work correctly).

Any help gratefully appreciated.

CAB2k
2004-12-05, 02:35 AM
Here is the corrected code, two errors found, fixed and marked

;;; ==== Start ersa Profile View Program ====

;;; p2 __p3
;;; | \p4
;;; | |
;;; | |
;;; | |
;;; | |p5
;;; | \ p6
;;; | \------ p7
;;; | \p8
;;; |______________|
;;; p1 p9
;;;
;;; p10 ???x??x??ersa

(defun c:ersaprof (/ b cmec d datlin fd file intpt line1 names oosm p1 p2 p3 p4 p4a p5 p6 p6a p7 p8 p8a p9 p10 p10a r1 r2 rot rota
siz t1)
(graphscr)

(setq olderr *error*
*error* nameerror
)
;;; setq

;;; ==== Get current variable info ====

(setq oosm (getvar "osmode"))
(setq cmec (getvar "cmdecho"))

(setvar "cmdecho" 0)

;;; ==== DCL, Get Size ====

(setq names (list "25x25x3RSA" "25x25x4RSA" "25x25x5RSA" " " "30x30x3RSA" "30x30x4RSA"
"30x30x5RSA" " " "40x40x4RSA" "40x40x5RSA" "40x40x6RSA" " "
"45x45x4RSA" "45x45x5RSA" "45x45x6RSA" " " "50x50x5RSA" "50x50x6RSA"
"50x50x8RSA" " " "60x60x5RSA" "60x60x6RSA" "60x60x8RSA" "60x60x10RSA"
" " "70x70x6RSA" "70x70x8RSA" "70x70x10RSA" " " "80x80x6RSA"
"80x80x8RSA" "80x80x10RSA" " " "90x90x6RSA" "90x90x8RSA" "90x90x10RSA"
"90x90x12RSA" " " "100x100x8RSA" "100x100x10RSA" "100x100x12RSA" "100x100x15RSA"
" " "120x120x8RSA" "120x120x10RSA" "120x120x12RSA" "120x120x15RSA" " "
"150x150x10RSA" "150x150x12RSA" "150x150x15RSA" "150x150x18RSA" " " "200x200x16RSA"
"200x200x18RSA" "200x200x20RSA" "200x200x24RSA"
)
;;;list
)
;;;setq names
(setq dcl_id (load_dialog "ersaprof.dcl"))
(if (not (new_dialog "ersaprof" dcl_id))
(exit)
)
;;;if

(action_tile
"tl"
"(setq intpt \"tl\")"
)
;;;action_tile
(action_tile
"tc"
"(setq intpt \"tc\")"
)
;;;action_tile
(action_tile
"tr"
"(setq intpt \"tr\")"
)
;;;action_tile
(action_tile
"ml"
"(setq intpt \"ml\")"
)
;;;action_tile
(action_tile
"mc"
"(setq intpt \"mc\")"
)
;;;action_tile
(action_tile
"mr"
"(setq intpt \"mr\")"
)
;;;action_tile
(action_tile
"bl"
"(setq intpt \"bl\")"
)
;;;action_tile
(action_tile
"bc"
"(setq intpt \"bc\")"
)
;;;action_tile <<<<===================<<<< ERROR WAS HERE, Missing CR
(action_tile "br"
"(setq intpt \"br\")"
)
;;;action_tile

(setq rot "0.0")
(action_tile
"ang"
"(setq rot $value)"
)
;;;action_tile

(start_list "selections")
(mapcar 'add_list names)
(end_list)
(action_tile
"accept"
(strcat
"(progn (setq siz (atof (get_tile \"selections\")))"
"(done_dialog)(setq userclick T))"
)
;;;strcat
)
;;;action_tile
(action_tile
"cancel"
"(done_dialog)(setq userclick nil)"
)
;;;action_tile "cancel"
(start_dialog)
(unload_dialog dcl_id)
(if userclick
(progn
(setq siz (fix siz))
(setq siz (nth siz names))
)
;;;progn
)
;;;if
(if (= userclick nil)
(exit)
)
;;;if

;;; ==== Get Data Line from .dat file ====

(setq file (findfile "structool.dat"))
(setq fd (open file "r"))
(setq line1 (read-line fd))
(while line1
(if (= line1 (strcat " " siz))
(progn
(setq datlin (read-line fd))
(setq line1 nil)
)
;;;progn
)
;;;if
(setq line1 (read-line fd))
)
;;;while
(close fd)

;;; ==== Set Parameters from Data Line ====

(setq d (atof (substr datlin 25 5))
b (atof (substr datlin 32 5))
t1 (atof (substr datlin 40 4))
r1 (atof (substr datlin 46 4))
r2 (atof (substr datlin 52 3))
)
;;;setq

;;; ==== Draw ersa Section Profile Section ====

(initget 7)
(setq p1 (getpoint
(strcat "\nInsertion Point for <" siz "> [Profile View]: ")
)
)
(setvar "osmode" 0)

;;; ==== Rotation Angle ====

(setq rota rot)
(setq rot (/ (* (atof rot) pi) 180))

;;; ==== Insertion Point ====

(cond
((= intpt "tl")
(setq p1 (polar p1 (+ rot (* 1.5 pi)) d)
)
;;;setq
)
((= intpt "tc")
(setq p1a (polar p1 (+ rot pi) (/ b 2))
p1 (polar p1a (+ rot (* 1.5 pi)) d)
)
;;;setq
)
((= intpt "tr")
(setq p1a (polar p1 (+ rot pi) b)
p1 (polar p1a (+ rot (* 1.5 pi)) d)
)
;;;setq
)
((= intpt "ml")
(setq p1 (polar p1 (+ rot (* 1.5 pi)) (/ d 2))
;;;setq
)
)
((= intpt "mc")
(setq p1a (polar p1 (+ rot pi) (/ b 2))
p1 (polar p1a (+ rot (* 1.5 pi)) (/ d 2))
)
;;;setq
)
((= intpt "mr")
(setq p1a (polar p1 (+ rot pi) b)
p1 (polar p1a (+ rot (* 1.5 pi)) (/ d 2))
)
;;;setq
)
((= intpt "bl")
(setq p1 p1)
;;;setq
)
((= intpt nil)
(setq p1 p1)
;;;setq
)
((= intpt "bc")
(setq p1 (polar p1 (+ rot pi) (/ b 2))
)
;;;setq
)
((= intpt "br")
(setq p1 (polar p1 (+ rot pi) b)
)
;;;setq
)
)
;;;cond

;;; ==== Get Current Layer ====

(setq clay (getvar "clayer"))

(if (= (tblsearch "layer" "Text") nil)
(command "-layer" "new" "Text" "colour" "green" "Text" "")
)
;;;if

(setq p2 (polar p1 (+ rot (* pi 0.5)) d)
p3 (polar p2 rot (- t1 r2))
p4a (polar p3 rot r2)
p4 (polar p4a (+ rot (* pi 1.5)) r2)
p5 (polar p4 (+ rot (* pi 1.5)) (- d r2 r1 t1))
p6a (polar p5 (+ rot (* pi 1.5)) r1)
p6 (polar p6a rot r1)
p7 (polar p6 rot (- d r2 r1 t1))
p8a (polar p7 rot r2)
p8 (polar p8a (+ rot (* pi 1.5)) r2)
p9 (polar p1 rot b)
p10a (polar p1 rot (/ b 2))
p10 (polar p10a (+ rot (* pi 1.5)) 60)
)
;;;setq

(command ".pline" p1 "width" 0.0 0.0 p2 p3 "arc" p4 "line" p5 "arc" p6 "line" p7 "arc" p8 "line" p9 "close")
(setvar "clayer" "text")
(command ".text" "c" p10 "30" rota siz)
(setvar "clayer" clay)

;;; ==== Reset System Variables ====

(setvar "osmode" oosm)
(setvar "cmdecho" cmec)

(setq *error* olderr)
(princ) ; <<<<<===============<<<<<<<<<< EXTRA PAREN WAS HERE
)
;;; ==== End of ersa Profile View Program ====