Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting invalid procedure call or argument in vbscript

Tags:

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:\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
like image 517
user505210 Avatar asked Jun 13 '13 18:06

user505210


1 Answers

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(".\tmp.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(".\tmp.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.

like image 132
Ekkehard.Horner Avatar answered Nov 15 '22 10:11

Ekkehard.Horner