Jump to content

DCL Locks Up... Any suggestions?


TheyCallMeJohn

Recommended Posts

Hello Everyone,

I am trying to work on DCL program for my coworker and I. I went through the tutorials by Kenny on Afralisp but I am stuck. My DCL keeps freezing. I tried checking it in Visual Lisp Editor and I couldn't figure it out.

 

If anyone has any suggestions on DCL resources. I want to write a larger program for generating detail sheets for company but have a lot to learn.

 

Is there a better way to write interfaces than DCL?

 

;;;;Original Code by by Kenny Ramage

(defun C:PL_TRADE_SELECT ()					;define function
(setq PL_FILE (findfile "PL_WEIGHT.DAT"))
(setq CODE_CHOICE "2007 OPA")
;	(setq CODES "*COV_CODES")
;	(list_find PL_FILE CODES)
;	(setq CODE_LIST FIND_RESULT)
;	(setq FIND_RESULT nil)
;	(setq CODE_LIST_MOD (COMMA_PULL CODE_LIST "STRING"))
(setq CODE_LIST_MOD '("1998 CBC" "2003 IBC" "2007 OPA"))
;	(setq dcl_id (load_dialog "PL_TRADE_SELECT.dcl"))		;load dialog
(if (not (new_dialog "PL_TRADE_SELECT" dcl_id)			;test for dialog

     );not

   (exit)						;exit if no dialog

 );if

 (setq w (dimx_tile "im")				;get image tile width
       h (dimy_tile "im")				;get image tile height

);setq

 (start_image "im")					;start the image
 (fill_image 0 0 w h 5)				;fill it with blue
 (end_image)						;end image
 
 (start_list "CODE_CHOICES")				;start the list box
 (mapcar 'add_list CODE_LIST_MOD)				;fill the list box
 (end_list)						;end list

 (action_tile "PU" "(setq PL_TYPE \"PU\")")		;store point load type
 (action_tile "MP" "(setq PL_TYPE \"MP\")")		;store point load type
 (action_tile "HV" "(setq PL_TYPE \"HV\")")		;store point load type
 (action_tile "EL" "(setq PL_TYPE \"EL\")")		;store point load type

   (action_tile
   "cancel"						;if cancel button pressed
   "(done_dialog) (setq userclick nil)"		;close dialog, set flag
   );action_tile

  (action_tile
   "accept"						;if O.K. pressed
   (strcat						;string 'em together
     "(progn 
      (setq CODE_CHOICE (atof (get_tile \"CODE_CHOICES\")))"	;get list selection
     " (done_dialog)(setq userclick T))"		;close dialog, set flag
   );strcat
 );action tile
 
 (start_dialog)					;start dialog

 (unload_dialog dcl_id)				;unload
(if userclick					;check O.K. was selected
   (progn
     (setq CODE_CHOICE (fix CODE_CHOICE))				;convert to integer
     (setq CODE_CHOICE (nth CODE_CHOICE CODE_LIST_MOD))			;get the size

   );progn

 );if userclick

(princ)

);defun C:PL_TRADE_SELECT

(princ)

 

And the DCL...

 

PL_TRADE_SELECT : dialog {				//dialog name
     label = "Point Load Trade Selection" ;		//give it a label
	
   :boxed_radio_column {			//define radio column
      label = "&Code" ;					//give it a label
      
   : popup_list {				//define popup list
       key = "CODE_CHOICES";			//give it a name
       value = "2007 OPA" ;		//initial value
       }							//end list
   }
   :boxed_radio_column {			//define radio column
      label = "Trade" ;				//give it a label

       : radio_button {			//define radion button
    	  key = "PU" ;				//give it a name
    	  label = "&Plumbing" ;		//give ]it a label
    	  value = "1" ;				//switch it on
       }					//end definition

    	: radio_button {			//define radio button
    	  key = "MP" ;				//give it a name
    	  label = "&Mechancical Pipe" ;		//give it a label
    	}					//end definition

    	: radio_button {			//define radio button
    	  key = "HV" ;				//give it a name
    	  label = "&HVAC" ;	//give it a label
    	  }					//end definition

    	: radio_button {			//define radio button
    	  key = "EL" ;				//give it a name
    	  label = "&Electrical" ;		//give it a label
    	}					//end definition

       }					//end radio column

    ok_cancel ;				//predifined OK/Cancel

    : row {					//define row

    : image {					//define image tile
    key = "im" ;				//give it a name
    height = 1.0 ;				//and a height
    width = 1.0 ;				//and now a width
    }						//end image

    : paragraph {				//define paragraph

    : text_part {				//define text
    label = "Message 1";		//give it some text
    }						//end text

    : text_part {				//define more text
    label = "Message 2";			//some more text
    }						//end text

    }						//end paragraph

    }						//end row
				
    }	

Link to comment
Share on other sites

The reason your dialog freeze is in fact in its definition - you attempt to pre-select an item using its value and not the index.

: popup_list {              //define popup list
key = "CODE_CHOICES";      //give it a name
[color=red] value = [s]"2007 OPA"[/s] "2" ;   //initial value[/color]
}

or

(start_list "CODE_CHOICES")        ;start the list box
(mapcar 'add_list CODE_LIST_MOD)   ;fill the list box
(end_list)                         ;end list
[color=magenta](set_tile "CODE_CHOICES" "2")      ;select an entry from pop-up list by its index[/color]

Link to comment
Share on other sites

  • 2 weeks later...

Well this is embarrassing... so I wrote Lisp to write a lisp and dcl but alas it is freezing again. I have been going over my code for an hour and half and I can't figure out where I have gone wrong...

 

here are the temp codes it generates:

 

(defun templsp ()
(if(not (setq dcl_id (load_dialog fname)))
(progn(alert "The file could not be loaded.")(exit))
(progn	(if (not (new_dialog "temp" dcl_id))
(progn (alert "The DCL definition could not be found inside the DCL file." (exit))
(progn
(action_tile "eb0" "(setq PL_WEIGHT \"0.4500\")")
(action_tile "eb1" "(setq PL_WEIGHT \"0.7200\")")
(action_tile "eb2" "(setq PL_WEIGHT \"1.0900\")")
(action_tile "eb3" "(setq PL_WEIGHT \"1.7300\")")
(action_tile "eb4" "(setq PL_WEIGHT \"2.1400\")")
(action_tile "eb5" "(setq PL_WEIGHT \"3.0900\")")
(action_tile "eb6" "(setq PL_WEIGHT \"4.9700\")")
(action_tile "eb7" "(setq PL_WEIGHT \"6.8800\")")
(action_tile "eb8" "(setq PL_WEIGHT \"9.0300\")")
(action_tile "eb9" "(setq PL_WEIGHT \"11.0100\")")
(action_tile "accept" "(saveVars_WEIGHT)(done_dialog 2)")
(action_tile "cancel" "(done_dialog 1)")
(setq ddiag(start_dialog))
(unload_dialog dcl_id)
(if (= ddiag 1)(princ "\n \n ...DCL_LSP Cancelled. \n "))
(if (= ddiag 2)(princ (strcat "\n You weight is:  lbs.")))
))))))

 

temp : dialog { label = "Pipe Selection";
: boxed_radio_column { label ="Pipe Size"; key = "PIPE_SIZE";
: radio_button {
key = "eb0";
label = "1/2 in";
value = "1" ;
}
: radio_button {
key = "eb1";
label = "3/4 in";
}
: radio_button {
key = "eb2";
label = "1 in";
}
: radio_button {
key = "eb3";
label = "1-1/4 in";
}
: radio_button {
key = "eb4";
label = "1-1/2 in";
}
: radio_button {
key = "eb5";
label = "2 in";
}
: radio_button {
key = "eb6";
label = "2-1/2 in";
}
: radio_button {
key = "eb7";
label = "3 in";
}
: radio_button {
key = "eb8";
label = "3-1/2 in";
}
: radio_button {
key = "eb9";
label = "4 in";
}
}
: boxed_row { : button { key = "accept"; label = " Okay "; is_default = true; }
: button { key = "cancel"; label = " Cancel "; is_default = false; is_cancel = true; } }
}

 

Called function

 

(defun saveVars_WEIGHT()
(setq PIPE_SIZE(get_tile "PIPE_SIZE"))
)

Link to comment
Share on other sites

Try this :-

 

(defun templsp ()
 (if (not (setq dcl_id (load_dialog fname)))
   (progn (alert "The file could not be loaded.") (exit))
   (progn
     (if (not (new_dialog "temp" dcl_id))
   (progn
     (alert
       "The DCL definition could not be found inside the DCL file."
     ) [color=red]<- paren missing[/color]
     (exit)
   )
   (progn
     (action_tile "eb0" "(setq PL_WEIGHT \"0.4500\")")
     (action_tile "eb1" "(setq PL_WEIGHT \"0.7200\")")
     (action_tile "eb2" "(setq PL_WEIGHT \"1.0900\")")
     (action_tile "eb3" "(setq PL_WEIGHT \"1.7300\")")
     (action_tile "eb4" "(setq PL_WEIGHT \"2.1400\")")
     (action_tile "eb5" "(setq PL_WEIGHT \"3.0900\")")
     (action_tile "eb6" "(setq PL_WEIGHT \"4.9700\")")
     (action_tile "eb7" "(setq PL_WEIGHT \"6.8800\")")
     (action_tile "eb8" "(setq PL_WEIGHT \"9.0300\")")
     (action_tile "eb9" "(setq PL_WEIGHT \"11.0100\")")
     (action_tile "accept" "(saveVars_WEIGHT)(done_dialog 1)")
     (action_tile "cancel" "(done_dialog 0)")
     (setq ddiag (start_dialog))
     (unload_dialog dcl_id)
     (if (= ddiag 0)
       (princ "\nDCL_LSP Cancelled.")
     )
     (if (= ddiag 1)
       (princ (strcat "\nYou weight is:" PL_WEIGHT "lbs.")) [color=red]<- didnt mention Pl_Weight here[/color]
     )
   )
     )
   )
 )
)
(defun saveVars_WEIGHT()
   (setq PIPE_SIZE(get_tile "PIPE_SIZE"))
)

Link to comment
Share on other sites

To be exact, your dialog isn't freezing, it just don't shown.

Along Satishrajdev's fixings please pay attention that fname variable isn't initialized (although it may be that you just didn't posted it). The saveVars_WEIGHT function will return the key of current selected radio-button, not its label.

Please don't forget that a better formatting of your code will help to notice some issues by yourself.

 

Also, please pay attention to initialize the PL_WEIGHT variable with a default value - your report will fail if user don't perform an action on dialog!

Link to comment
Share on other sites

It worked thank you.

Try this :-

 

(defun templsp ()
 (if (not (setq dcl_id (load_dialog fname)))
   (progn (alert "The file could not be loaded.") (exit))
   (progn
.....
)

Link to comment
Share on other sites

MSasu,

Could you clarify what you mean by "To be exact, your dialog isn't freezing, it just don't shown." The dialog would pop up it just wouldn't close. The reason fname variable wasn't initialized and the coding wasn't formatted well is because this code is generated by another lisp program which also sets a value for fname. I tried to design it along the lines of Kenny Ramage's tutorial DCL without the DCL File - Part 2

 

But I think going thru and formatting the code that is generated, would help me catch any errors in the future. So thank you for the advice. Also I will initialize the variable.

 

Thanks again. :D

Link to comment
Share on other sites

Taking into account the way your parentesis were balanced, there was no action defined for the case when the dialog definition was available.

(if ([b]not[/b] (new_dialog "temp" dcl_id))
(progn [color=red];the call of dialog is in this branch, which cannot be reached when definition is available?!?[/color]

Link to comment
Share on other sites

Okay thanks for the clarification.

 

Taking into account the way your parentesis were balanced, there was no action defined for the case when the dialog definition was available.

(if ([b]not[/b] (new_dialog "temp" dcl_id))
(progn [color=red];the call of dialog is in this branch, which cannot be reached when definition is available?!?[/color]

 

I had to add to it and found it a lot easier this time create the final lsp and resultant DCL. Get it working how I want it to. Then go back and write the original code to produce that result, and format it correctly and then compare the result to my test code using the Compare function on Notepad++. :working:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...