Hi, all,

below uses ":" to put two statement in on line. Any one know where I
can find explanation of this usage or this way just to put statment in
one line.

Thanks.
Greg

Dim sIP_Address : sIP_Address = GetIP()

Re: Question about ":" in vbscript syntax by Tom

Tom
Mon Dec 03 06:27:17 PST 2007

On Dec 3, 9:05 am, greg chu <greg_...@wendys.com> wrote:
> Hi, all,
>
> below uses ":" to put two statement in on line. Any one know where I
> can find explanation of this usage or this way just to put statment in
> one line.
>
> Thanks.
> Greg
>
> Dim sIP_Address : sIP_Address = GetIP()

I found a documented reference in the WSH downloadable help file at "A
Simple VBScript Page". I used a search on the word 'colon' to locate
it. It was applied to the use in an HTML context. I also found a
reference to its use in an IF/Else context at "If...Then...Else
Statement".

WSH 5.6 documentation download (URL all one line)
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Re: Question about ":" in vbscript syntax by Bob

Bob
Mon Dec 03 06:31:08 PST 2007

greg chu wrote:
> Hi, all,
>
> below uses ":" to put two statement in on line. Any one know where I
> can find explanation of this usage or this way just to put statment in
> one line.
>
> Thanks.
> Greg
>
> Dim sIP_Address : sIP_Address = GetIP()

Use the colon to allow putting two or more statements on one line. It works.
What more do you need to know?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Question about ":" in vbscript syntax by Evertjan

Evertjan
Mon Dec 03 07:12:47 PST 2007

Bob Barrows [MVP] wrote on 03 dec 2007 in
microsoft.public.scripting.vbscript:

> greg chu wrote:
>> below uses ":" to put two statement in on line. Any one know where I
>> can find explanation of this usage or this way just to put statment
>> in one line.

>> Dim sIP_Address : sIP_Address = GetIP()
>
> Use the colon to allow putting two or more statements on one line. It
> works. What more do you need to know?

This is ancient Basic stuff.

A colon allows two or more statements on one line, [as you say, Bob,]
which are interpreted just as if they were on seperate lines,
EXCEPT when used in a inline IF .. THEN .. ELSE ..,
where the single line has a special logically obvious usefulness:

If a=1 Then b=1:c=3 Else d=5:a=2*d

So you cannot blindly replace all colons with newline chars.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Question about ":" in vbscript syntax by mr_unreliable

mr_unreliable
Mon Dec 03 08:09:40 PST 2007

Bob Barrows [MVP] wrote:
> Use the colon to allow putting two or more statements on one line. It works.
> What more do you need to know?
>

The use of the colon as a statement separator was carried
over from visual basic (and vba too, for that matter).

It is one of a number of features carried over -- but not
documented. I suppose microsoft just assumed that people
would know about these features, and so saw no need to
explicitly mention them.

Also, in certain circles, using the colon to put two or
more statements on one line is frowned upon as bad
programming practice. Those purists will say ONE STATEMENT
PER LINE, please.

As for myself, I like to use it, especially for a
declaration + realization situation -- which some
other languages support natively.

For example:

Dim oATO : Set wshATO = CreateObject("wshAPIToolkit.ucATO")

or:

' this PBM_SETPOS message sets the current progress bar value,
' and redraws the bar to reflect the new position.
Dim PBM_SETPOS : PBM_SETPOS = (WM_USER + 2)


cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)