Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i write to a text file using ASP & VBScript? 2

Status
Not open for further replies.

mijulie

Programmer
Jun 21, 2001
36
0
0
IE
This below is my ASP page. Does anybody know what lines i need to write to a file? All suggestions welcome, thanks in advance, J

<%@ LANGUAGE=VBScript %>
<%
strTitle = Request.Form(&quot;Title&quot;)
strBinary = Request.Form(&quot;Binary&quot;)
strBuild = Request.Form(&quot;Build&quot;)
strTest = Request.Form(&quot;Test&quot;)
strDate = Request.Form(&quot;Date&quot;)
strLandLine = Request.Form(&quot;LandLine&quot;)
strMobile = Request.Form(&quot;Mobile&quot;)
str1_3_9Challenge = Request.Form(&quot;1_3_9Challenge&quot;)
strBlocks = Request.Form(&quot;Blocks&quot;)
strChallenge = Request.Form(&quot;Challenge&quot;)
strIRDBDownload = Request.Form(&quot;IRDBDownload&quot;)
striIRDBDownload = Request.Form(&quot;iIRDBDownload&quot;)
strReprogramming = Request.Form(&quot;Reprogramming&quot;)
strStatus = Request.Form(&quot;Status&quot;)
strComment = Request.Form(&quot;Comment&quot;)
strDebugs = Request.Form(&quot;Debugs&quot;)

%>

<B>Binary: </B><%=strBinary %><BR>
<B>Build: </B><%=strBuild %><BR>
<B>Test A/C: </B><%=strTest %><BR>
<B>Date: </B><%=strDate %><BR><BR>


<B><U>Test Results</U></B><BR><BR>

<B>1_1_15 LandLine:</B> <%If strLandLine = &quot;Tekelec&quot; Then %>
Tekelec: Yes
<% Else %> <U>Tekelec - No</U>
<% End If %>
<% If strLandLine = &quot;D&D&quot; Then %>
D & D: Yes
<% Else %> <B> , </B> <U>D & D - No</U>
<% End If %>
<% If strLandLine = &quot;BearerData&quot; Then %>
Bearer Data: Yes
<% Else %> <B> , </B> <U>Bearer Data - No</U>
<% End If %>
<% If strLandLine = &quot;SoftShelf&quot; Then %>
SoftShelf: Yes
<% Else %> <B> , </B> <U>SoftShelf - No</U>
<% End If %><BR><BR>
 
I think that for CreateTextFile, i don't think you are using the correct parameters

for a good reference, see:


anyhow try
Set filetxt = filesys.CreateTextFile(&quot;F:\Corktest\Sit\ TheBinary & TheBuild & &quot;.txt&quot;, True)

I think that you need the ForWriting param only when you open the text file.

so if you were doing
Set filetxt = filesys.OpenTextFile(&quot;F:\Corktest\Sit\ TheBinary & TheBuild & &quot;.txt&quot;, ForAppending, True)

That would work like a charm.

good luck
leo
 
This is the line in my code, when i run it i get an error saying unterminated string constant after, True)

Set filetxt = filesys.CreateTextFile(&quot;F:\com\docs\Corktest\Sit\TheBinary&TheBuild&&quot;.txt&quot;, True)
 
That error will be generated because IIS sees three &quot;'s in a line and thinks that means you have an unterminated string in that line. Looking at your code that is not true so I would suggest...

Set filetxt = filesys.CreateTextFile(&quot;F:\com\docs\Corktest\Sit\TheBinary&TheBuild&&quot;&quot;&quot;.txt&quot;, True)

G

-GTM Solutions, Home of USITE-
-=
 
I've been at my grandparents and i dont have time to write..

If u want to pass anny variable(string variable) to another string try this way:

your code:
Set filetxt = filesys.CreateTextFile(&quot;F:\Corktest\Sit\&TheBinary&TheBuild&.txt&quot;, ForWriting, True)

new code
Set filetxt = filesys.CreateTextFile(&quot;F:\Corktest\Sit\&quot; & TheBinary & TheBuild & &quot;.txt&quot;, ForWriting, True)

if the variable is TheBinary,TheBuild

TheBinary=&quot;BinnaryDirectory\&quot;
TheBuild=&quot;filename&quot;

the path to the file will be like
&quot;F:\Corktest\Sit\BinnaryDirectory\filename.txt&quot;

if u have code like this

TheBinary=&quot;BinnaryDirectory\&quot;
TheBuild=&quot;filename&quot;
myStringVariable= TheBinary & TheBuild

this is equivqalent to
myStringVariable= TheBinary + TheBuild


myStringVariable will have the value of the both string variables
&quot;BinnaryDirectory\filename&quot;
 
Thanks for that, it's working away fine now, much appreciated, Mijulie
 
er... maybe some late, but I have a problem writing a file. My web hosting does not allow me to know the whole path to my folder. And trying to write the file without a path does not work... what could I do?
 
Use server.mappath to get the physical path to the asp page you are writing, then manipulate that string to be the full path to the file you want to create, eg....

filepath=server.mappath(&quot;myasp.asp&quot;)
filepath=replace(filepath,&quot;myasp.asp&quot;,&quot;mytextfile.txt&quot;)

filepath should now be something like &quot;f:\inetpub\
hope this helps...

G -GTM Solutions, Home of USITE-
-=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top