>>I don't know how to check preference during application start up each time.
Where the call goes? which FN?
Can I save serial number in preference resource file?
How do I check serial number each time when my application launches by user.
Can I name "Preference resource" something else?<<
Whew. It looks as if your first batch of respondents got so wrapped up in
answering the hard parts of your question, they leapt over the easy parts.
#1 with few exceptions, you can give your files any name you like so long as
you remember to tell the application what name to look for. In fact, as I was
pasting into this form I discovered a name I'd forgotten to change. WHOOPS!!!
#2 you're doing the right thing by putting owner-specific material in the
prefs file, assuming this is a copy-protection issue. Most ordinary computer
users never set foot in their System folder and would never think of copying
the prefs along with the application.
#3 your program presumably has some stuff that executes only at startup--
setting up windows, reading default data etc, functions called _before_ you go
into the HANDLEEVENTS loop. Mine tend to go like this:
LOCAL FN getGoing
oldDepth = SYSTEM(_crntDepth)
IF oldDepth <> 8 THEN FN fixColors
'snip, snip--read arrays & defaults, including default prefs
FN startingValues 'function also called by "New" command
prefsVol% = SYSTEM(_sysVol)
LONG IF SYSTEM(_sysVers) > 699
prefsVol% = FOLDER("Preferences",prefsVol%)
END IF
FN readPrefs
FN initializeWindow
quickflag = 0
howmany = 1
whatToDo = FINDERINFO (howmany, currentGame$, type&, gameVol%)
SELECT
CASE currentGame$ = "Palace Prefs"
quickflag = 1
'snip, snip--if user by some freak of chance double-clicked prefs file
'go into application & open new document
CASE howmany > 0
'snip, snip--read values for saved document clicked in Finder
CASE ELSE
'else = user went straight into application--open new file
END SELECT
IF regName$ <> "" THEN regName$ = FN stripSpaces$(regName$)
'in my code, player name is written into prefs
FN newRoom(newPlace) 'finally, put text & picts into window
IF quickflag THEN FN showPrefs
'optional extra--if player went into application by clicking on prefs
file
'now open prefs window
END FN
The readPrefs function goes like this (I just use a data file, change as need
for resources):
LOCAL FN readPrefs
ON ERROR FN writePrefs
OPEN "I",2,"Palace Prefs",,prefsVol%
READ #2,mouseNavPref,dblClickPref,autoSavePref,regPref
READ #2,regName$;32
CLOSE #2
ON ERROR FN handleError
END FN
The ON ERROR detour simply ensures that if the program can't read the prefs--
say, if it's just been installed & there isn't a prefs file yet--the program
creates one using default values. So that's where you put in your serial# info
and anything else you deem necessary for copy protection. Mine, being low-
budget games, have an easy out: even if the pirates know enough to copy the
prefs file, they'll sooner or later open the registration window, try to
change the user name without knowing the code for the new name... and thereby
deregister themselves ;-)
Oh yes, and then, when user quits, go back and _write_ the prefs. It's
entirely up to you whether you want to write to the prefs file every time a
preference is changed, or just hold on to them until program quits; for me it
seemed safer not to hop back and forth between two different locations
(application and system folders).