1<% 2 3public const cnRefreshTime = 5 ' refresh time in seconds 4 5' filename for file with all pictures and file containing the name of the current picture 6public const csFilePicture= "picture.txt" 7public const csFileCurrent= "currpic.txt" 8 9' constants for file-access 10const ForReading = 1 11const ForWriting = 2 12 13' new-line delimiter 14Dim FILE_LINE_DELIMITER 15FILE_LINE_DELIMITER = vbCRLF 16 17'/** 18' * Get data from file using a given separator. 19' */ 20function File_getDataVirtual( sFilename, sServerPath, sSeperator ) 21 call Err.Clear() 22 23 Dim aFSObject, sServerFileName 24 25 Set aFSObject = CreateObject("Scripting.FileSystemObject") 26 sServerFileName = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName ) 27 28 File_getDataVirtual = "" 29 if Err.Number = 0 then 30 File_getDataVirtual = File_read( sServerFileName ) 31 If Not IsNull(File_getDataVirtual) Then 32 File_getDataVirtual = Replace( File_getDataVirtual, FILE_LINE_DELIMITER, sSeperator) 33 File_getDataVirtual = Split( File_getDataVirtual, sSeperator) 34 End If 35 end if 36end function 37 38'/** 39' * Get data from a file 40' */ 41function File_read( sFilename ) 42 call Err.Clear() 43 44 Dim aFSObject, aStream 45 46 Set aFSObject = CreateObject( "Scripting.FileSystemObject" ) 47 Set aStream = aFSObject.OpenTextFile( sFilename, ForReading ) 48 49 while not aStream.AtEndOfStream 50 File_read = File_read + aStream.ReadLine + FILE_LINE_DELIMITER 51 wend 52 53 aStream.Close 54end function 55 56'/** 57' * Get data from a file given by filename and virtual pathname 58' */ 59Function File_readVirtual(sFileName, sServerPath) 60 call Err.Clear() 61 62 Dim aFSObject, sServerFileName 63 64 Set aFSObject = CreateObject("Scripting.FileSystemObject") 65 sServerFileName = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName ) 66 67 File_readVirtual = "" 68 if Err.Number = 0 then 69 File_readVirtual = File_read( sServerFileName ) 70 end if 71End Function 72 73'/** 74' * Write data to a file 75' */ 76function File_write( sFileName, sText ) 77 call Err.Clear() 78 79 Dim aFSObject, aFile 80 81 Set aFSObject = CreateObject( "Scripting.FileSystemObject" ) 82 if Err.Number = 0 then 83 Set aFile = aFSObject.CreateTextFile( sFileName, TRUE ) 84 if Err.Number = 0 then 85 aFile.Write( sText ) 86 aFile.Close 87 end if 88 end if 89 90 File_write = ( Err.Number = 0 ) 91end function 92 93'/** 94' * Write data to a file given by filename and virtual pathname 95' */ 96function File_writeVirtual( sFileName, sServerPath, sText ) 97 call Err.Clear() 98 99 Dim aFSObject, aServerFile 100 101 Set aFSObject = CreateObject( "Scripting.FileSystemObject" ) 102 aServerFile = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName ) 103 104 If Err.Number = 0 Then 105 File_writeVirtual = File_write( aServerFile, sText ) 106 else 107 File_writeVirtual = false 108 End If 109end function 110%>