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