在 vbscript 中获取无效的过程调用或参数 [英] getting invalid procedure call or argument in vbscript

查看:30
本文介绍了在 vbscript 中获取无效的过程调用或参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码..我在这个语句 txsOutput.Writeline txsInput1.ReadAll 得到一个无效的调用或过程..组合文件只是一个文本文件,其中有一些这种格式的条目

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

名称 test.css.

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:\txt3.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:\inetpub\wwwroot\data\p\" & 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

推荐答案

调用 TextStream.WriteLine 时出现的错误 5 通常是由于尝试写入 TextStream 无法编码的数据引起的:

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

尝试将U+1F00 ἀ e1 bc 80 GREEK SMALL LETTER ALPHA WITH PSILI"写入使用/用于ASCII"编码的流:

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(".\tmp.txt")
>> f.WriteLine "AÄ"
>>  --- no news here means: written ---
>> f.WriteLine ChrW(&H1F00)
>>
Error Number:       5
Error Description:  Invalid procedure call or argument

证明这一点:

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

由于数据源 (.ReadAll()) 似乎来自 WWW,因此它可能包含非 ASCII/ANSI 文本.但请注意,如果输入是 UTF-8,则仅打开 Unicode (=UTF-16) 的输出文件将无济于事.

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.

这篇关于在 vbscript 中获取无效的过程调用或参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆