elaintarha Posted November 14, 2007 Posted November 14, 2007 (edited) Hi all!I need following help:I have this script that accepts number as a parameter and then echoes the line from that number from file c:\account.txt. This works fine:* check.vbs *********************Const FOR_READING = 1strFilePath = "C:\account.txt"set objRe = New RegExpobjRE.Global = TrueobjRE.IgnoreCase = FalseobjRE.Pattern = WScript.Arguments(0)iLineNumber = objRE.PatternSet objFS = CreateObject("Scripting.FileSystemObject")Set objTS = objFS.OpenTextFile(strFilePath, FOR_READING)For i=1 To (iLineNumber-1) objTS.SkipLineNextWScript.Echo objTS.Readline***********************c:\type account.txtonetwothreefourfivec:\check.vbs 4fourc:\check.vbs 2twoI need the following:I have a html file containing this kind of data:***********</p><p class="fontti">TEEMU TESTAAJA</p> <p>Vahvista sisäänkirjaus antamalla avainlukua nro 70 vastaava turvaluku</p><p><input name="turvaluku" type="password" maxlength="6" size="6" autocomplete="off" style="TxtBox" /><input name="vahvista" type="submit" class="Button155 ButtonMarginLeft10" value="Vahvista sisäänkirjaus" />***********I need to be able to read file, find the "70" (number between nro and vastaava, will be changing number) and use it as a parameter in the script instead of having to manually give the number. Can anyone help me? Any help appreciated!timo -- @ -- kiinnostaa.net Edited November 14, 2007 by elaintarha
gunsmokingman Posted November 14, 2007 Posted November 14, 2007 Is the number 70 in the account.txt if yes then something like this might helpConst FOR_READING = 1strFilePath = "C:\account.txt"set objRe = New RegExpobjRE.Global = TrueobjRE.IgnoreCase = FalseobjRE.Pattern = WScript.Arguments(0)iLineNumber = objRE.PatternSet objFS = CreateObject("Scripting.FileSystemObject")Set objTS = objFS.OpenTextFile(strFilePath, FOR_READING)Dim StrValueFor i=1 To (iLineNumber-1) If instr(objTS.Readline,70) then '/-> StrValue Is 70 StrValue = objTS.Readline Exit For end if '/-> Not Needed' objTS.SkipLineNext'/-> This will only Show The Last Line Read Txt, Not Needed' WScript.Echo objTS.ReadlineHope this is what you wanted.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now