Solved

vbscript - issue with script.. line 31 bad file mode..

Posted on 2010-11-17
6
485 Views
Last Modified: 2012-05-10
getting bad file mode on this....

need copy and paste the <asp...
then
the html code

then paste the </asp:panel....

repeat...
dim objArgs, objFile1, objFile2, FileStream1,FileStream2, i , slIN1, sLINE2, j, sline3, sline4, sline5, k, allLines

Set objArgs = Wscript.Arguments
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objFile1 = objFSO.GetFile(objArgs(0))
'Set objFile2 = objFSO.GetFile(objArgs(1))
Set FileStream1 = objFSO.OpenTextFile("D:\Desiition\design_1\index.htm")
Set FileStream2 = objFSO.OpenTextFile("C:\Documentstings\NBDFFR\PRGS\VBSCRIPT\test_panel_web.txt")



For i = 1 to 50
    ' READ THE DRIVE FILE IN...
    Set FileStream1 = objFSO.OpenTextFile("D:\Desiition\design_" & i & "\index.htm")
   
    sLine1 = FileStream1.ReadLine()
    

    ' READ THE ASP:panel CODE IN...
     ' sline2 = "this"
 
     sline2 = "<asp:Panel ID=""Panel"" " & i & " runat=""server"" Height=""1599px"">"

    sline3 = "</asp:Panel>"
    sline4 = ""
    sline5 = ""

    

   Filestream2.writeline Sline1
   ' GOTO NEXT LINE IN FILESTREAM 2 AND PASTE..
   Filestream2.writelIne sline2
 ' GOTO NEXT LINE IN FILESTREAM 2 AND PASTE...
   Filestream2.writeline sline3
 ' GOTO NEXT LINE IN FILESTREAM 2 AND PASTE...
   Filestream2.writeline sline4
 ' GOTO NEXT LINE IN FILESTREAM 2 AND PASTE...
   Filestream2.writeline sline5

   


Next

msgbox("complete")

Open in new window

0
Comment
Question by:GlobaLevel
  • 3
  • 2
6 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34160107
Both of your files are opened for reading only

Set FileStream1 = objFSO.OpenTextFile("D:\Desiition\design_1\index.htm")
Set FileStream2 = objFSO.OpenTextFile("C:\Documentstings\NBDFFR\PRGS\VBSCRIPT\test_panel_web.txt")

http://msdn.microsoft.com/en-us/library/314cz14s%28VS.85%29.aspx

For example, to create fs1 if it doesn't exist, but append if it does

Set FileStream1 = objFSO.OpenTextFile("D:\Desiition\design_1\index.8tm", 2, true)
0
 
LVL 13

Expert Comment

by:F Igor
ID: 34160186
Use the second parameter of OpenTextFile

1=ForReading - Open a file for reading. You cannot write to this file. (readonly)
2=ForWriting - Open a file for writing (create)
8=ForAppending - Open a file and write to the end of the file (append)

Set FileStream2 = objFSO.OpenTextFile("C:\Documentstings\NBDFFR\PRGS\VBSCRIPT\test_panel_web.txt",2)
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 34164682
getting closer...but its not reading in the whole html file...
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 10

Author Comment

by:GlobaLevel
ID: 34164692
giving me this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 1 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 2 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 3 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 4 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 5 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 6 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 7 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 8 runat="server" Height="1599px">
</asp:Panel>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<asp:Panel ID="Panel" 9 runat="server" Height="1599px">
</asp:Panel>

0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 34164714
its stops readin in the html file after it sees the space..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      <titl
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34168565
This is not the bad file mode issue anymore.
It's logic - basically you have no loop, there should be a test for EOF, but you have it hardcoded to loop through 50 lines... (I think if I read correctly)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add and format columns in vb6 7 57
Using an encrypted  value to decrypt and display contents in vb6 9 51
Automate switch config backup 3 59
Server 2012 management. 5 24
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question