homepage Welcome to WebmasterWorld Guest from 23.23.9.5
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
ASP Error when writing to a text file...
Illegal assignment: 'strPathInfo'
isaaclloyd

5+ Year Member



 
Msg#: 2555 posted 10:04 pm on Mar 8, 2005 (gmt 0)

Here is the error:

Microsoft VBScript runtime error '800a01f5'

Illegal assignment: 'strPathInfo'

/mainpage_edit.asp, line 43

Here is the code for line 43 etc.:


39. <DIV style="width:600;">
40. <FONT FACE="Arial" SIZE="2" COLOR="#000000">
41.
42. <!-- #INCLUDE file="global.asp" -->
43. <%
44. strPathInfo =("data/mynext.txt") ' root path to text file
45. strPhysicalPath = Server.MapPath(strPathInfo) ' full file path to text file
46.
47. if getTrueFalse(request("callback")) then ' form submitted change file
48. theNewFile = Request.form("theNewFile")
49. fName = Server.MapPath(strPathInfo)
etc..

When I submit and save to the text file, it almost always works, however there are a few times where I wil hit the browser back botton and then reuturn to the website admin page, hit refresh, and then re-go to this page where I edit the text file and sometimes it will give me the error above when I try to save... Any comments, answers, thoughts are greatly apreciated. Thanks.

~Isaac~

 

mrMister

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 2555 posted 7:15 pm on Mar 29, 2005 (gmt 0)

strPathInfo =("data/mynext.txt")

Have you defined this variable further up in the page? Perhaps as a Constant?

mattglet

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2555 posted 8:44 pm on Mar 29, 2005 (gmt 0)

strPathInfo =("data/mynext.txt")

Take out the parentheses...

strPathInfo ="data/mynext.txt"

Easy_Coder

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2555 posted 10:22 pm on Mar 29, 2005 (gmt 0)

Mr Mister hit it on the head for you.

Although this code is legal:

strPathInfo =("data/mynext.txt") ' root path to text file
strPhysicalPath = Server.MapPath(strPathInfo) ' full file path to text file

You'd get this error if you were attempting to redefine a Const.

Check global.asp for an assignment of strPathInfo.

isaaclloyd

5+ Year Member



 
Msg#: 2555 posted 11:06 pm on Mar 29, 2005 (gmt 0)

Well here is global.asp:

<%
' common functions and variables are kept in here

'
'____________ Common functions __________________

' simple debug function
Function dump(strString)
Response.Write("Debug : " & strString & "")
End Function

' function to get true or false boolean values passed from a string
function getTrueFalse(strBoolean)
output=false
if ucase(trim(strBoolean)) = "TRUE" then output= true
getTrueFalse= output
end function

%>

and here is the full script:

<!-- #INCLUDE file="global.asp" -->
<%
strPathInfo = ("mytextfile.txt") ' root path to text file
strPhysicalPath = Server.MapPath(strPathInfo) ' full file path to text file

if getTrueFalse(request("callback")) then ' form submitted change file
theNewFile = Request.form("theNewFile")
fName = Server.MapPath(strPathInfo)
Set objFSO = CreateObject("Scripting.FileSystemObject") ' new filesystemobject
Set objText = objFSO.CreateTextFile(fName, true) ' create new text file with the same name
objText.Write(theNewFile) 'write contents of textarea to new file
objText.Close ' done
updatetext = "File has been saved!<br><br>"
updatetext = updatetext &"<a href="""& request.ServerVariables("SCRIPT_NAME")&""">click here to edit again</a>"
else
' load the file
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

'create filesystemobject (FSO)
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.GetFile(strPhysicalPath)
textFile = "" ' this will hold the contents of the text file

'open file with FSO
set objFileTextStream = objFile.OpenAsTextStream(ForReading, TristateUseDefault)

Do While objFileTextStream.AtEndOfStream <> True
strFileLine = objFileTextStream.Readline
strLine = Server.HTMLEncode(strFileLine)
strLine = Replace(strLine,CHR(9),"&nbsp;&nbsp;&nbsp;&nbsp;")
textFile = textFile & strLine & vbCrLf
Loop
objFileTextStream.Close
end if
%>
<!-- #INCLUDE file="global.asp" -->

<CENTER>

<%
if updatetext <> "" then
response.write updatetext
else ' write form
%>

<B>EDIT PAGE</B><BR>
You can edit the text on the page below.<BR>
You can type HTML functions, such as:
BR>

<form action="<%=request.ServerVariables("/asp/editText/Copy%20of%20editText/SCRIPT_NAME")%>" method="post">
<input type="hidden" name="callback" value="true">
<textarea name="theNewFile" cols="70" rows="20" class="field"><%=textFile%></textarea>
<BR>
<input name="Submit" type="submit" class="button" value="Save & Update">
</form>


<%
end if
%>

</CENTER>

Easy_Coder

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2555 posted 4:03 am on Mar 30, 2005 (gmt 0)

I'd do an infile search for that variable just to rule it out because that error is thrown when a constant gets redefined.

3 other items I noticed:

1) Looking over your Full Script I noticed that you're including the same include file twice, not sure if you meant to do that:
On line 1
<!-- #INCLUDE file="global.asp" -->

This appears just before the <center> tag again:
<!-- #INCLUDE file="global.asp" -->

2) The path to the text file in your first post is different that the path in your last post.

3) The Form Post Code looks goofed, I don't see how this form will post to anypage other then itself because this code outputs action="":
action="<%=request.ServerVariables("/asp/editText/Copy%20of%20editText/SCRIPT_NAME")%>"

should be
action="/asp/editText/Copy%20of%20editText<%= Request.ServerVariables("script_name")%>"

isaaclloyd

5+ Year Member



 
Msg#: 2555 posted 7:32 am on Mar 30, 2005 (gmt 0)

Well the script does work most of the time. I very rarely get this error anymore. The onyl time I have ever gotten it before was when I was trying to update again really fast.... I know it looks like it shouldn't work... but it does... don't worry about what path I used. Thefirst time it was just different. The only thing that's really wrong right now is that when I save to much text (like a page of 500+ character, which isn't that much) it saves BUT replaces the first 10 characters with something like: 0^0.^.0 it does characters I don't have on my keyboard.... anyways... If anything wants to look into it I would apreciate it, but no rush on this script. Thanks for your time. Let me know if anyone has a better script that lets me edit text files using html pages.

~Isaac Lloyd~

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved