• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

vbscript syntax problem

Flatline

Golden Member
Hello all, I'm attempting to invent a workaround (or as I like to call them, reacharounds) for a problem my compadres in my company created. I've written a vbscript that does everthing I need it to do except for one thing: write a specific bunch of text to a file the script has created. The syntax is kind of tricky, and I'm hoping that someone here will have dealt with something like it before (I just started messing with vbscript and I'm not ashamed to admit when I need help)

Here is the text I want written to the file:

<?xml version="1.0" encoding="UTF-8" ?>
<records>
<address filename="Aristotles Video Conf Room.xml" name="Aristotles Video Conf Room">
<ip address="960927" speed="384"/>
<isdn country_code="" area_code="" number="" speed="" network=""/>
<phone country_code="" area_code="" number=""/>
<mobile country_code="" area_code="" number=""/>
<email address=""/>
<e164 alias="960927"/>
<comment text=""/>
</address>

The ip address and e164 alias have, of course, been changed to protect the (not so) innocent.
 
The filesystemobject is pretty handy. Check it out at DevGuru

to answer your question, first assign what you want to output to a string
then do something like the following:


Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FolderExists("<targetdir>") Then
Dim fileOut: Set fileOut= FS.OpenTextFile("<targetdir>\<filename>", ForWriting, True)
fileOut.WriteLine(theString)
fileOut.Close
End If

 
Thanks for the reply...I just figured it out:

Set objFile = CreateObject("Scripting.FileSystemObject")
Set strGuyFile = objFile.CreateTextFile(strFilePath, True)

dim qm
qm = chr(34)


strGuyFile.WriteLine "<?xml version=" &amp; qm &amp; "1.0" &amp; qm &amp; _
" encoding=" &amp; qm &amp; "UTF-8" &amp; qm &amp; " ?>"

and so forth

Thanks again
 
If your problem is the double quotes, you can escape the double quote with two of them so

when I say "this", I mean "that"

would be

"when I say ""this"", I mean ""that"""
 
Back
Top