Registration Key (file reading and writing) by Sph!nx4th Dec 2009 6:12
|
---|
Summary A full example on how to create, read and write to a file to setup a simple registration for your game/program. Description It's very basic and for newbies to learn file reading and writing. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com // Registration! (place this at start of app!) CODE BY SPH!NX! GLOBAL ID$ ID$ = "0" IF NOT FIlE EXIST ("registration.dat") MAKE FILE ("registration.dat") if file exist("registration.dat") then delete file "registration.dat" PRINT "" PRINT " Enter Registration Key " INPUT " > ", ID_input$ IF ID_input$ = "T34M-D3V3D-1Z-C001" THEN ID$ = "T34M-D3V3D-1Z-C001" IF ID$="T34M-D3V3D-1Z-C001" PRINT " Registration Accepted!" OPEN TO WRITE 1, ("registration.dat") WRITE STRING 1, ID$ wait 1000 CLOSE FILE 1 ELSE PRINT " Registration Failed!" if file exist("registration.dat") then delete file "registration.dat" WAIT 2000 END ENDIF ENDIF IF FILE EXIST ("registration.dat") OPEN TO READ 1, ("registration.dat") READ STRING 1, ID$ CLOSE FILE 1 IF ID$ = "T34M-D3V3D-1Z-C001" GOTO _proceed ELSE PRINT "" PRINT " Illegal registration key used!" WAIT 2000 END ENDIF ENDIF _proceed: |