home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1995-12-24 | 5.6 KB | 165 lines |
- Module ShareBan
- -----------------------------------------------------------------------
- ShareWare Banner Handling Routines (version 1.01 24-Dec-95)
- This library contains routines that handle the display of a ShareWare
- start up banner to encourage registrations. It uses a 'User' file in
- the application directory and is based on an idea from Graham Crowe
- in the September 1995 Risc User, page 22 but with some cunning
- additions (I would say that wouldn't I). In particular a registration
- number is encoded into the file and a FN is added to the application
- RunImage which must pass the same number back to disable the banner.
- This prevents anybody with a copy of the registration file generator
- from simply creating their own file as they won't know the code number
- in the original file - assuming of course that only the compressed
- version of your program is distributed....
- -----------------------------------------------------------------------
- Structure of Data used in this module
- Public Methods Supported:
- FN_shell_ShareBan_Init Initialises module
- FNshell_ShareBan_GetUser
- Responses to events raised by other modules
- Private Methods Supported:
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- Public routines..
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- ("*|Start FN_shell_ShareBan_Init
- _shell_ShareBan_Init
- _c_ShareBan_CodeNr% 4
- -P_c_ShareBan_ErrNoTemplate$ = "Template file has been corrupted, exiting...."
- .._c_ShareBan_BannerName$ = "sharebanner"
- 0._m_ShareBan_User$ = "Unregistered"
- 1"_m_ShareBan_WindowHandle% = -1
- shell_ExReg_ShareBan_Loaded
- 7!*|Stop FN_shell_ShareBan_Init
- ;)*|Start PROCshell_ShareBan_ShowBanner
- shell_ShareBan_ShowBanner
- void%
- shell_WindowLoaded( _c_ShareBan_BannerName$ )
- ShareBan_Registered
- B- _m_ShareBan_User$ =
- ShareBan_GetUser
- ShareBan_OpenWindow
- ShareBan_HandleWindow
- HY void%=
- shell_MessageWindow( _c_ShareBan_ErrNoTemplate$,
- shell_GetAppName, "" )
- N(*|Stop PROCshell_ShareBan_ShowBanner
- R$*|Start FNshell_ShareBan_GetUser
- shell_ShareBan_GetUser
- = _m_ShareBan_User$
- V#*|Stop FNshell_ShareBan_GetUser
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- Responses to events raised by other modules..
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- Private module routines
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- j#*|Start PROCShareBan_OpenWindow
- ShareBan_OpenWindow
- shell_CreateWindowStatic( _c_ShareBan_BannerName$, _m_ShareBan_WindowHandle% )
- shell_WindowCentreOnScreen( _m_ShareBan_WindowHandle% )
- shell_OpenWindow( _m_ShareBan_WindowHandle%,
- "Wimp_SetCaretPosition", _m_ShareBan_WindowHandle%, 3, , -1, 0
- "Hourglass_Smash"
- shell_MouseLimit( _m_ShareBan_WindowHandle% )
- 200,20
- u"*|Stop PROCShareBan_OpenWindow
- y%*|Start PROCShareBan_HandleWindow
- ShareBan_HandleWindow
- reply%, poll_blk%, r%
- reply% = 0
- -poll_blk% =
- shell_HeapBlockFetch( 2048 )
- "Wimp_Poll", , poll_blk%
- - reply% = poll_blk%!16:
- mouse click
-
- keypress
-
- poll_blk%!24
-
- 13:reply% = 2
-
- 27:reply% = 1
-
- 17,18:
- A
- poll_blk%!16 = 0
- reply% = 1:
- quit message received
- reply%
- +poll_blk%!0 = _m_ShareBan_WindowHandle%
- "Wimp_CloseWindow", , poll_blk%
- ( "Pointer" )
- reply% = 1
- "Wimp_CloseDown"
- shell_HeapBlockReturn( poll_blk% )
- $*|Stop PROCShareBan_HandleWindow
- !*|Start FNShareBan_Registered
- ShareBan_Registered
- F%, reg%, present%, type%, filelen%
- gap%, testlen%, namelen%
- reg% =
- shell_FileExists(
- shell_GetAppDir + ".User" )
- > type% =
- shell_FileType(
- shell_GetAppDir + ".User" )
- @ filelen% =
- shell_FileLength(
- shell_GetAppDir + ".User" )
- * F% =
- shell_GetAppDir + ".User" )
- namelen% =
- gap% =
- void% =
- void% =
- void% =
- void% =
- 7 testlen% = ( gap% + 1 ) * namelen% + 2 + gap% + 4
- type% <> &FFD
- testlen% <> filelen%
- reg% =
- + _m_ShareBan_User$ =
- ShareBan_GetUser
- shell_GetProgramCodeNr
- 1000 ) <> !_c_ShareBan_CodeNr%
- * _m_ShareBan_User$ = "Unregistered"
- reg% =
- reg% =
- reg% =
- = reg%
- *|Stop FNShareBan_Registered
- *|Start FNShareBan_GetUser
- ShareBan_GetUser
- J%, count%, asc%, user$, len%, gap%, file_handle%
- 2file_handle% =
- shell_GetAppDir + ".User" )
- len% =
- # file_handle%
- gap% =
- # file_handle%
- +_c_ShareBan_CodeNr%?0 =
- # file_handle%
- +_c_ShareBan_CodeNr%?1 =
- # file_handle%
- +_c_ShareBan_CodeNr%?2 =
- # file_handle%
- +_c_ShareBan_CodeNr%?3 =
- # file_handle%
- user$ = ""
- count% = 1
- J% = 1
- gap%
- asc% =
- # file_handle%
- asc% =
- # file_handle%
- user$ +=
- ( asc% )
- count% += 1
- count% > len%
- # file_handle%
- = user$
- *|Stop FNShareBan_GetUser
-