Readline with max 2012

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  07 July 2011
Readline with max 2012

Hi guys

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"		
       )	
       
       register()
       isregistered()


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
       --  Frame:
       --   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.

thanks, David
 
  07 July 2011
Originally Posted by Wheiraucher: Hi guys

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
)



i guess it's because you try to encrypt your file before you closed it
swap that two lines i marked bold in the quote and it should work
__________________

PowerPreview: High Quality Nitrous Previews for 3ds Max 2012|2013|2014

[ Free Download (ScriptSpot) ]

Home of The Frogs | Online Portfolio
 
  07 July 2011
Wow. that solved the error. Thanks a lot!!! I am glad that the solution is so simple (in terms of additional scripting work).

I still don't understand why max2012 reacts different to the script then 2011, but hey, who cares, it is working, now.

thanks again, David
 
  07 July 2011
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 06:11 AM.


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