Re: Defining Parameter
From: Al Dunbar [MS-MVP] (alan-no-drub-spam_at_hotmail.com)
Date: 10/13/04
- Next message: Torgeir Bakken \(MVP\): "Re: Close all Windows"
- Previous message: Chris Henderson: "Newbie Question - Hotfix / Patching script"
- In reply to: Ronen: "Defining Parameter"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 13 Oct 2004 11:51:58 -0600
"Ronen" <eyasso@hotmail.com> wrote in message
news:%23p$5ptSsEHA.3468@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> Is there a way to define in VBS a text like in c/c++ in the following way?
>
>
> #define TDOutput.Print Wscript.echo
Not that I know of...
> This way doesn't work:
>
> Const TDOutput.Print = Wscript.echo
Const assigns a value to a symbol so that common constant values can be
referred to in your script symbolically.
The symbol must be equivalent in form to a variable name. TDOutput and Print
would both be valid, but TDOutput.Print is not. For the construct
"TDOutput.Print" to mean anything in vbscript, TDOutput must have been
already created as an object variable. But a constant cannot depend in any
way on a variable.
The value assigned the constant must be a: "Literal or other constant, or
any combination that includes all arithmetic or logical operators except
Is.". Nowhere in that definition does it allow for any run-time values.
Wscript.echo is not a constant, but the name of a method. And further,
Wscript is the name of an object created at run-time by WSH, and is not part
of vbscript itself.
What you are looking for seems to be a source-level macro or
string-replacement capability. vbscript is quite different from c/c++ in
this and many other respects. Trying to provide a convention in which a
c/c++ programmer might feel more comfortable when working in vbscript (if
that is your goal) seems to me to be a particularly ineffective technique.
IMHO, you'd be better off using vbscripts own particular features directly.
For example, something like this might do what you want here:
print "this is a test"
print "the time is " & time & ", and the date is " & date
wscript.quit
sub print( arg )
wscript.echo arg
end sub
/Al
- Next message: Torgeir Bakken \(MVP\): "Re: Close all Windows"
- Previous message: Chris Henderson: "Newbie Question - Hotfix / Patching script"
- In reply to: Ronen: "Defining Parameter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|