Avatar of CWS (haripriya)
CWS (haripriya)Flag for India

asked on 

Write to a file.

<%
sImg = "#FFFFFF"
sVid = "#FFFFFF"
%>

I just want to right the above code in a .INC file. I am using the following code.

<%
dim fs,fname, strPath, a, b, cl
a= """#FFFFFF"""
b= """#000000"""
set fs=Server.CreateObject("Scripting.FileSystemObject")
strPath = Server.MapPath("./cat.inc")
set fname=fs.CreateTextFile(strPath)
fname.WriteLine("<%")
fname.WriteLine("sImg = " & a )
fname.WriteLine("sVid = " & b )
fname.WriteLine("%>")

fname.Close
set fname=nothing
set fs=nothing
%>

It keeps giving error:
---------------------------------
Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/test.asp, line 19

fname.WriteLine("
-------------------------------------
line 19 is this:
fname.WriteLine("%>")
Adobe DreamweaverASPWeb Languages and Standards

Avatar of undefined
Last Comment
CWS (haripriya)
Avatar of sirbounty
sirbounty
Flag of United States of America image

What if you remove the parens?
fname.WriteLine "%>"
Avatar of sirbounty
sirbounty
Flag of United States of America image

With fname
 .WriteLine "<%"
 .WriteLine "sImg = " & a
 .WriteLine "sVid = " & b
 .WriteLine "%>"
End With
Avatar of CWS (haripriya)

ASKER

same error:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/test.asp, line 19

fname.WriteLine "
-----------------^
Avatar of sirbounty
sirbounty
Flag of United States of America image

Is the file even created?
What if you use
fname.WriteLine "test"
Avatar of TheJay04
TheJay04
Flag of United Kingdom of Great Britain and Northern Ireland image

try this

<%
dim fs,fname, strPath, a, b, cl
a= """#FFFFFF"""
b= """#000000"""
set fs=Server.CreateObject("Scripting.FileSystemObject")
strPath = Server.MapPath("./cat.inc")
set fname=fs.CreateTextFile(strPath)
fname.WriteLine("<%")
fname.WriteLine("sImg = " & a & "")
fname.WriteLine("sVid = " & b & "")
fname.WriteLine("%>")

fname.Close
set fname=nothing
set fs=nothing
%>
ASKER CERTIFIED SOLUTION
Avatar of davbouchard
davbouchard

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of kevp75
kevp75
Flag of United States of America image

davbouchard is correct.

Anytime you are trying to write code to a file (using the FSO), you will need to do how he/she suggested
Avatar of CWS (haripriya)

ASKER

thanks davbouchard. It works.
ASP
ASP

Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.

82K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo