Actually, by watching the variable in the debugger, Director does add 30
days to the current date.  I was happy about that, because it saves on
code.  Is that what you meant?

I'm not to concerned about hackers, if they think my program is that
great, I'll be amazed...

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Howdy-Tzi
Sent: Thursday, May 30, 2002 9:06 AM
To: [EMAIL PROTECTED]
Subject: Re: <lingo-l> Expiration Date


At 08:22 -0700 05/30/2002, Rozan wrote:

>I'm trying to write my very first lingo script, so I am a newbie.  The 
>part of the script that is causing problems (I think)... :
>     gSetDate = the systemDate + 30
>     setPref ("Expiry.txt"), gSetDate
>
>Do I need to make a variable to hold the value of "systemDate + 30", or

>can that go directly into setPref?

Putting it into a variable's not a bad step, because you can set a 
breakpoint in your code and step through with the Debugger, to see if 
what's happening is what you think is happening.

You've got a small problem in that what you think you're doing with 
the systemDate (probably) isn't what's actually going on. The 
systemDate is returned as a date object, so adding 30 to it isn't a 
meaningful operation for Director.

To begin you would probably want to see if the expiration pref file 
was even there. If it is, you need to check the current date against 
that. If it's not, you need to make your 30-day timeout.

Here's one possibility:

   sDate = getPref ( "expiry" )
   if voidP ( sDate ) then
     dExpDate = the systemDate
     if dExpDate.month = 12 then
       dExpDate.month = 1
       dExpDate.year = dExpDate.year + 1
     else
       dExpDate.month = dExpDate.month + 1
     end if
     sDate = string ( dExpDate )
     setPref ( "expiry", sDate )
   end if
   dDate = value ( sDate )
   if the systemDate > dDate then
     ALERT "Your one-month trial is over."
     HALT
   end if

...The above, when it's called, looks for a file called "expiry" in a 
Prefs folder alongside the program. If it's not there, it writes one 
and stuffs the value it has written into the sDate variable.

Otherwise it reads the file's contents into the sDate variable.

Either way, sDate now has a string value of a date object in it, and 
when that gets passed through the value filter and plugged into the 
dDate object, it's a recognizable date object for Director.

Note I test the validity of the month -- you can't go over 12, of 
course, and Director appears to lack an "odometer" style function 
that would automatically increment the year whenever the month value 
rolled over. That's why I tested the month -- for specific days it 
gets too inconsistent, what with those odd 30s, 31,s 28s and 
occasional 29s.

Of course when you compare this to what date calcs used to be like 
before Dir7, this is really cake.

ANYway, hope this helps. Note, BTW, that a clever hacker will simply 
delete the expiry file from the Prefs folder. This is like the lock 
on your kid sister's diary -- a nuisance, a token that keeps honest 
people honest. If you really want to become a security nut you can 
try lots of alternative methods, none of which will offer a 100 
percent guarantee of success, all of them considerably more 
complicated.

To offer a suggestion consistent with my nom de plume, where security 
is concerned, practice nonattachment to perfection.

-- 

              Warren Ockrassa | http://www.nightwares.com/
  Director help | Free files | Sample chapters | Freelance | Consulting
        Author | Director 8.5 Shockwave Studio: A Beginner's Guide
                    Published by Osborne/McGraw-Hill
         http://shop.osborne.com/cgi-bin/osborne/0072195622.html
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]).
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to