PDA

View Full Version : Changing file attributes with lisp



pcsyoga
2004-06-10, 03:30 PM
Is there a way I can change the attribute of a file to read-only with lisp?

Ed Jobe
2004-06-10, 03:39 PM
Its built into vba, but with lisp, you can use DOSlib from www.mcneel.com. Use the dos_attrib command.

stig.madsen
2004-06-10, 04:08 PM
... or write your own,


(defun SetRO (/ afile fso ofile ro)
(cond
((and (setq aFile (getfiled "" "" "" 4))
(setq fso (vlax-create-object "Scripting.FilesystemObject"))
(setq oFile (vlax-invoke fso 'GetFile aFile))
)
(vlax-put-property oFile 'Attributes (setq ro (- 1 (logand 1 (vlax-get-property oFile 'Attributes)))))
(princ (strcat "File set to " (nth ro '("Read-write" "Read-only"))))
(vlax-release-object oFile)
(vlax-release-object fso)
)
)
(princ)
)

pcsyoga
2004-06-10, 04:22 PM
Thanks everyone, Stig had what I was looking for.

stig.madsen
2004-06-11, 11:44 AM
Don't forget Robert McNeel has what you are looking for. I just thought it'd be more fun to write one.

Ed Jobe
2018-08-28, 02:38 PM
If you're referring to McNeel, I provided you a link in post #2.