SaveText to File
When I evaluate this script and hit save then type in "Cool" it saves the file correctly as "Cool.txt" but when I typed in "Cool.txt" it saves the file as "Cool.txt.txt"
Not sure where its bugging out here. Let me know if anyone has the solution.
Thank you.
fn saveTaskList SaveLocation = ( if (substring SaveLocation 1 (SaveLocation.count-4))==".txt" then ( TaskList = createFile SaveLocation ) else ( TaskList = createFile (SaveLocation+ ".txt") ) format "Hi" to:TaskList ) rollout rlSaveText "Save Text" ( local SaveLocation = undefined button btnSave "Save" on btnSave pressed do ( SaveLocation = getSaveFileName caption:"Save Task List" types:"Text Documents(*.txt)|All|All Files(*.*)|" if SaveLocation != undefined then ( saveTaskList SaveLocation ) ) ) createDialog rlSaveText 150 150
Comments
Just replace substring
Just replace
substring SaveLocation 1 (SaveLocation.count-4)
withsubstring SaveLocation (SaveLocation.count-3) SaveLocation.count
and it should be all ok.Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters