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 Tools Display Modes
  03 March 2013
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

  03 March 2013
are you closing cf after you create it?
  03 March 2013
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 <<
  03 March 2013
close cf

DOH! Thanks lo!
  03 March 2013
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
Society of Digital Artists

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

All times are GMT. The time now is 10:49 AM.

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