Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default global variables

    I would like to know the preferred way in which to define, store, and
    retrieve global varialbes in asp.net applications. I have read through past
    threads here and have seen mixed advice. Some say to define them in
    global.asax but I can't seem to reference them. Others say that they must
    be defined in the session_start and that they cannot be simply defined in
    global.asax. Yet others say just put them in any class anywhere and
    reference them.

    It seems the right answer would be defining them as session variables but I
    can't seem to reference them with session.myvariable
    Thanks,
    T


    Tina Guest

  2. Similar Questions and Discussions

    1. Global variables in AS3
      The documentation for AS3 tells me that a variable set as 'public' will be available everywhere. If I set public var myvar:String; at the top of...
    2. Global Variables problem
      Hi there.. i know this is a very newb question, but any way... need to know something. I had declared a global variable this way: on...
    3. Problem with global variables
      Hi All, I'm turning mad with global variables... In created a simple test script with 2 functions which worked fine but the other one i need...
    4. Global variables - application variables vs include file
      What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include...
    5. How can I see global variables with ProjectBuilder
      Loris Cecchinelli wrote: Menu->Debug->Expressions->varl.
  3. #2

    Default Re: global variables

    If you want the same variable across the application, you use Application
    variables and create them in the application_start event. If you need them
    individually for each session then you use session variables. You don't
    reference them assession.myvariable, it is actually a collection so you
    would reference them (in C#) as session["myvariable"]. Just remember that
    these are kept in server memory so if you have lots of sessions this can be
    a performance drag.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "Tina" <tinamseaburn@excite.com> wrote in message
    news:u87uHnSWDHA.2040@TK2MSFTNGP11.phx.gbl...
    > I would like to know the preferred way in which to define, store, and
    > retrieve global varialbes in asp.net applications. I have read through
    past
    > threads here and have seen mixed advice. Some say to define them in
    > global.asax but I can't seem to reference them. Others say that they must
    > be defined in the session_start and that they cannot be simply defined in
    > global.asax. Yet others say just put them in any class anywhere and
    > reference them.
    >
    > It seems the right answer would be defining them as session variables but
    I
    > can't seem to reference them with session.myvariable
    > Thanks,
    > T
    >
    >

    Mark Fitzpatrick Guest

  4. #3

    Default Global Variables

    I am trying to make it so a user can set a power level, and a ball will move a certain distance based on the power.

    I created a text field for the user power imput in sprite 3. The scripts for the button, and the ball are below.

    It works aright the first time you click on the button, but after that the ball stays stationary. Any tips would be helpful. I'm new to this.




    -----------button script---------

    global gPower

    on mouseup me

    gpower= sprite(3).member.text

    end

    ---------ball script----------
    global gPower
    property my
    property xvel, xaccel

    on beginsprite me
    my=sprite(me.spritenum)
    xvel=0
    xaccel=.1

    end

    on exitframe me

    xvel=xvel+xaccel
    if xvel>gPower then
    my.locH=my.locH
    else
    my.locH=my.locH+xvel
    end if


    end



    chefthor webforumsuser@macromedia.com Guest

  5. #4

    Default Re: Global Variables

    hi,
    [url]http://www.robotduck.com/learning/index.htm[/url]
    there are some really good examples here that you could download and
    reference

    hope that helps
    lee

    "chefthor" <webforumsuser@macromedia.com> wrote in message
    news:bgrgh7$m94$1@forums.macromedia.com...
    > I am trying to make it so a user can set a power level, and a ball will
    move a certain distance based on the power.
    >
    > I created a text field for the user power imput in sprite 3. The scripts
    for the button, and the ball are below.
    >
    > It works aright the first time you click on the button, but after that the
    ball stays stationary. Any tips would be helpful. I'm new to this.
    >
    >
    >
    >
    > -----------button script---------
    >
    > global gPower
    >
    > on mouseup me
    >
    > gpower= sprite(3).member.text
    >
    > end
    >
    > ---------ball script----------
    > global gPower
    > property my
    > property xvel, xaccel
    >
    > on beginsprite me
    > my=sprite(me.spritenum)
    > xvel=0
    > xaccel=.1
    >
    > end
    >
    > on exitframe me
    >
    > xvel=xvel+xaccel
    > if xvel>gPower then
    > my.locH=my.locH
    > else
    > my.locH=my.locH+xvel
    > end if
    >
    >
    > end
    >
    >

    LeeD Guest

  6. #5

    Default Global Variables

    Hey it's me again,

    I am wondering if there is a (secure) way to create a variable that is
    global. For example, I have an include file right now that defines a number
    of arrays for site configuration - eg:

    $FilePath = array ("Logs" => "MyLog/", "Templates" => "MyTemplate/");

    Lexically speaking, this is fine from the main script. The scope of the
    variable resides within the main script. However when I go into a function
    it is no longer in scope, obviously. I can always pass the information
    through an arguement ie

    WriteLog($FilePath['Logs'], 'error.log', $ErrorNum, $ErrorDetails);

    This works fine, however, it is a little cumbersome. I know avoiding
    use of global variables is good programming, but in this case it would make
    life much easier if I could define a few global variables. Can someone
    please tell me the best way to do this?

    Thanks
    /Aaron


    Aaron Murray Guest

  7. #6

    Default Re: Global Variables

    On Fri, 30 Jan 2004 20:00:03 GMT, "Aaron Murray" <__nospam__@hotmail@.com>
    wrote:
    > I am wondering if there is a (secure) way to create a variable that is
    >global. For example, I have an include file right now that defines a number
    >of arrays for site configuration - eg:
    >
    > $FilePath = array ("Logs" => "MyLog/", "Templates" => "MyTemplate/");
    >
    > Lexically speaking, this is fine from the main script. The scope of the
    >variable resides within the main script. However when I go into a function
    >it is no longer in scope, obviously. I can always pass the information
    >through an arguement ie
    >
    > WriteLog($FilePath['Logs'], 'error.log', $ErrorNum, $ErrorDetails);
    >
    > This works fine, however, it is a little cumbersome. I know avoiding
    >use of global variables is good programming, but in this case it would make
    >life much easier if I could define a few global variables. Can someone
    >please tell me the best way to do this?
    (a) The 'global $FilePath' statement to bring the global into scope.
    (b) The $_GLOBALS array, visible from all scopes.

    --
    Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
    <http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
    Andy Hassall Guest

  8. #7

    Default Global Variables

    Im having trouble understanding where I put code exactly. Can I have global
    variables with serverside script?

    When I create a variable outside of any functions it doesnt seem to be able to
    be read from within application functions (like application.connect). Can
    anybody point me in the right direction of understand how this whole dynamic
    works?

    smazr123 Guest

  9. #8

    Default Re: Global Variables

    I seem to remember reading something about the FMS Framework using _global for
    specific purposes (don't remember exactyl what it was), and therefore using
    _global elsewhere wasn't recommended.

    I like to assign variables to the application object (FMS creates the
    application object for you when the app starts) when I need a global var.

    application.myVar = "someValue"

    Now you can reference that application var from anywhere in your SSAS by using
    application.myVar

    JayCharles Guest

  10. #9

    Default Re: Global Variables

    Hello :)

    you can use the _global in SSAS ... it's easy


    in the main.asc :

    _global = this ;

    and now you can use this scope reference to call the global target when
    you want.

    All class in SSAS must be implemented in the global scope. The _global
    scope it's the root environnement of the main.asc file.

    For me it's a bad idea to override the application object with all the
    global methods...

    EKA+ :)

    JayCharles a écrit :
    > I seem to remember reading something about the FMS Framework using _global for
    > specific purposes (don't remember exactyl what it was), and therefore using
    > _global elsewhere wasn't recommended.
    >
    > I like to assign variables to the application object (FMS creates the
    > application object for you when the app starts) when I need a global var.
    >
    > application.myVar = "someValue"
    >
    > Now you can reference that application var from anywhere in your SSAS by using
    > application.myVar
    >
    ekameleon Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139