PDA

View Full Version : Using LISP and/or Visual LISP to find something



mikelf
2008-02-01, 05:42 PM
I'm trying to create a LISP file by writing Visual LISP and LISP.

I want it to find a key in the Windows registry, and if it doesn't find it, then return nil.
If it does find it, change the key.

Here is what I have so far, and it works. My probilem is the part that says "CADWorx 2007". I want it to find this key, and if it doesn't, then return nil, but if it does find it, use the code below to change the key. Then I want it to search for the same thing, except it says "CADWorx 2008". If it finds it, change the key (using the code below),and if it doesn't find it, then return nil.



(defun C:test ()


(vl-registry-write "HKEY_USERS\\S-1-5-21-1794388629-2076409663-1235820382-4565\\Software\\COADE, Inc.\\CADWorx 2007\\Plant\\Settings"
"Configuration 17" "J:/CAD/CADWorx System Config Files/test.cfg")

)


Any help is greatly appreciated.


Moderator Note:

How to use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)

mikelf
2008-02-01, 08:33 PM
Well, no one I talked to can figure it out.

Here's what I have done now:


(defun C:test ( / |reg-key1| |reg-key2|)

;_we are going to program the first key path to |reg-key1|
(SETQ |reg-key1|
(STRCAT "HKEY_USERS\\S-1-5-21-1794388629-2076409663-1235820382-4565\\Software\\COADE, Inc.\\CADWorx 2007\\Plant\\Settings"
) ;_ end of STRCAT
) ;_ end of setq

;_we are going to program the second key path to |reg-key2|
(SETQ |reg-key2|
(STRCAT "HKEY_USERS\\S-1-5-21-1794388629-2076409663-1235820382-4565\\Software\\COADE, Inc.\\CADWorx 2008\\Plant\\Settings"
) ;_ end of STRCAT
) ;_ end of setq

;_we are going to insert |reg-key1| into Windows' registry
(vl-registry-write |reg-key1|
"Configuration 17" "J:/CAD/CADWorx System Config Files/EnCana.cfg"
) ;_writes variable to the set registry key

;_we are going to insert |reg-key2| into Windows' registry
(vl-registry-write |reg-key2|
"Configuration 17" "J:/CAD/CADWorx System Config Files/EnCana.cfg"
) ;_writes variable to the set registry key

(princ)

)


Moderator Note:

How to use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)

CAB2k
2008-02-01, 09:05 PM
Something like this doesn't work?

(defun C:test ()

(defun reg_updt (target)
(if
(null
(vl-registry-read
(strcat "HKEY_USERS\\S-1-5-21-1794388629-2076409663-1235820382-4565\\Software\\COADE, Inc.\\"
target "\\Plant\\Settings")))
nil
(vl-registry-write (strcat "HKEY_USERS\\S-1-5-21-1794388629-2076409663-1235820382-4565\\Software\\COADE, Inc.\\"
target "\\Plant\\Settings")
"Configuration 17" "J:/CAD/CADWorx System Config Files/test.cfg")
)
)

(setq result1 (reg_updt "CADWorx 2007"))
(setq result2 (reg_updt "CADWorx 2008"))

(princ)
)