home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
utilities
/
utilsd
/
drawpersp
/
!DrawPersp
/
OLELib
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1995-02-02
|
6KB
|
138 lines
Module OLE
-----------------------------------------------------------------------
OLE Handling Routines
-----------------------------------------------------------------------
Public Methods Supported:
_shell_OLELibInit Initialises module
shell_OLELinkFile Sets up the OLE link for the specified file
shell_OLEDeLinkFile Breaks the link to the file
shell_OLEScanLinkedFiles Called during the null event poll
shell_OLEGetNrOfLinkedFiles Returns nr of files currently linked
shell_OLEInProgress Returns TRUE if OLE in progress
REM Private Methods Supported:
None
*|Start FN_shell_OLELibInit
_shell_OLELibInit
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
*|Stop FN_shell_OLELibInit
0!*|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...
7@ G_OLE_DataBlock% =
shell_HeapBlockFetch( OLE_RecLength% )
Initialise data block (write end of data marker words)
9* G_OLE_DataBlock%!00 = OLE_EndOfData%
:* G_OLE_DataBlock%!04 = OLE_EndOfData%
;* G_OLE_DataBlock%!08 = OLE_EndOfData%
<* 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..
ES G_OLE_DataBlock% =
shell_HeapBlockExtend( G_OLE_DataBlock%, OLE_RecLength% )
FQ loc_newrecord% = G_OLE_DataBlock% + ( G_OLE_NrOfFiles% * OLE_RecLength% )
HE loc_newrecord%!00 =
shell_HeapBlockFetch(
( file_name$ ) + 1 )
IE loc_newrecord%!04 =
shell_HeapBlockFetch(
( user_FN$ ) + 1 )
J) $( loc_newrecord%!00 ) = file_name$
K' $( loc_newrecord%!04 ) = user_FN$
LD loc_newrecord%!08 =
shell_FileGetDateStamp( file_name$ )
M loc_newrecord%!12 = 0
O@ !( loc_newrecord% + OLE_RecLength% + 00 ) = OLE_EndOfData%
P@ !( loc_newrecord% + OLE_RecLength% + 04 ) = OLE_EndOfData%
Q@ !( loc_newrecord% + OLE_RecLength% + 08 ) = OLE_EndOfData%
R@ !( loc_newrecord% + OLE_RecLength% + 12 ) = OLE_EndOfData%
G_OLE_NrOfFiles% += 1
99, "Unable to find file '" + file_name$ + "'"
^ *|Stop PROCshell_OLELinkFile
b#*|Start PROCshell_OLEDeLinkFile
shell_OLEDeLinkFile( file_name$ )
OLE_index%, curr_file_name$
OLE_index% = 0
shell_FileExists( file_name$ )
l: curr_file_name$ = $( G_OLE_DataBlock%!OLE_index% )
n(
curr_file_name$ = file_name$
pG
shell_HeapBlockReturn( G_OLE_DataBlock%!( OLE_index% + 00 ))
qG
shell_HeapBlockReturn( G_OLE_DataBlock%!( OLE_index% + 04 ))
fix_ptr% = OLE_index%
wc G_OLE_DataBlock%!( fix_ptr% + 00 ) = G_OLE_DataBlock%!( fix_ptr% + 00 + OLE_RecLength%)
xc G_OLE_DataBlock%!( fix_ptr% + 04 ) = G_OLE_DataBlock%!( fix_ptr% + 04 + OLE_RecLength%)
yc G_OLE_DataBlock%!( fix_ptr% + 08 ) = G_OLE_DataBlock%!( fix_ptr% + 08 + OLE_RecLength%)
zc 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