jim_archi4 Posted February 20, 2015 Share Posted February 20, 2015 (edited) I wrote this routine a few years back which allows a secure login to AutoCAD using 3 routines (Login_name) (Log_name_old) originally Log_name and (Warning 2). Basically you type in your password in (login_name) (log_name) evaluates the password and (Warning2) quits you out of AutoCAD if the password is wrong otherwise you proceed to AutoCAD. I have tried to modify the routines by re-writing (Log_name) and adding in (Warning 3 and 4) to allow 3 chances to log in. Generally I think the structure is sound but it's not working properly. I cannot get past the first attempt (count is always 1) and even when I type in the correct password it hangs suggesting it's stuck in the "While" loop. I now get a symbol 1 error after the fist attempt. I know I'm close but needs help. My code is below which are the subroutines. In the Acad.lsp file there is a switch which say if login is required the run these routines. If anyone out there can help I would really appreciate it I have spent many nights trying to make this work. Thanks Jim ;;;------------------------------------------------------------------------- (defun login_name () (se) (setq olderr *error* *error* clyerr ) (if (= "DRAWING1.DWG" (strcase (getvar "dwgname"))) (progn (setq num (load_dialog "wpa")) (new_dialog "wpa" num) (set_tile "tname" "**********") (set_tile "msg2" mess_2) (mode_tile "tname" 2) (logo) (action_tile "accept" "(do_txt)(done_dialog)") (start_dialog) (unload_dialog num) ) ) ) (defun do_txt () (setq logn (get_tile "tname")) ) ;;;------------------------------------------------------------------------- (defun Log_name_old () (setq olderr *error* *error* clyerr ) (setq filename (open "c:/WPA_CAD2014/ser.dat" "r")) (setq Logn_name (read-line filename)) (setq enable_logon (read-line filename));***REMOVE THIS LINE (close filename) (if (= "DRAWING1.DWG" (strcase (getvar "dwgname"))) (progn (IF (/= (strcase LOGN_NAME) (strcase LOGN)) (warning2) ) ) ) ) (defun Log_name () (setq olderr *error* *error* clyerr ) (setq filename (open "c:/WPA_CAD2014/ser.dat" "r")) (setq Logn_name (read-line filename)) (setq enable_logon (read-line filename));***REMOVE THIS LINE (close filename) (setq count 1);;;Initialize counter (While (< count 4) (if (= "DRAWING1.DWG" (strcase (getvar "dwgname"))) (progn (IF (/= (strcase LOGN_NAME) (strcase LOGN)) (progn (cond (( = count 1)(warning3)) (( = count 2)(warning4)) (( = count 3)(warning2)) );close cond );close progn );close if );close progn );close if (set count (+ count 1)) );;;Close While );end file ;;;------------------------------------------------------------------------- (defun Warning2 () (se) (setq olderr *error* *error* clyerr ) ;;;(beep) (setq num (load_dialog "wpa3.dcl")) (new_dialog "wpa3" num) (set_tile "msg2" mess_2) (action_tile "accept" "(done_dialog)") (logo) (start_dialog) (unload_dialog num) (command ".quit" "y") (princ) ) ;;;------------------------------------------------------------------------- (defun Warning3 () (se) (setq olderr *error* *error* clyerr ) ;;;(beep) (setq num (load_dialog "wpa31.dcl")) (new_dialog "wpa31" num) (set_tile "msg2" mess_2) (action_tile "accept" "(done_dialog)") (logo) (start_dialog) (unload_dialog num) (login_name) ;;;(command ".quit" "y") (princ) ) ;;;------------------------------------------------------------------------- (defun Warning4 () (se) (setq olderr *error* *error* clyerr ) ;;;(beep) (setq num (load_dialog "wpa32.dcl")) (new_dialog "wpa32" num) (set_tile "msg2" mess_2) (action_tile "accept" "(done_dialog)") (logo) (start_dialog) (unload_dialog num) (login_name) ;;;(command ".quit" "y") (princ) ) ;;;------------------------------------------------------------------------- Edited March 4, 2015 by SLW210 Added Code Tags Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 20, 2015 Share Posted February 20, 2015 Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
jim_archi4 Posted March 4, 2015 Author Share Posted March 4, 2015 Hi SLW210, I have tried to put the code inside by reading your link however editing doesn't do it, so I wrote a new posting copied and pasted the text selecting the code and pressing the '#' but as you can see in my new post it's the same......SO FRUSTRATING!!!! can you help me Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 4, 2015 Share Posted March 4, 2015 Just type [ c o d e ] at start and [ / c o d e ] at end without spaces Quote Link to comment Share on other sites More sharing options...
SLW210 Posted March 4, 2015 Share Posted March 4, 2015 As BIGAL shows, you can simply add them manually, I fixed it for you this time. I deleted your other thread, no need to double post. Quote Link to comment Share on other sites More sharing options...
jim_archi4 Posted March 4, 2015 Author Share Posted March 4, 2015 Many thanks for your help this time Quote Link to comment Share on other sites More sharing options...
pBe Posted March 5, 2015 Share Posted March 5, 2015 Is this for initial launch of an autocad session? Quote Link to comment Share on other sites More sharing options...
jim_archi4 Posted March 5, 2015 Author Share Posted March 5, 2015 Yes it it only for the first launch when drawing is drawing1.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted March 11, 2015 Share Posted March 11, 2015 We can help you further if we can try what you have now, if you don't mind posting the rest of the code please do so, saves us time trying to figure out what the end result would look like. I think the problem is easy and it would be probably shorter than what you have have now. Quote Link to comment Share on other sites More sharing options...
jim_archi4 Posted March 11, 2015 Author Share Posted March 11, 2015 Ok The balance of the code, in the Acad lisp file is the following and it's triggered by reading an external file "1" run the routine "0" don't run Please not I have manually added the '[' brackets to place code correctly hope it works!!! [(if (= enable_logon "1") (progn (login_name) (log_name) ) )] All the basic code is above as posted previously the (SE) code is irrelevant as it is in all my lisps to and if removed will stll work OK. Below are the DCL codes [WPA.DCL icon : image { fixed_width = true; color = 0; width = 20; height = 7; key = "icon"; } wpa : dialog { layout = horizontal; label = "wpa_cad Authoriztation"; initial_focus = "tname"; : cluster { layout = vertical; :boxed_column { label ="Login Password:"; : edit_box { label = "Enter Your Login Password : "; width = 40; key="tname"; } : text { label = " "; alignment = centered; } }//close boxed column // : column { // icon; WPA3.DCL for warning2 icon : image { fixed_width = true; color = 0; width = 20; height = 7; key = "icon"; } wpa3 : dialog { layout = horizontal; label = "wpa_cad Alert!"; : cluster { layout = vertical; : boxed_column { label ="Unauthorised Use:"; : text { label = "Your Password is not ACCEPTED"; alignment = centered; } : text { label = "Unauthorised User...wpa_cad disabled"; alignment = centered; } } :row { fixed_width = true; alignment = centered; :button { key = "accept"; label = "OK"; width = 8; mnemonic = "O"; is_default = true; is_cancel = true; } } : text { key = "msg2"; alignment = centered; } } : column { icon; spacer; // spacer; } } WPA31.DCL for warning 3 icon : image { fixed_width = true; color = 0; width = 20; height = 7; key = "icon"; } wpa31: dialog { layout = horizontal; label = "wpa_cad Alert!"; : cluster { layout = vertical; : boxed_column { label ="Access Denied:"; : text { label = "Your Password is not CORRECT"; alignment = centered; } : text { label = "2 attempts left"; alignment = centered; } } :row { fixed_width = true; alignment = centered; :button { key = "accept"; label = "OK"; width = 8; mnemonic = "O"; is_default = true; is_cancel = true; } } : text { key = "msg2"; alignment = centered; } } : column { icon; spacer; // spacer; } } WPA.DCL32 for warning 4 icon : image { fixed_width = true; color = 0; width = 20; height = 7; key = "icon"; } wpa32: dialog { layout = horizontal; label = "wpa_cad Alert!"; : cluster { layout = vertical; : boxed_column { label ="Access Denied:"; : text { label = "Your Password is not CORRECT"; alignment = centered; } : text { label = "Last attempt"; alignment = centered; } } :row { fixed_width = true; alignment = centered; :button { key = "accept"; label = "OK"; width = 8; mnemonic = "O"; is_default = true; is_cancel = true; } } : text { key = "msg2"; alignment = centered; } } : column { icon; spacer; // spacer; } }] Thank you in advance Quote Link to comment Share on other sites More sharing options...
jim_archi4 Posted March 11, 2015 Author Share Posted March 11, 2015 It still does not work for me I used the "[" you can see it in my code but it does not place it in a separate code section WHY!!!!! ARRRRGHHH Quote Link to comment Share on other sites More sharing options...
SLW210 Posted March 12, 2015 Share Posted March 12, 2015 You have to [noparse] "your code here" [/noparse] Quote Link to comment Share on other sites More sharing options...
pBe Posted March 13, 2015 Share Posted March 13, 2015 Why not just attached the lsp and DCL file. i'm not understanding the DCL code on your post. At the lower right corner Post Quick Reply | Go Advanced | Cancel Help us Help you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.