Jim Claypool Tip:

To protect a file from loading, put this at the top.
(while (not (equal (getstring “\nPassword: “) “PASSWORD”)))

To protect a certain function do this.
Defun C:FUNCTION_NAME ()
(while (not (equal (getstring “\nPassword: “) “PASSWORD”)))
….
Do your stuff here
….
)
Change PASSWORD to suit.

And now You will have to compile the lsp to fas to protect it.

Another Option:
(defun c:ddpass (/ pass msg inputvalue tmp arq_tmp1 dcl_id )
(setq pass "igal") ;;;;;; Here you Put your password
(while (/= pass T)(progn
(defun errdia (msg)
(set_tile "error" msg)
nil
)
(defun xxx ()
(if (= pass inputvalue)

(progn (done_dialog)(setq pass T)
(princ "\nPassword correct! You are Wellcome!"))
(progn
(set_tile "Password2" "")
(mode_tile "Password2" 2)
(errdia "Password not correct!")
)
)
)
(princ "\r*********************************************************************")
(defun gravar ()
(write-line "pass : dialog {label = \"Password...\";
: edit_box {
key = \"Password2\";
password_char = \"*\";
is_default = true;}
ok_only;
: errtile {
width = 30;
alignment = right ;

} }"
arq_tmp2)
)
(setq tmp (strcat (getenv "temp") "\\_.dcl"))
(setq arq_tmp2 (open tmp "w"))
(write-line "" arq_tmp2)
(close arq_tmp2)
(setq arq_tmp2 (open tmp "a"))
(gravar)
(close arq_tmp2)
(setq dcl_id (load_dialog tmp))
(if (not (new_dialog "pass" dcl_id))
(exit)
)
(mode_tile "Password2" 2)
(action_tile
"Password2"
"(setq inputvalue (get_tile \"Password2\"))
(xxx)
"
)
(action_tile
"accept"
"(setq inputvalue (get_tile \"Password2\"))
(xxx)
"
)
(action_tile
"cancel"
"(setq inputvalue nil)
(xxx)
"
)
(errdia "Enter the password to unlock.")
(start_dialog)
(unload_dialog dcl_id)

)
)
(princ)
)
(c:ddpass)

Advertisements