Page 1 of 1

Application Trial

Posted: Thu Jul 30, 2009 3:23 pm
by bsouthuk
Hi I want to email my application which is ready for beta testing to a company but want it so that when they click on a button it will let them know they have a 30 day trial.

I want it so that the days count down every day the user opens the applciation. Also, when the 30 day period has expired it will let the user know and not open the next stack.

Is there a simple script I can use for this.

your help is most appreciated.

Thanks
Daniel

Posted: Sat Aug 01, 2009 5:15 am
by shadowslash
Hi bsouthuk,

I'm at school right now so I'm gonna make this script from my head. Try this one out and tell me if it gives you the desired result that you want. Take note that this doesn't rely on the computer's date but through the number of times the program has been run. I still can't think through how to implement the date because as I said earlier, I'm not at home with a Rev. If ever I get the chance to check back once I got to use Rev again, I'll try to correct it (in case it has errors).

Code: Select all

local trialCount

on preOpenStack
   put queryRegistry("HKEY_CURRENT_USER\Software\Your Program\trialCountdown") into trialCount
   if trialCount is not a number then
      put 30 into trialCount
      if setRegistry("HKEY_CURRENT_USER\Software\Your Program\trialCountdown",trialCount) is not true then
         regError
      end if
   else
      if trialCount is not 0 then put trialCount-1 into trialCount
      if setRegistry("HKEY_CURRENT_USER\Software\Your Program\trialCountdown",trialCount) is not true then
         regError
      end if
   end if
end preOpenStack

on regError
   answer error "Failed to initialize. Please confirm that you have proper rights on this computer." titled "ERROR"
   if the environment is not "development" then quit
end regError

on openStack
   if trialCount is 1 then
      answer info "You only have 1 try left to use this program." titled "Alert"
   else
      if trialCount is 0 then
         answer warning "You've already used this program 30 times. Register it at once or suffer my wrath!" titled "Alert"
         if the environment is not "development" then
            quit
         end if
      else
         answer info "You only have" && trialCount && "tries left to use this program." titled "Alert"
      end if
   end if
end openStack
NOTE:
This script was made for the Windows platform, for MacOS, you can simply modify the code above and point it to an encrypted file instead. (Or wherever Mac platforms store those kind of settings.)

Posted: Sat Aug 01, 2009 11:02 am
by bsouthuk
Thanks so much for this - one silly question though is where do I put the script?

Posted: Mon Aug 03, 2009 12:08 pm
by shadowslash
bsouthuk wrote:Thanks so much for this - one silly question though is where do I put the script?
You put the script into the stack's script. Image Right click on your main stack while in edit mode and select Edit Script from the context menu.