I want a static varible like C language

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack

    I want a static varible like C language

    Hello,
    Under is C procedure:
    #include<stdio. h>
    #include<conio. h>
    void ab(int x)
    {
    if(x<5)
    {
    ab(x+1);
    printf("%d ",x);
    }
    }
    void main(void)
    {
    ab(1);
    getch();
    }

    Under is ASP procedure:
    <SCRIPT Language=JavaSc ript runat=server>
    var a;
    abc(0);
    function abc(b)
    {
    abc.prototype.x =b+1;
    if(abc.prototyp e.x<5)
    {
    abc(abc.prototy pe.x);
    Response.Write( abc.prototype.x );
    Response.Write( " ");
    }
    else
    return;
    }
    </SCRIPT>
    Run the C procedure shows "4 3 2 1 ",but load the ASP's procedure shows "5 5
    5 5 ".
    I want a JavaScript function like C function.That is to say,I want a varible
    which in the function is static.
    Thank you

  • Bob Barrows

    #2
    Re: I want a static varible like C language

    Jack wrote:[color=blue]
    > Hello,
    > Under is C procedure:
    > #include<stdio. h>
    > #include<conio. h>
    > void ab(int x)
    > {
    > if(x<5)
    > {
    > ab(x+1);
    > printf("%d ",x);
    > }
    > }
    > void main(void)
    > {
    > ab(1);
    > getch();
    > }
    >
    > Under is ASP procedure:
    > <SCRIPT Language=JavaSc ript runat=server>
    > var a;
    > abc(0);
    > function abc(b)
    > {
    > abc.prototype.x =b+1;
    > if(abc.prototyp e.x<5)
    > {
    > abc(abc.prototy pe.x);
    > Response.Write( abc.prototype.x );
    > Response.Write( " ");
    > }
    > else
    > return;
    > }
    > </SCRIPT>
    > Run the C procedure shows "4 3 2 1 ",but load the ASP's procedure
    > shows "5 5 5 5 ".
    > I want a JavaScript function like C function.That is to say,I want a
    > varible which in the function is static.
    > Thank you[/color]

    How's it feel to want? :-)

    Try .scripting.jscr ipt


    --
    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"


    Comment

    • Jack

      #3
      Re: I want a static varible like C language

      It's myself.This problem was already solved.

      Comment

      Working...