Jump to content

Recommended Posts

Posted (edited)

EDIT: I have narrowed it down to the code that is coloured orange. It seems that the 1st dialog box doesn't close when a serial number has been entered. I have obviously got some code wrong for closing the dialog.

 

 

I am fairly new to DCL and finding it a bit challenging at the moment to work out what the problem is. I don't think its the DCL so much as the LISP that goes with it

 

Basically I have 2 dialog boxes.

The first one asks for a serial number, and the 2nd one asks for an authorization code

 

The serial number check works, then goes onto ask for the authorization code.

 

The problem is that no matter if the authorization code is correct or wrong, after pressing the OK button on the dialog box, the 1st dialog box appears again with the serial number in the edit box.

 

Once this happens AutoCAD is stuck and there is no way to break whatever is happening with the dialog box. You have to ctrl + alt + delete and then end task to close AutoCAD

 

I am stuck.

 

Here is the code

DCL 1st Box:

sno : dialog {
         label = "Window CAD Authorization";
         : column {
           : boxed_column {
             : edit_box {
               key = "serialkey";
               label = "Enter Serial Number:";
               edit_width = 8;
               
             }

           }
           : boxed_row {
             : button {
       label = " Submit ";
               key = "acceptSerial";
       allow_accept = true;
       is_default = true;

             }
             : button {
               key = "cancelSerial";
               label = " Cancel ";
               is_default = false;
               is_cancel = true;
             }
           }
         }

}

2nd DCL dialog code:

ano : dialog {
         label = "Window CAD Authorization";
         : column {
           : boxed_column {
             : edit_box {
               key = "authkey";
               label = "Enter Authorization Key:";
               edit_width = 11;
               
             }

           }
           : boxed_row {
             : button {
       label = " Submit ";
               key = "acceptAuth";
       allow_accept = true;
       is_default = true;

             }
             : button {
               key = "cancelAuth";
               label = " Cancel ";
               is_default = false;
               is_cancel = true;
             }
           }
         }

}

And here is some of the lisp:

;Serial Number Dialog Box
[color=darkorange](defun serial-dcl  ()

 (setq dcl_id (load_dialog "sno.dcl"))
 (if (not (new_dialog "sno" dcl_id))
   (exit)
 )

 (set_tile "serialkey" "")
 (mode_tile "serialkey" 2)

 
 (action_tile
   "cancelSerial"
   "(done_dialog)"
 )


 (action_tile
   "acceptSerial"
   "(setq serialchk (get_tile \"serialkey\")) (serial-check)"
             )
 
 (start_dialog)
 (unload_dialog dcl_id)

)[/color]




[color=darkorange]
(defun serial-check ()

(cond
      ((= serialchk "123")(done_dialog)(alert "Serial Successful")(serial-code-equation))
      ((= serialchk "234")(done_dialog)(alert "Serial Successful")(serial-code-equation))

      ((/= serialchk "123")(alert "Incorrect Serial Number")(done_dialog 0))
      ((/= serialchk "234")(alert "Incorrect Serial Number")(done_dialog 0))
    );end cond
 )[/color]



(defun serial-code-equation ()
***SECRET STUFF****
 
(Auth-dcl)

)




(defun Auth-dcl  ()

 (setq dcl_idA (load_dialog "ano.dcl"))
 (if (not (new_dialog "ano" dcl_idA))
   (exit)
 )

 (set_tile "authkey" "")
 (mode_tile "authkey" 2)


 
 (action_tile
   "cancelAuth"
   "(done_dialog)"
 )


 (action_tile
   "acceptAuth"
   "(setq authchk (get_tile \"authkey\")) (Auth-Check)"
             )
 
 (start_dialog)
 (unload_dialog dcl_idA)


)

Here is the last function that gets called where everything then goes wrong

(defun Auth-Check ()

(cond
 ((= authchk key)(alert "Authorization Key Successfully Activated")(done_dialog))
 
 ((/= authchk key)(alert "Authorization Key Not Correct")(done_dialog))
 
 )
)

Edited by Andrew1979
Posted

This works for me (action_tile "sizze" "(setq item $value)(done_dialog)") returns item

Posted
This works for me (action_tile "sizze" "(setq item $value)(done_dialog)") returns item

 

thanks for that, I have tried that before but it doesn't work for me. I have managed to change code to make things a bit better, but no matter what I do, I cannot close that first dialog box. I really don't understand what the problem is.

Posted (edited)

Your first dialog isn't showed again, it was just not closed since its START_DIALOG call isn't reached; I did some adjustment to your code:

;Serial Number Dialog Box
(defun serial-dcl( / isValid )
 (setq dcl_id (load_dialog "sno.dcl"))
 (if (not (new_dialog "sno" dcl_id)) (exit))

 (set_tile "serialkey" "")
 (mode_tile "serialkey" 2)
 
 (action_tile "cancelSerial" "(done_dialog)")
 (action_tile "acceptSerial" "(setq isValid (serial-check (get_tile \"serialkey\")))")
 
 (start_dialog)
 (unload_dialog dcl_id)

 (if isValid (serial-code-equation))
)

(defun serial-check( serialchk / isValid )
(cond
 ((or (= serialchk "123")
      (= serialchk "234"))
  (setq isValid T)
  (alert "Serial Successful")
 )
 (T
  (setq isValid nil)
  (alert "Incorrect Serial Number")
 )
);end cond
(done_dialog)

isValid
)

Edited by MSasu
Fixed name of DCL file
Posted

great, thanks for that, looks good. I will give it a try later and let you know how I go.

Posted

Good luck; I also have optimized a little your code, you may find that useful, too.

Posted

Ok, that didn't seem to work. It did close the dialog box but didn't do anything else but that. If you put in the correct or wrong code it just closed the dialog. No alerts were called, no other functions were called. Any ideas? Thanks

Posted

Please pay attention that above I have posted only the two functions that I adjusted; you should replace just them in your code. Also please check my post again since I fixed back the name of your DCL (it was changed it to suit my test environment).

Posted

Yeah I noticed the change but made adjustments. For some reason, it just wouldn't work. However, I have now gotten it to work based on what you informed me about with the DCL dialog not loading.

 

I reverted pretty much to my initial code with this exception:

 (action_tile
   "acceptSerial"
   "(setq serialchk (get_tile \"serialkey\"))(done_dialog)"
   )
 
 (start_dialog)
 (unload_dialog dcl_id)
(serial-checker)

 )

 

Now it works. Thanks again

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...