Low cost ecommerce web development India flash website design

VARIABLES AND CONSTRUCTS

Dim 'em first To "Dim" it means to Dimension it. That's VB lingo. A variable is declared in VBScript using the Dim keyword. <% Dim myVar %> VB programmers will notice here, that we have not included any indication of the type of the said variable. E.g. Dim myString as String, or Dim myString$. In VBScript, all variables are variants. Their type is determined automatically by the runtime interpreter, and the programmer need not (and should not) bother with them. By default, VBScript does not force requiring variable declaration. That is, it is allowed to use a variable directly without declaring it first. However, experienced programmers know the importance of making it compulsory to declare all your variables first - without that, the bugs that may result are verrry difficult to detect. Considering this, we have here a simple directive to make variable declaration compulsory. <% Option Explicit Dim myVar %> Remember that Option Explicit must necessarily be the first statement of your ASP page, otherwise a server error is generated. To illustrate what I mean, if you had a page that read:

14 <% Pi = 3.141592654 Response.Write Pi %> this is a perfectly valid page. You will get the value of Pi written back to the page, as you really expected. Now, using the Option Explicit directive as above, let's rewrite the same page as follows: <% Option Explicit Pi = 3.141592654 %> Now you have an error that says: Microsoft VBScript runtime (0x800A01F4) Variable is undefined: 'Pi' /asp/test.asp, line 3 The reason is that, now, with the Option Explicit directive, IIS expects to see a declaration of every variable that is used. So, in this case, the correct script must read: <% Option Explicit Dim Pi Pi = 3.141592654 %> freelance web designer India web development

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73