home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 October / VPR0210A.ISO / OPENOFFICE / f_0093 / common.inc
Text File  |  2000-09-18  |  3KB  |  110 lines

  1. <%
  2.  
  3. public const cnRefreshTime  = 5    ' refresh time in seconds
  4.  
  5. ' filename for file with all pictures and file containing the name of the current picture
  6. public const csFilePicture= "picture.txt"
  7. public const csFileCurrent= "currpic.txt"
  8.  
  9. ' constants for file-access
  10. const ForReading    =  1
  11. const ForWriting    =  2
  12.  
  13. ' new-line delimiter
  14. Dim FILE_LINE_DELIMITER
  15. FILE_LINE_DELIMITER = vbCRLF
  16.  
  17. '/**
  18. ' * Get data from file using a given separator.
  19. ' */
  20. function 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
  36. end function
  37.  
  38. '/**
  39. ' * Get data from a file
  40. ' */
  41. function 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
  54. end function
  55.  
  56. '/**
  57. ' * Get data from a file given by filename and virtual pathname
  58. ' */
  59. Function 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
  71. End Function
  72.  
  73. '/**
  74. ' * Write data to a file
  75. ' */
  76. function 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 )
  91. end function
  92.  
  93. '/**
  94. ' * Write data to a file given by filename and virtual pathname
  95. ' */
  96. function 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
  109. end function
  110. %>