Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


save to top of text file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3342
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> save to top of text file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 save to top of text file - 6/11/2005 8:45:02 PM   
  gibbo1715

 

Posts: 52
Score: 0
Joined: 6/8/2005
From:
Status: offline
the code below adds a line of text at the end of my text file, how can i get it to add the line of text to the top?, also i would like my div tag to display the whole text file, can anyone help with either problem?

Sub Submit_OnClick

Dim strSearchString, strOutputName, objFSO, objOutputFile, Form1

Const FOR_Appending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Form1 = Document.Testform

strSearchString = Form1.Text1.Value

strOutputName = "C:\Documents and Settings\Paul\My Documents\Workinprogress\divtag.asp"

Set objOutputFile = objFSO.OpenTextFile(strOutputName, FOR_Appending, True)

objOutputFile.WriteLine strSearchString & "<P>"

DIVTAG.InnerHTML = strSearchString


End Sub

</script>
</Head>

<body>

<form name="Testform">
<input name="Text1" type="text" size="20">
<input name="Submit" type="Button" value="Submit">
<input type="button" value="Refresh Page" onClick="window.location.reload()">
</form>

<DIV ID="DIVTAG"></DIV>

</body>

Gibbo
 
 
Post #: 1
 
 Re: save to top of text file - 6/11/2005 11:17:17 PM   
  didorno

 

Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
You could read the whole file into one single string, together with the new sentence you can concatenate both strings. Then overwrite the file
with the new string.

Good luck !

(in reply to gibbo1715)
 
 
Post #: 2
 
 Re: save to top of text file - 6/13/2005 12:41:27 AM   
  gibbo1715

 

Posts: 52
Score: 0
Joined: 6/8/2005
From:
Status: offline
any chance of example code of how to do this

(in reply to gibbo1715)
 
 
Post #: 3
 
 Re: save to top of text file - 6/13/2005 2:02:39 AM   
  mbouchard


Posts: 1922
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Something like this

Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
NewString = "What ever you want here" & vbcrlf

Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
ReadAllTextFile = f.ReadAll
f.close
NewFile = NewString & readalltextfile
Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
f.write NewFile
f.close

(in reply to gibbo1715)
 
 
Post #: 4
 
 Re: save to top of text file - 6/13/2005 5:35:30 AM   
  didorno

 

Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
mbouchard, that's what I mean ! Thank you.

Sometimes I try to have people to do some home work, because the learning process works better (in my view).


Regards.

(in reply to gibbo1715)
 
 
Post #: 5
 
 Re: save to top of text file - 6/13/2005 8:22:59 AM   
  gibbo1715

 

Posts: 52
Score: 0
Joined: 6/8/2005
From:
Status: offline
thanks that works great, is there an easy way to do something similar with a html page?

(in reply to gibbo1715)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> save to top of text file Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts