Because I'm trying to use the same password # (not same password) for 5 different ebooks with the same ESBN (long story short: keeping same password # makes providing password for each ebook a LOT cleaner for the user), I've created two scripts, one that runs at application OPEN, the other at EXIT.----Begin Script run at ebook OPEN----------------------
; This script looks in a file location, safe.txt, for a password written when ebook run previously exited
; if the previously entered password is found, script copies the value to the ANS2000.ini file
MESSAGEBOX('Just entering script at OPEN, iscorrectpassword value: {iscorrectpassword} {linefeed}(1 = system perceives correct password entered, 0 = not set)')
FILEEXIST('XXExists','{tmp}\safe.txt')
IF({XXExists})
FILEREAD('ReadStatus','InfoThatWasRead','{tmp}\safe.txt')
MESSAGEBOX('safe.txt already existed, value in file: {InfoThatWasRead}')
ELSE
FILEWRITE('CreateStatus','{tmp}\AF.txt','ZXZXZXZXZXZXZXZXZXZX')
FILEREAD('ReadStatus','InfoThatWasRead','{tmp}\safe.txt')
MESSAGEBOX('safe.txt did not exist, created it with ZXZXZX value')
ENDIF
IFSTRNOTEQUAL('{InfoThatWasRead}','ZXZXZXZXZXZXZXZXZXZX')
INIWRITE('{InfoThatWasRead}','ANS2000.ini','{esbn}','PasswordE')
MESSAGEBOX('Password written to ANS2000.ini, iscorrectpassword value: {iscorrectpassword} {linefeed}(1 = system perceives correct password entered, 0 = not set)')
ENDIF
----END Script run at ebook OPEN----------------------
----BEGIN Script run at ebook EXIT----------------------
; this script designed to be executed when user is exiting ebook
; This script looks in ANS2000.ini to see if the password was written (to unlock all pages)
; If the password exists in ANS2000.ini (as user is exiting), script copies and stores it to a safe location, safe.txt
; then the script clears the password field in ANS2000.ini
INIREAD('ExitPW','ANS2000.ini','{esbn}','PasswordE')
IFSTRNOTEQUAL('{ExitPW}','')
; ExitPW is not empty; write password to safe.txt to be read next time application OPENS
FILEWRITE('WriteCreateStatus','{tmp}\safe.txt','{ExitPW}')
; FILEREAD('ReadStatus','InfoThatWasRead','{tmp}\safe.txt')
MESSAGEBOX('At Exit, ExitPW (written to safe.txt): {ExitPW}')
; then, clear password field in ANS2000.ini
INIWRITE('','ANS2000.ini','{esbn}','PasswordE')
ENDIF
----END Script run at ebook EXIT----------------------
The scripts perform well, passwords are transferred properly, when correct password is entered, all protected pages "unlock" and are displayed as requested.
When the ebook is re-opened after the password has initially been entered, the password is correctly read from safe.txt, {incorrectpassword} value = 1, at first glance the ebook appears to be "unlocked", but when I click on a navigation button to display a previously protected page (protected without correct password, after correct password entered went to unprotected state in first ebook run), on the 2nd (and subsequent runs) the previously protected pages revert back to protected mode, complete with the personalized HTML conveying message that the user needs to purchase a password.
As you can see in the scripts, I'm reporting the {iscorrectpassword} value, and it reports a value of 1 after the password has been set, on the 2nd running of the ebook. It's interesting because I've HTML coded my navigation buttons to "ghost" when {iscorrectpassword} = 0, and after I've put in the correct password, they correctly go to active / non-ghosted state (even on the 2nd running), but for some reason the Activ Ebook Compiler programming is not responding to the {iscorrectpassword} = 1 value, and is reverting to the protected page state, only on the 2nd and subsequent runnings of the ebook.
Perhaps there's another switch / variable that the protected status refers to? Suggestions? Thank you.