I have a problem with a function that works in max2011 alright, but fails in 2012. And I am unsure where the actual error is. All I am trying to do is write a password into a file, then open the file again and check the password. Pretty straight forward process:
fn register =
pw = "I am the password" -- some password
regfile = createfile (getDir #temp + "\\license.tmp") -- create a temporary license file
format pw to:regfile -- write the password into the file
encryptfile (getDir #temp + "\\license.tmp") (getDir #temp + "\\license.lic") 1234567 -- make an encrypted version
close regfile -- close the temporary file..
deletefile (getDir #temp + "\\license.tmp") -- ..so that it can be deleted
fn isregistered =
registered = false-- create boolean registered
if (doesfileexist (getDir #temp + "\\license.lic")) then-- check for file
checkfile = openencryptedfile (getDir #temp + "\\license.lic") 1234567 -- open the license file
password = readline checkfile -- read the first line, containing the password
close checkfile -- close the file again
if password == "I am the password" then registered = true -- if it matches, registering worked
if registered then messagebox "hooray, it works"
So if you run the code in max 2011 you should get a messagebox saying "hooray, it works". One would think the same applies to max 2012, but there I get:
-- Error occurred in isregistered(); filename: D:\Projekte\3dsmax\scripts\registertest.ms; position: 826; line: 20
-- registered: false
-- checkfile: <File:C:\Users\David\AppData\Local\Autodesk\3dsMax\2012 - 64bit\enu\temp\license.lic>
-- password: undefined
-- Runtime error: Read past end of file
What could be the explanation? It must be something 2012 specific, I guess.