Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
922 views
in Technique[技术] by (71.8m points)

getting invalid procedure call or argument in vbscript

I have the below code..I am getting an invalid call or procedure at this statement txsOutput.Writeline txsInput1.ReadAll ..The combination file is ust a text file which has some entries in this format

name test.css.

Can someone please tell me what's wrong with the script.

Dim strInputPath1
Dim txsInput1,txsOutput
Dim FSO

Dim Filename


Set FSO = CreateObject("Scripting.FileSystemObject")
strOutputPath = "C:xt3.txt"
Set txsOutput = FSO.CreateTextFile(strOutputPath)

Set re = New RegExp
re.Pattern = "s+"
re.Global  = True

Set f = FSO.OpenTextFile("C:combination.txt")
Do Until f.AtEndOfStream
  tokens = Split(Trim(re.Replace(f.ReadLine, " ")))
  extension = Split(tokens(0),".")
  strInputPath1 =  "C:inetpubwwwrootdatap" & tokens(1) & "" & extension(1) & "" & tokens(0) 

Loop
f.Close

WScript.Echo strInputPath1

Set txsInput1 = FSO.OpenTextFile(strInputPath1, 1)
txsOutput.Writeline txsInput1.ReadAll

txsInput1.Close
txsOutput.Close
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The error 5 when calling TextStream.WriteLine is typically caused by trying to write data the TextStream can't encode:

Trying to write "U+1F00 ? e1 bc 80 GREEK SMALL LETTER ALPHA WITH PSILI" to a stream opened with/for 'ASCII' encoding:

>> Set f = goFS.CreateTextFile(".mp.txt")
>> f.WriteLine "A?"
>>  --- no news here means: written ---
>> f.WriteLine ChrW(&H1F00)
>>
Error Number:       5
Error Description:  Invalid procedure call or argument

To prove this:

>> f.close
>> Set f = goFS.CreateTextFile(".mp.txt", True, True) ' overwrite, unicode
>> f.WriteLine ChrW(&H1F00)
>>
>> --- no news are good news --

As the data source (.ReadAll()) seems to come from the WWW, it's probable that it contains non ASCII/ANSI text. Be warned though, just opening the output file for Unicode (=UTF-16) won't help if the input is UTF-8 slurped by .ReadAll() on a ASCII Textstream.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...