Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to append to textfile and record the date variable (code needs checking)

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
258 Views, 2 Replies

How to append to textfile and record the date variable (code needs checking)

I have forgotten how to append I’m assuming its not write-line but append line could somebody confirm this.

 

And also

 

I’m having trouble recording the date variable… I keep getting error bad argument type stringp nil

		; Appends usage count by DATE long variable...
		(setq g(open "C:/ICT/AutoCAD_Architecture_suite_2012/CUSTOM/WOOD Clones/PEN/USSAGELOG.PEN" "w"))
		(setq MYDATE DATE)
		(write-line MYDATE g)

		; AS ABSOLUTE LAST WE NEED TO CLOSE THE TEXTFILE...
		(close g)

I have the following code snippet I’m trying to append the file named USAGELOG.TXT to record the date of executions

 

Tags (1)
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Maybe this change "w" to "a"

 

(setq g(open "C:/ICT/AutoCAD_Architecture_suite_2012/CUSTOM/WOOD Clones/PEN/USSAGELOG.PEN" "w"))

 

(setq g(open "C:/ICT/AutoCAD_Architecture_suite_2012/CUSTOM/WOOD Clones/PEN/USSAGELOG.PEN" "a"))

 

Southie

Message 3 of 3
Shneuph
in reply to: Anonymous

Changing 'w' to 'a' appends the file instead of overwriting.  If you want to append lines in the file you'll have to read the entire file and save them to variables.  Then append them with code and write everything back to the file.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost