Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@SCRIPT does not like all comments

Aug
1,914
68
Using;
Code:
TCC  16.03.54  Windows Vista [Version 6.0.6002]
TCC Build 54  Windows Vista Build 6002  Service Pack 2

I am converting some of my larger VBScripts to TCC functions, using a utility that I created, vbs2Function.exe

Example;
Code:
a=10
a=a+1
'Create a console for output
set fso=CreateObject("Scripting.FileSystemObject")
set stdout=fso.GetStandardStream(1)
stdout.WriteLine a
Rem This is a comment

runs properly using
Code:
cscript //nologo test.vbs
and converts to this;
Code:
function test=`%@script[vbscript,a=10:a=a+1:'Create a console for output:set fso=CreateObject("Scripting.FileSystemObject"):set stdout=fso.GetStandardStream(1):stdout.WriteLine a:Rem This is a comment:]`

Running this as
Code:
echo %@test[]
returns nothing but the prompt.

The reason for this is the first comment. If I remove the first comment from the @script function, it works properly with no problem.

It appears that, when using the @script function, comments are allowed only at the end of the command. If comments are placed anywhere else in the @script function, execution halts.

Why is this?

Joe
Code:
TCC  16.03.54  Windows Vista [Version 6.0.6002]
TCC Build 54  Windows Vista Build 6002  Service Pack 2
 
It appears that, when using the @script function, comments are allowed only at the end of the command. If comments are placed anywhere else in the @script function, execution halts.

Why is this?
In vbscript ' is a line comment, in other words, everything from that char until the end of line (#13#10) will be treated as a comment.
(The same is true for jscript's // comment)
If you place it at the end of the code it obviously won't matter, because no code follows.

I'm not sure if vbscript has a block comment equalient (iow, similar to jscript's /*comment*/)
 

Similar threads

Back
Top