|
I am new to VBScripting. have only worked on VC++,C# etc.Kindly help me with this.
I have to develop a module using VBScript. The VbScript should be able to open an existing .htm file(this .htm file has a list of drivers name and file name).
The VBScript has to basically be able to open this .htm file, pick out all drivers name and associated file name and log the driver and file names into a simple text file.
Being new to VBScripting i do not have an idea how to go ahead. Pls suggets me a way to do this - if there is a sample code existing kindly inform me.
Thanks in advance.
Awaiting a reply soon.
Sincerely
Giftsana
|
|
|
|
|
This is the code you need..hope this will help you
_________________________________________________
set fso=createobject("scripting.filesystemobject")
Function read_data()
s=""
set f=fso.getfile("c:\source.htm") 'read data from source file
set ts=f.openastextstream(1,0) 'read,ascii
s=s & ts.readall
ts.close
set ts=fso.CreateTextFile("C:\destination.txt",true,false) 'overwrite,ascii
s=clearAllTags(s)
ts.write s
ts.close
End Function
'This function will remove all the HTML,BODY tags from our data and write only data from htm file
Function clearAllTags(s)
Dim re
Set re = New RegExp
re.Pattern = "(<[^>]*>)"
re.Global = True
re.IgnoreCase = True
clearAllTags = re.Replace(s, "")
End Function
_________________________________________________
Sushant Mathur
Bangalore,
INDIA.
http://n.domaindlx.com/fun2ssh/HOME.htm
|
|
|
|
|
Hi Sushant
Thanks a lot for the prompt reply with the sample code.
I shall try with this.
Thanks again
Sincerely
Giftsana
Singapore
|
|
|
|
|
Hello Sushant
I opended an .htm file and copied the code you gave.
there is an error in the following line:
where is removed defined? i get the message "Could not find any attribute 'removed' of element 'body'."
so i replaced 'removed' with 'onload' but i cannot find any .txt log file created in the folder.
Kindly let me know what is 'removed' used for? do we have to define it elsewhere?
Awaiting a reply.
Sincerely
Giftsana
|
|
|
|
|
actually there was onload in BODY tag but when i paste my code hereit automatically becomes removed ...don't know why
and i have checked again and its working fine here...
try again and let me know
Sushant Mathur
Bangalore,
INDIA.
http://n.domaindlx.com/fun2ssh/HOME.htm
|
|
|
|
|
Hi Sushant
Thanks again for informing me of the above.
I tried running it with again,
but i still cant see the Log file created?
Below is my code, cld you suggest me where am i going wrong?
<title>DaVinci Driver Logger
Set objfso = CreateObject("scripting.filesystemobject")
Function read_data()
s = ""
Set f = objfso.GetFile("c:\DaVinci-1 Latest Driver List (US).htm")
Set ts = f.openastextstream(1,0)
s = s & ts.readall
ts.close
set ts = objfso.CreateTextFile("c:\DaVinciLog.txt",true,false)
s = clearAllTags(s)
ts.write s
ts.close
End Function
Function clearAllTags(s)
Dim re
Set re = New RegExp
re.Pattern = "(<[^>]*>)"
re.Global = True
re.IgnoreCase = True
clearAllTags = re.Replace(s,"");
End Function
Sincerely
Giftsana
|
|
|
|
|
FYI I have used in the code.
when i copied and pasted it shows removed as you said.
Sincerely
Giftsana
|
|
|
|
|
|
Thanks for the prompt reply and for downloading the source.
Sorry for bothering again.
Let me try it.
Thanks again.
Sincerely
Giftsana
|
|
|
|
|
|
Yes i did that, took code from view->source
I opened a new html(DriverLog.htm) page and copied the code.
On trying to open this .htm file(DriverLog.htm) from IE, i see a message "An ActiveX control on this page might be unsafe to interact with other parts of the page.Do you want to allow this interaction?" on hitting the "Yes" button i see "Error on page" message and no log file is created.
Kindly suggest if i missed something.
Thanks again for your patience and replying to my queries.
Sincerely
Giftsana
|
|
|
|
|
Can u please clik on that error symbol and let me know what is the error??
because its working fine here.
That active X prompt will come.needn't worry
Sushant Mathur
Bangalore,
INDIA.
http://n.domaindlx.com/fun2ssh/HOME.htm
|
|
|
|
|
The error is foll:
Line: 13
Char: 1
Error: File not found
Code: 0
It was not getting the proper source file path at the foll line
set f=fso.getfile("c:\DaVinciDriver.htm") 'read data from source file
so i changed this to(hardcoded) ->
set f=fso.getfile("C:\Giftsana\ATS Modules\ATS DaVinci Driver Logger\DaVinciDriver.htm")
So now the log file is created and i can see the driver name etc!
is there a function to get the path of the source file(.htm) ,cos here i am hardcoding the path?
Thanks again for replying to all my queries and helping me get a solution!
Thank You.
Sincerely
Giftsana
|
|
|
|
|
Yes to do this use and you can take value from there.
and no thanks its my pleasure
-----------------
sample code to do the above
Sub button_1_onclick
dim file_val
file_val=Document.frm1.val.value
End Sub
---------------
Sushant Mathur
Bangalore,
INDIA.
http://n.domaindlx.com/fun2ssh/HOME.htm
|
|
|
|
|
Hello Sushant
Thanks.
i have another query which i tried getting sol but cldnt.
the log file that i retrive frm the above opern returns all data, i want to extract only the driver name and file name from the .txt file? is it possible in vbscript?
for ref here is a part of my text file
the IBM Confidential information.
Driver/Utility Name
<ThinkPad Utility>
ThinkVantage Productivity Center
79uz02ww.zip
11/25/05
1.02
O
O
Productivity Center Supplement for ThinkPad
79uy01ww.zip
11/25/05
1.01
and so on...
i have to retrieve only "Productivity Center Supplement for ThinkPad" and "79uy01ww.zip" and likewise other drivers / filenames in the text file above.
i have been trying without succes? or is it possible to filter these frm the .htm file itself, by identifying driver name after some special character?
Sincerely
Giftsana
|
|
|
|
|
I am sorry for replying late...actually it is possible if we use some string function but not sure which one
tell u after some time
Sushant Mathur
Bangalore,
INDIA.
http://n.domaindlx.com/fun2ssh/HOME.htm
|
|
|
|
|
Sure, Thanks for the reply.
I am really sorry for bothering you, but am helpless as i have no clue as to which func to use in VBScript.
fyi: i have posted a new message with the sample html file, although some tags r missing while posting,
Cld you have a look at this htm file and suggest what RegExp pattern i shld set to extract the driver name and file name and log to txt file?
Sincerely
Giftsana
|
|
|
|
|
hello... everyone... need some help... i have a page that's really long... and it has a "SAVE" button at the very bottom of the page... i saw an idea but do not know how to implement... question is how can the "SAVE" button follow the vertical scroll bar button when the user scrolls up/down??? so, the user does not have to scroll to the bottom of the page to see the "SAVE" button... thanks...
e32
|
|
|
|
|
You can check pixel values of the scrollbar using document.body.scrollTop(IE only) and window.pageYOffset(Non IE).This will return value in pixels so take this and each time set this value in the position attribute of your SAVE image button.
Sushant Mathur
Bangalore,
INDIA.
http://n.domaindlx.com/fun2ssh/HOME.htm
|
|
|
|
|
hi all, help me i need a simple asp code for reading a livefeed from a site and display the info to my site
RaJ
|
|
|
|
|
|
Is there a way for me to use javascript or some other method to check if a client pc has the .Net framework installed or not. I need to know if the client pc has the .Net framework installed or not so that I can disable a button that launches an application that requires the .Net framework. Thanks.
|
|
|
|
|
|
I have put the following script in the Page_Load of my aspx.cs file, but it doesn't seem to work. I have tested it on client PCs that either have the .Net framework installed or not and in all cases I get the else part of the script displaying "No CLR" message. Do I need to plug in another string other than the ".Net CLR" into the indexOf?
string strJScript2 =
"if (navigator.userAgent.indexOf('.Net CLR') > -1) " +
"alert('CLR available'); else alert('No CLR');";
Page.RegisterStartupScript("Alert", strJScript2);
|
|
|
|
|
I figured out what the problem was, indexOf is case sensitive. Once I passed in ".NET CLR" then it worked, thanks for you help.
|
|
|
|