Notifications
Clear all
[Closed] creating a log file error
Mar 27, 2013 8:51 pm
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 "%
" t to:exportlog
for i = 1 to larr.count do format "% % seconds
" larr[i][1] larr[i][2] to:exportlog
format "<--##############################-->
" to:exportlog
close exportlog
)
Thanks!
3 Replies
1 Reply
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 <<