So I'm making an exporter in maxscript
I have troubles writing the export path into a .txt file and reading it.
This is what I have:
----------------------------------------------------------------------------------
label labelExportFolder "Export folder" pos:[10,600]
edittext folderPathTxt "" pos: [10,620] width:140
button btnBrowse "..." pos: [160,620]
on btnBrowse pressed do
(
Global MyPath = "" -- this stores the path in string form
local dir = getSavePath caption:"path..."
if (dir != undefined) do ( folderPathTxt.text = dir )
append MyPath folderPathTxt.text as string -
maxRootDir = getdir #maxroot
global TextFileName = (maxRootDir +"\\ExportPath.txt")
-- if file doesn't exist, create one and store MyPath in it
if doesFileExist (maxRootDir +"\\ExportPath.txt") == false do
(
global TextFile = (createFile TextFileName)
format MyPath to:TextFile
close TextFile
)
-- if the .txt file does exist, read it and store the content in MyPath and put it in the edittext
if doesFileExist (maxRootDir +"\\ExportPath.txt") == true do
(
local replaceTxt = ""
MyPath = (openFile TextFileName mode:"r+")
folderPathTxt.text = MyPath
close TextFile
)
)
-------------------------------------------------------------------------------------------
So I hope it's clear what I'm trying to do.
I'm not sure whether I should use the TxtFile or TextFileName
when i do "close TextFile" or "MyPath = (openFile TextFileName mode:"r")"
I guess the TextFileName just contains the path to the file that is created,
but I don't know what the TextFile variable is exactly. I'm confused
miauu · 2015-12-24