array question

T

the other john

Is there a way or a property that can tell me how many items are in an
array? Like when using the Split function but the actual number of
created array items is unknown? I need to be able to dynamically count
the number of items that are created as a result of using Split().

Hopefully this is enough information...

Thanks!
 
M

Mike Brind

the said:
Is there a way or a property that can tell me how many items are in an
array? Like when using the Split function but the actual number of
created array items is unknown? I need to be able to dynamically count
the number of items that are created as a result of using Split().

Ubound()
 
M

Mike Brind

Evertjan. said:
Mike Brind wrote on 10 aug 2006 in microsoft.public.inetserver.asp.general:


Only if vbs is assumed, not in jscript.

I _always_ assume vbscript. Users of jscript/javascript or perl tend
to announce themselves (in a tone of voice that varies between proud,
or aggressively defensive ).

:)
 
A

Anthony Jones

Dave Anderson said:
In principle, I agree that VBScript questions posing as ASP questions
deserve the "ASP is not VBScript" rebuke, but have tried to say so
indirectly, by answering the questions with dual-language examples.

The problem with us programmers is that we tend to loose the human point of
view.
If you are working on an ASP page and have a problem with syntax the human
thing to do is ask other developers in your community. In this case the
community is this NG.

For that reason I don't think the "ASP is not VBScript" rebuke is ever
justified. We need to remember that a lot of people developing with ASP
aren't hardened 'classically' trained programmers.

If you were to look at the posts in VBScript and Javascript groups without
knowing the names of the groups you might concluded the VBScript = Automated
Administration and Javascript = DHTML. It's hardly fair then to complain
when someone posts a VBScript question in the ASP group.
I think this serves several purposes, not least of which is demonstrating
the beauty and simplicity of doing some things in JScript, and none of which
is to express -- ahem -- pride or defensiveness.

I agree. JScript/Javascript/ECMAScript (seen rebukes about use of these
terms as well) is simply a more elegant and ultimately a more powerfull
language. However the vast majority of the ASP community uses VBScript. It
would've been better if it had standardised on JScript but it didn't.
Frankly most ASP pages don't need the flexibility that JScript offers and
VBScript is more friendly to the 'casual' programmer.
 
E

Evertjan.

Dave Anderson wrote on 11 aug 2006 in
microsoft.public.inetserver.asp.general:
In any case, VBScript is implied by the term "Split function", don't you
think? JScript has very few functions, and String.split() is not one of
them.

stringObj.split([separator[, limit]])

It is called a "method", because of the added flexibilty.
 
E

Evertjan.

Anthony Jones wrote on 11 aug 2006 in
microsoft.public.inetserver.asp.general:
Frankly most ASP pages don't need the flexibility that JScript offers and
VBScript is more friendly to the 'casual' programmer.

Even under asp/vbs, I like to define my regex functions in jscript,
and the possibiliy to get UTC from the server, without having to regard
summertime change dates is very useful when using servers on the other side
of the big pond.
 
A

Anthony Jones

Evertjan. said:
Anthony Jones wrote on 11 aug 2006 in
microsoft.public.inetserver.asp.general:


Even under asp/vbs, I like to define my regex functions in jscript,

That's interesting. It's one of the only areas where I find VBScript
better.
VBScript can execute a global expression with submatches whereas JScript
can't (actually it can but you can't retrieve the submatches)
and the possibiliy to get UTC from the server, without having to regard
summertime change dates is very useful when using servers on the other side
of the big pond.

Good point there's no way to do this in VBScript without help from an
external component.
 
D

Dave Anderson

Anthony said:
If you are working on an ASP page and have a problem with
syntax the human thing to do is ask other developers in
your community. In this case the community is this NG.

I do not agree. If you have a problem with syntax, then you are likely to be
posting here for the first time (or thereabout). This forum was not already
"your community" because you would have been reading it for some time, and
would know the difference between microsoft.public.scripting.vbscript and
microsoft.public.inetserver.asp.general. If it were "your community", you
would have an interest in keeping it tidy.


For that reason I don't think the "ASP is not VBScript" rebuke
is ever justified. We need to remember that a lot of people
developing with ASP aren't hardened 'classically' trained
programmers.

By that reasoning, none of these are justified:

JavaScript is not Java
ASP.NET is not ASP
Client-side is not server-side
(D)HTML is not ASP



My point, if you read it carefully, is that the rebuke need not be rude, and
ought to be instructive. There *is* value in asking people to use
appropriate groups. The last thng we need is a bunch of posts about the
conflict Lebanon.


If you were to look at the posts in VBScript and Javascript
groups without knowing the names of the groups you might
concluded the VBScript = Automated Administration and
Javascript = DHTML. It's hardly fair then to complain when
someone posts a VBScript question in the ASP group.

Who complained? I advocated instructive examples that make the point.


JScript/Javascript/ECMAScript (seen rebukes about use of
these terms as well) is simply a more elegant and ultimately
a more powerfull language.

I can't agree that JScript is more powerful than VBScript. I cannot think of
a single task that JScript can solve, but that VBScript cannot. I don't
consider it *convenient* to use the Class Statement (or 4*atn(1) in place of
Math.PI), but I don't deny that there are routes to solutions in VBScript.

And let's face it, VBScript often runs faster than JScript on the server.
 
D

Dave Anderson

Evertjan. said:
It is called a "method", because of the added flexibilty.

It is called a method because it belongs to an object, and is not a
standalone function. I don't see how that translates to added flexibility.

The point was that the OP used "function", not "method".
 
T

the other john

Yikes. what happened here? didn't count on all of this...

so the moral of the story is you don't want me posting VB questions in
here? Ok then. I can live with that.

In way it's too bad however. This group has been invaluable to me and
with so many knowledgable people that are doing similar things its a
great place to get a quick answer, if even "slightly" off topic. I
understand everyone wants to keep the group relevant to ASP. Still,
it's nice to stop at coffee house for more than just coffee
occasionally ;-)

Thanks all anyway!
 
M

Mike Brind

Dave said:
I do not agree. If you have a problem with syntax, then you are likely to be
posting here for the first time (or thereabout). This forum was not already
"your community" because you would have been reading it for some time, and
would know the difference between microsoft.public.scripting.vbscript and
microsoft.public.inetserver.asp.general. If it were "your community", you
would have an interest in keeping it tidy.

Interesting....

If you took out all the server-side scripting questions from this
group, and all the db-related ones (which obviously belong in other
groups), not to mention all the IIS related questions, this group would
be an ex-group. It would cease to be. It will have shuffled off this
mortal coil. It would be dead.

By definition, then, this group's only purpose is as a first staging
post for newbies, until they're better informed.

btw, my very tongue in cheek comment on the users of
jscript/javascript/perl etc was never intended to flame...
 
B

Bob Barrows [MVP]

the said:
Yikes. what happened here? didn't count on all of this...

so the moral of the story is you don't want me posting VB questions in
here?

Wow!
Who said anything like that?
Ok then. I can live with that.

Don't. This is the perfect group to post ASP questions that involve
server-side vbscript code.
In way it's too bad however. This group has been invaluable to me and
with so many knowledgable people that are doing similar things its a
great place to get a quick answer, if even "slightly" off topic. I
understand everyone wants to keep the group relevant to ASP. Still,
it's nice to stop at coffee house for more than just coffee
occasionally ;-)

You seem to have missed the point. The argument was not about whether your
post was on-topic. It was more about whether it was correct to assume you
were using vbscript as opposed to jscript in your server-side code.
 
B

Bob Barrows [MVP]

Anthony said:
For that reason I don't think the "ASP is not VBScript" rebuke is ever
justified. We need to remember that a lot of people developing with
ASP aren't hardened 'classically' trained programmers.

We're here to educate aren't we (Well ... I am. I try very hard not to just
give the quick fix)? People who talk about writing ASP code need to be
informed that their terminology is incorrect. I really do not consider that
to be a rebuke.
 
B

Bob Barrows [MVP]

Mike said:
Interesting....

If you took out all the server-side scripting questions from this
group, and all the db-related ones (which obviously belong in other
groups), not to mention all the IIS related questions, this group
would
be an ex-group. It would cease to be. It will have shuffled off this
mortal coil. It would be dead.

Why would anyone want to to that? Who said we should be doing that?
Everything you've mentioned is on-topic (well ... maybe not db, but even
those)...

Let me go back and read this thread. I though the discussion was about
whether or not it was correct to assume a poster was asking a vbscript
question as opposed to jscript ....

OK, I think I see what you are talking about in Dave's post. I will reply to
that.
 
B

Bob Barrows [MVP]

Dave said:
In principle, I agree that VBScript questions posing as ASP questions
deserve the "ASP is not VBScript" rebuke,

Wait a minute, you seem to be implying that vbscript or jscript syntax
questions are not really on-topic here. Am I reading too much into this
statement?
 
B

Bob Barrows [MVP]

Actually, since VB is not used in ASP (except as an external component) we
really would rather not address VB questions here. VBScript questions, when
they involve server-side code, are certainly welcome.
 
A

Anthony Jones

Bob Barrows said:
We're here to educate aren't we (Well ... I am. I try very hard not to just
give the quick fix)? People who talk about writing ASP code need to be
informed that their terminology is incorrect. I really do not consider that
to be a rebuke.

Your point is well made. I retract. I guess I'm easily irked by the
pendantic amongst us and that can cloud my judgement. I still think it as
you do that the OP was reasonably placed here.
 
E

Evertjan.

Mike Brind wrote on 11 aug 2006 in
microsoft.public.inetserver.asp.general:
I _always_ assume vbscript. Users of jscript/javascript or perl tend
to announce themselves (in a tone of voice that varies between proud,
or aggressively defensive ).

[skipping a lot of following and diverging thread lines resulting from
here]

You can see the OP asked a Q that can be answered
with a vbscript answer or an jscript answer,
if the word "function" can be extended to "method",
which is a function in the broader sence too.

My one row addition, which is only a rebuke in the most suspicious of
minds, and I know Mike's mind is not, is just that _I_ would have
answered:

"Ubound() in vbscript"

I cannot agree with Mike it is a good thing to assume vbs in an anwer
where vbs is not stipulated in the question in his ASP NG.
The "asp = vbscript" concept does not aggree with me.

=============

I would have added that the number of terms
of a jscript array is not as easily defined:

var a = new Array();
a[0] = 5;
a[999] = 'Hi';
a['saved'] = 4;

is the last one part of the array, and the number of terms 3?
or is the number 1001?

Let us try a.length:

var a = new Array();
a[0] = 5;
a[999] = 'Hi';
response.write(a.length+'<br>') // writes 1000
a['saved'] = 4;
response.write(a.length) // writes 1000 again

I think length does not return the actual number of terms,
so a count is necessary:

var a = new Array();
a[0] = 5;
a[999] = 'Hi';
a['saved'] = 4;
var n = 0;
for (t in a)n++;
response.write(n); // 3

That is the right jscript answer, methinks,
depending on definition of "array" and "terms".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top