creating a log file error

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2013   #1
creating a log file error

I have a script that imports files and writes to a log file. If the log file does not exist it gets created

			
local exportfilelog = txt_dir.text + "\\importlog.txt"
local importFileList = txt_dir.text + "\\importFileList.txt"
if doesFileExist exportfilelog == false then cf = createFile exportfilelog


It creates the file OK but when I try to write to it, it errors telling me the file doesn't exist. It works on the second pass because the file already exists. What do I have to do to make max see the newly created file on the first go-round?

			
fn writetolog dir larr fileLog=
(				
local t = localtime							
local exportlog = openfile fileLog mode:"a"
format "%\n" t to:exportlog
for i = 1 to larr.count do format "% % seconds\n" larr[i][1] larr[i][2] to:exportlog
format "<--##############################-->\n" to:exportlog	
close exportlog
)


Thanks!
__________________
www.davetyner.com
 
Old 03 March 2013   #2
are you closing cf after you create it?
 
Old 03 March 2013   #3
Originally Posted by lo: are you closing cf after you create it?


like this? Still errors


			if doesFileExist exportfilelog == false then
				( 
					cf = createFile exportfilelog
					close exportfilelog
				)

-- >> MAXScript Rollout Handler Exception:
-- Runtime error: FileStream cannot create: C:\Plant 3D Models\OriginalModels\importlog.txt <<
__________________
www.davetyner.com
 
Old 03 March 2013   #4
close cf


DOH! Thanks lo!
__________________
www.davetyner.com
 
Old 03 March 2013   #5
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:53 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.