home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1995-10-18 | 6.1 KB | 146 lines |
- Module OLE
- -----------------------------------------------------------------------
- OLE Handling Routines (version 1.03 18-Oct-95)
- -----------------------------------------------------------------------
- Public Methods Supported:
- FN_shell_OLELib_Init Initialises module
- PROCshell_OLELinkFile Sets up the OLE link for the specified file
- PROCshell_OLEDeLinkFile Breaks the link to the file
- PROCshell_OLEScanLinkedFiles Called during the null event poll
- PROCshell_OLEGetNrOfLinkedFiles Returns nr of files currently linked
- PROCshell_OLEInProgress Returns TRUE if OLE in progress
- Responses to events raised by other modules
- PROCshell_DoOLEHandling
- REM Private Methods Supported:
- None
- *|Start FN_shell_OLELib_Init
- _shell_OLELib_Init
- Set up global constants for this module
- OLE_RecLength% = 16
- OLE_EndOfData% = -1
- Set up global variables for this module
- G_OLE_DataBlock% = 0
- G_OLE_NrOfFiles% = 0
- Format of data block is:
- +00 ptr to filename
- +04 ptr to FN name
- +08 low word file datestamp
- +12 hi word file datestamp (not used at the moment)
- ...
- +nn
- +nn
- +nn
- shell_ExReg_OLELib_Loaded
- *|Stop FN_shell_OLELib_Init
- 5!*|Start PROCshell_OLELinkFile
- shell_OLELinkFile( file_name$, user_FN$ )
- loc_newrecord%
- G_OLE_DataBlock% = 0
- First time it has been called, so initialise OLE data block...
- <@ G_OLE_DataBlock% =
- shell_HeapBlockFetch( OLE_RecLength% )
- Initialise data block (write end of data marker words)
- >* G_OLE_DataBlock%!00 = OLE_EndOfData%
- ?* G_OLE_DataBlock%!04 = OLE_EndOfData%
- @* G_OLE_DataBlock%!08 = OLE_EndOfData%
- A* G_OLE_DataBlock%!12 = OLE_EndOfData%
- First check that file to be linked actually exists..
- shell_FileExists( file_name$ )
- Make space for new OLE data and write new data, terminating OLE data block
- with 'end_of_data' marker words..
- JS G_OLE_DataBlock% =
- shell_HeapBlockExtend( G_OLE_DataBlock%, OLE_RecLength% )
- KQ loc_newrecord% = G_OLE_DataBlock% + ( G_OLE_NrOfFiles% * OLE_RecLength% )
- ME loc_newrecord%!00 =
- shell_HeapBlockFetch(
- ( file_name$ ) + 1 )
- NE loc_newrecord%!04 =
- shell_HeapBlockFetch(
- ( user_FN$ ) + 1 )
- O) $( loc_newrecord%!00 ) = file_name$
- P' $( loc_newrecord%!04 ) = user_FN$
- QD loc_newrecord%!08 =
- shell_FileGetDateStamp( file_name$ )
- R loc_newrecord%!12 = 0
- T@ !( loc_newrecord% + OLE_RecLength% + 00 ) = OLE_EndOfData%
- U@ !( loc_newrecord% + OLE_RecLength% + 04 ) = OLE_EndOfData%
- V@ !( loc_newrecord% + OLE_RecLength% + 08 ) = OLE_EndOfData%
- W@ !( loc_newrecord% + OLE_RecLength% + 12 ) = OLE_EndOfData%
- G_OLE_NrOfFiles% += 1
- 99, "Unable to find file '" + file_name$ + "'"
- c *|Stop PROCshell_OLELinkFile
- g#*|Start PROCshell_OLEDeLinkFile
- shell_OLEDeLinkFile( file_name$ )
- OLE_index%, curr_file_name$
- OLE_index% = 0
- shell_FileExists( file_name$ )
- q: curr_file_name$ = $( G_OLE_DataBlock%!OLE_index% )
- s(
- curr_file_name$ = file_name$
- uG
- shell_HeapBlockReturn( G_OLE_DataBlock%!( OLE_index% + 00 ))
- vG
- shell_HeapBlockReturn( G_OLE_DataBlock%!( OLE_index% + 04 ))
- fix_ptr% = OLE_index%
-
- |c G_OLE_DataBlock%!( fix_ptr% + 00 ) = G_OLE_DataBlock%!( fix_ptr% + 00 + OLE_RecLength%)
- }c G_OLE_DataBlock%!( fix_ptr% + 04 ) = G_OLE_DataBlock%!( fix_ptr% + 04 + OLE_RecLength%)
- ~c G_OLE_DataBlock%!( fix_ptr% + 08 ) = G_OLE_DataBlock%!( fix_ptr% + 08 + OLE_RecLength%)
- c G_OLE_DataBlock%!( fix_ptr% + 12 ) = G_OLE_DataBlock%!( fix_ptr% + 12 + OLE_RecLength%)
- & fix_ptr% += OLE_RecLength%
- 6
- G_OLE_DataBlock%!fix_ptr% = OLE_EndOfData%
- G_OLE_NrOfFiles% -= 1
- Y G_OLE_DataBlock% =
- shell_HeapBlockExtend( G_OLE_DataBlock%, - OLE_RecLength% )
-
- $ OLE_index% += OLE_RecLength%
- G_OLE_DataBlock%!OLE_index% = OLE_EndOfData%
- "*|Stop PROCshell_OLEDeLinkFile
- !*|Start FNshell_OLEFileStatus
- shell_OLEFileStatus( file_name$ )
- *|Stop FNshell_OLEFileStatus
- (*|Start PROCshell_OLEScanLinkedFiles
- shell_OLEScanLinkedFiles
- OLE_index%, _file_name$, fn_name$, void%
- new_date_stamp%, old_date_stamp%
- Call a user defined FN if any of the files in the OLE 'watching'
- list have changed their datestamp since the last time they
- were scanned. This routine should be called every 1 or 2 seconds
- by the PollIdle handler of a wimp application.
- OLE_index% = 0
- shell_OLEInProgress
- G_OLE_DataBlock%!OLE_index% <> OLE_EndOfData%
- @
- Note '_file_name$' is used so that crunching the BASIC
- >
- program does not change the name of the variable (as
-
- it is EVALuated later)
- 6 _file_name$ = $( G_OLE_DataBlock%!OLE_index% )
- = old_date_stamp% = G_OLE_DataBlock%!( OLE_index% + 8 )
- @ new_date_stamp% =
- shell_FileGetDateStamp( _file_name$ )
- .
- new_date_stamp% <> old_date_stamp%
- ? G_OLE_DataBlock%!( OLE_index% + 8 ) = new_date_stamp%
- = fn_name$ = $( G_OLE_DataBlock%!( OLE_index% + 4 ) )
- 9 void% =
- ( "FN" + fn_name$ + "( _file_name$ )")
-
- $ OLE_index% += OLE_RecLength%
- '*|Stop PROCshell_OLEScanLinkedFiles
- )*|Start FNshell_OLEGetNrOfLinkedFiles
- shell_OLEGetNrOfLinkedFiles
- = G_OLE_NrOfFiles%
- (*|Stop FNshell_OLEGetNrOfLinkedFiles
- !*|Start FNshell_OLEInProgress
- shell_OLEInProgress
- G_OLE_NrOfFiles% > 0
- *|Stop FNshell_OLEInProgress
- #*|Start PROCshell_DoOLEHandling
- shell_DoOLEHandling
- shell_OLEInProgress
- shell_OLEScanLinkedFiles
- "*|Stop PROCshell_DoOLEHandling
-