Tuesday, November 29, 2011

Squishing onto a line: the colon :

Sometimes we need to reduce the human readability of our code. The colon will provides help to do this by letting we put multiple lines of ASP code onto a single line. Below is an example …..!! 



<%
Dim a
Dim b
Dim c
a=3 : b=25 : c=a-b : b=a*c : c=a*a-c+b : b=5*3*c*2/a
%>

Monday, November 28, 2011

How to Accesses a VBScript array within a JScript script.


<SCRIPT LANGUAGE="VBSCRIPT">
Function makeArrayVB()

    ' Creates a VBScript array
    dim anArray(1,1)

    anArray(0,0) = "0,0"
    anArray(0,1) = "0,1"

    anArray(1,0) = "1,0"
    anArray(1,1) = "1,1"

    makeArrayVB = anArray
End Function

<SCRIPT LANGUAGE="JavaScript">

// Accesses a VBScript array within a JScript script
function getVBArray(){

    var arrayObj;
    var jsArray;
    arrayObj = makeArrayVB();

    jsArray = VBArray(arrayObj).toArray();
    alert("VBScript array length = " + jsArray.length);

    // Displays the contents of the array
    for(i=1;i<=jsArray.length;i++){

       alert(jsArray[i-1]);
    }
}

</SCRIPT>