locked
WM 6.5 Reading INI file in HTML RRS feed

  • Question

  • <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>OneLink</title> <SCRIPT LANGUAGE="VBScript"> Function ReadIni( myFilePath, mySection, myKey ) Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Dim intEqualPos Dim objFSO, objIniFile Dim strFilePath, strKey, strLeftString, strLine, strSection Set objFSO = CreateObject( "Scripting.FileSystemObject" ) ReadIni = "" strFilePath = Trim( myFilePath ) strSection = Trim( mySection ) strKey = Trim( myKey ) If objFSO.FileExists( strFilePath ) Then Set objIniFile = objFSO.OpenTextFile( strFilePath, ForReading, False ) Do While objIniFile.AtEndOfStream = False strLine = Trim( objIniFile.ReadLine ) ' Check if section is found in the current line If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then strLine = Trim( objIniFile.ReadLine ) ' Parse lines until the next section is reached Do While Left( strLine, 1 ) <> "[" ' Find position of equal sign in the line intEqualPos = InStr( 1, strLine, "=", 1 ) If intEqualPos > 0 Then strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) ' Check if item is found in the current line If LCase( strLeftString ) = LCase( strKey ) Then ReadIni = Trim( Mid( strLine, intEqualPos + 1 ) ) ' In case the item exists but value is blank Response.Write(ReadIni) If ReadIni = "" Then ReadIni = " " End If ' Abort loop when item is found Exit Do End If End If ' Abort if the end of the INI file is reached If objIniFile.AtEndOfStream Then Exit Do ' Continue with next line strLine = Trim( objIniFile.ReadLine ) Loop Exit Do End If Loop objIniFile.Close Else WScript.Echo strFilePath & " doesn't exists. Exiting..." Wscript.Quit 1 End If End Function

    </SCRIPT> </head> <body> <b>Device ID: <% ReadIni("\application\atpar\DeviceID.ini","Device","ID") %> </body>


    Hi there,

    I need to run an HTML page in a WM6.5 environment. This page needs to read data from an INI file to be displayed in the page.

    I found this script, but it's not working for me, there's no result on the screen.

    I'll appreciate any help on this task.

    Edo Fuenzalida.

    


    Thursday, August 1, 2013 6:40 PM