It was somewhere outside Barstow when
Join Bytes! wrote:
[color=blue]
>I have been learning ASP[/color]
Good.
[color=blue]
> from a book I bought a week ago[/color]
Bad.
I really quite like ASP. But I've yet to see any good reference or
tutorial for it. When I first learned it it took a _long_ time before
I realised just how much of it to throw away, and what little of the
core was worth keeping hold of. The trouble is (like nearly all
M$oft products) it's a good core product weighed down by baggage
that's loaded onto it because it fitted some M$oft corporate agenda.
One vital thing to remember is that there's no "ASP language". ASP is
just a container for languages - any language engine that can
co-operate with a pretty simple COM interface can be used from ASP.
Out of the box it ships with VBScript and JavaScript (actually
JScript, a slight variation). Other useful ones to know of are
PerlScript, PythonScript and even COBOLScript (!)
As a general principle, throw VBScript away and just use JScript. It's
a much better language. There is _nothing_ you can do in VBScript that
you can't do (and better) in JScript. It's fundamental to ASP that
any of these languages can do everything external that the others can,
so you have a totally free choice depending on how good the language
M$oft usually have about half-a-dozen "VB" languages on the go at
once. There's VB (it makes Windows desktop apps), VBA (embedded into
Office) and the VBScript you're using with ASP. A few other dialects
too. When reading "VB books", make sure that they either apply to the
version you're using, or you understand the differences.
Of the three, VBScript is considerably cut down. One way it's cut
down is in variable typing. VB allows variable declaration with Dim
and also allows variables to be given types. VBScript doesn't - all
variables are of the "Variant" type (exactly the same as "Dim foo As
Variant" in VB). You can still declare them, or let them be
auto-declared when first used (you should _always_ use Option
Explicit and declare them yourself - it saves a lot of bugs).
[color=blue]
>Now I learned how to declare a varible with the dim keyword,
>and now I learned about subtypes and how to add values for my varible,
>but everytime they show an example they go from varible to the word
>variant.[/color]
So this description isn't an ASP thing, it's a VBScript thing. Be
wary of any book that doesn't realise there's an important difference
between these ! If you don't get their distinction quite clear in
your mind, you'll have a lot of trouble.
In VBScript, every variable is of Variant type. But it's still poorly
worded to mix these two words up in a textbook. A "variant" is not a
"variable" - they're different things; one's effectively an adjective
and the other is a noun. Just because every one of these nouns can be
described by that same adjective doesn't mean that they're "the same
thing".
[color=blue]
>Now I know the definition of variant in the asp world,[/color]
One useful thing about VBScript and ASP is that ASP's only variable
types are the Object and the Variant, and these are also VBScript's
native types (they're actually native types of COM, which underlies
the whole lot). This makes some tasks very simple, because you don;t
have to do any conversion. OTOH, it also makes some VBScript code
inelegant and inefficient, because you can't type more appropriately
if you otherwise could do.
--
Smert' spamionam