CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 07-11-2011, 12:22 PM   #1
Wheiraucher
3dhippie
 
Wheiraucher's Avatar
portfolio
David Shelton
3d generalist
Mainz, Germany
 
Join Date: Jul 2005
Posts: 360
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:
Code:
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:

Code:
-- 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
 
Old 07-11-2011, 01:01 PM   #2
spacefrog
Frog of the posts
 
spacefrog's Avatar
Josef Wienerroither
Freelance
Vienna, Austria
 
Join Date: Sep 2002
Posts: 2,457
Quote:
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
 
Old 07-11-2011, 01:08 PM   #3
Wheiraucher
3dhippie
 
Wheiraucher's Avatar
portfolio
David Shelton
3d generalist
Mainz, Germany
 
Join Date: Jul 2005
Posts: 360
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
 
Old 07-11-2011, 01:08 PM   #4
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:43 PM.


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