Accessing variable in a loop

I cannot access this variable from outside the loop. I know
it has to be something very simple. When tracing the variable, it
comes back as undefined. Please help.. Thanks

when you prefix a variable with var, you make it local to the
function that contains the variable.

Similar Messages

  • How to access variables outside user exit

    Hi,
    I'm working with a user exit and my problem is that in a particular moment I have to access variables located outside the scope of the user exit (they are in a standard program)
    How can I reach these variables?
    thanks in advance

    Hi,
    If they are global variables then you can access them using Global assign technique,
    For example,
    FIELD-SYMBOLS: <fs_value> TYPE ANY.
    ASSIGN ('(SAPMV45A)XVBAK') TO <fs_value>.
    It is basically,
    ASSIGN ('(<Std. Program Name>)<Variable name>') TO <field symbol>.
    NOTE: To make sure they are accessible in your user exit, just put a break-point in the user exit and once you are there in debugging, type in,
    (<Std. Program Name>)<Variable name> in the Field names section and if it does not show it in RED then it is accessible..
    Hope this helps.. 
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • How to Access Variables defined in the PopUpWindow

    Hi Friends
    I am building a flex site using flex builder 2.....
    Here I need your help.....
    My Problem is how to store a variable from a popup window
    I have this problem while in the login window comes as popup
    while clicking login button in the page a popup where user
    can enter username and password...
    after submitting if the login is successufl the popup
    vanish...
    After a successful login I need to store the logged user name
    in the main index page but I am not able to store
    At first I created a variable 'loggedUsername' in the popup
    panel and after success log i assigned the username to it ... after
    it i am not able to get the loggedUsername..
    doubting I defined the variable in the main index.mxml page
    but this variable is not accessible from the loginwidow.mxml page
    where the popup will function...
    Heip me
    how to store the name if the user login is success..
    thanks
    Chintu...

    Lets say you have a public property in your application like
    public var name:String = "John Smith";
    to access this using an inline item renderer:
    <mx:itemRenderer>
    <mx:Component>
    <mx:VBox>
    <mx:TextInput text={outerDocument.name} />
    </mx:VBox>
    </mx:Component>
    </mx:itemRenderer>
    To access variables of the applicaton you can use
    Application.application.name (for example) to reference "global"
    variables, so you might also use this technique. With an inline
    item renderer, the outerDocument property will refer to the
    component which contains the renderer.

  • How to access variables declared in main mxml in itemrenderer files

    Hi,
    I have a main mxml which has a cutomRenderer that defines two
    mxml components
    namely raidobutton and textinput.
    Now in this TextInput.as i need to access variable defined in
    main mxml.
    Please suggest a way.
    Thanks,
    Lucky

    Lets say you have a public property in your application like
    public var name:String = "John Smith";
    to access this using an inline item renderer:
    <mx:itemRenderer>
    <mx:Component>
    <mx:VBox>
    <mx:TextInput text={outerDocument.name} />
    </mx:VBox>
    </mx:Component>
    </mx:itemRenderer>
    To access variables of the applicaton you can use
    Application.application.name (for example) to reference "global"
    variables, so you might also use this technique. With an inline
    item renderer, the outerDocument property will refer to the
    component which contains the renderer.

  • Problem using local variable in event loop

    I have a state machine from which I want to monitor various controls, including "Start" and "Stop" buttons.  Not every state needs to monitor the controls.  At present, most states run timed loops.  In the first state that reads the front panel, I have an Event structure (inside a While loop) that monitors the various controls' Change Value events.  For numeric controls, I update variables (in shift registers) as needed.  The "Start" button is used to end the While loop controlling the Event structure, allowing the State to exit to the next state.
    My problem comes in subsequent states that employ this same idea.  Here, I put a Local Variable bound to the Start button and use the same code, but it frequently happens that when I enter this particular state, I cannot "turn on" the control -- I push the button, but it stays off.  Curiously, if it was On when I enter, I can turn it off, but then I'm stuck not being able to turn it on.
    I mocked up a very simply routine that illustrates this.  There are two sequences (corresponding to the two states).  Both use an Event loop with a local variable bound to my Stop button (really this is an LED control with custom colors).  I've deliberately moved the "initialization" (the declaration of the control in the block diagram) out of the Event loops -- putting it inside the first loop modifies the behavior in another strange way.
    Here's my thinking on how I would expect this to work:  The code outside Event Loop 1 should have little effect.  Assume the Stop button is initially Off.  You will "sit" in Event Loop 1 until you push the Stop button, changing its value to True; this value will be passed out of the Event case and cause the first While loop to exit.  You now enter the second sequence.  As I understand the Exit tunnel, it defaults to "False", so I'd expect to stay in the second Event loop until I turn the Stop button from On to Off, which will pass out a False, and keep me in the While for one more button push.  However, this doesn't happen -- I immediately exit, as though the "True" value of the Stop local variable is being seen and recognized by the Event loop (even though it hasn't changed, at least not in the context of this second loop).
    An even more curious thing occurs if I start this routine with the Stop button turned on.  Now I start in my Event loop waiting for a change, but this time the change will be from On to Off, which won't cause an exit from the frame.  This will be reflected by having the While loop count increment.  We should now be in the state of the example above, i.e. in an Event loop waiting for the control to be pushed again, and turned On.  However, clicking the control has no effect -- I cannot get it to "turn on".
    Where am I going astray in my thinking?  What is it about this method of doing things that violates the Labview paradigm?  As far as I can tell, what I'm doing is "legal", and I don't see the flaw in my reasoning, above (of course not -- otherwise I'd have fixed it myself!).  Note that because I'm using local variables inside Event loops (and I'm doing this because there are two places in my code where I want to do such testing), the Stop control is not latching (as required).  Is there something that gets triggered/set when one reads a latched control?  Do I need to do this "manually" using my local variable?
    I'll try to attach the simple VI that illustrates this behavior.
    Bob Schor
    Attachments:
    Simple Stop Conundrum.vi ‏14 KB

    altenbach wrote:
    Ravens Fan wrote:
    NEVER have multiple event structures that share the same events. 
    Actually, that's OK.  NOT OK is having multiple event structures in the same sequence structure.
    See also: http://forums.ni.com/ni/board/message?board.id=170&message.id=278981#M278981
    That's interesting.  I had always thought I read more messages discouraging such a thing rather than saying it was okay.  Your link lead me to another thread with this message. http://forums.ni.com/ni/board/message?board.id=170&message.id=245793#M245793.  Now that thread was mainly concentrating on registered user events which would be a different, but related animal. 
    So if you have 2 event structures they each have their own event queue?  So if you have a common event, one structure pulls it off its event queue and it does not affect the other structure's event queue?  I guess the inherent problem with this particular VI was that the second event structure locked the front panel.  Since the code never got to that 2nd event structure because the  first loop never stopped because the change was from true to false.  After reading your post and the others, I did some experimentation and turned off the Lock front panel on the 2nd structure, and that prevented the lockup of the program.
    Overall, the example VI still shows problems with the architecture and I think your answer should put the original poster on the right track.  I think as a rule I would probably never put the same event in multiple structures, I feel there are better ways to communicate the same event between different parts of a program,  but I learned something by reading your reply and about how the event structures work in the background.  Thanks.

  • Using variables in a loop

    Hello and thanks in advance!  I'm attempting to insert records into a temp table using a loop.  I have many declared variables that will be used as criteria in the query.  Since the variable are all named the same other than a ascending
    numberic to the name, how would I get a variable in a loop to substitute the "numberic" part of the variables? I've created some sudo sql for what I'm trying to achieve:
    Declare @Start1 as Date = '2014-01-01'
    Declare @Start2 as Date = '2014-15-01'
    Declare @Start3 as Date = '2014-18-01'
    Declare @i INT = 1
    WHILE @i < 20
         SELECT .... INTO #MyTemp ...
         WHERE OrderDate Like @Start + @i       --This is the line I cant seem to get working.
         SET @i = @i +1
    END

    >>You have just described a 1950's file system using punch cards (also called unit records) writing to a scratch tape with Autocoder. You have no idea how to write SQL or program in a declarative language. We do not sure temporary files or loops. The
    goal is to write one statement that does the task. We do not use local variables; we use expressions that compute their values.<<
    What are you talking about or your point? I dont ever remember asking about temporary files. Who is the 'We' you keep referring to?  why did you even bother posting with a negative and absolutely unhelpful reponse.
    >>That is called an “array” in procedural programming and a repeated group in RDBMS. It also violated First Normal Form (1NF). <<
    Wrong. I said that I created variables.  I did not say I created an array.  Also, you have no idea of what I was trying to accomplish. 
    >>
    If you truly do not care about ever being a good programmer, you can kludge this 1950's code with dynamic SQL. But I will use you as a bad example in my books :(  <<
    I have no idea who you are and take offense at your entire post attempting to tear me down.  Your arrogance and attitude appears to have grown with your forum points.  I'm still confused as to why somebody with your so-called expertise
    posted such an a$$#*%! comment.

  • Can't access variables in specific S7-1200 DB's in LabVIEW project

    Hi all,
    I'm trying to establish a connection between LabVIEW and a Siemens S7-1200 though Ethernet and SIemens OPC Server.
    The physical connection is OK (I can ping S7-1200 with no problem).
    When I needed to access variables from specifics DB's inside S7-1200 ( I want to access variable DB190,X0.4), I called Siemens support and they said I had to modify the variable's definition when using OPC Scout, from "MX0.4" to "DB190,X0.4", and then it was possible to access this variable.
    Same solution (renaming the path) applies to NI OPC Client, I can read and write variables properly.
    My problem is that when I try to add variables in LabVIEW Project, I can't find those variables whose address were modified, so I can't access the correct variable in my program.
    I tried to change the variable path in Multiple Variable Editor, but it doesn't work either.
    Any suggestions on what I can try??

    First: Avoid the ODBC/JDBC Bridge if at all possible.
    It's the worst JDBC driver I've ever seen. It's buggy
    and a great hindrance both to learning and to
    producing usefull code.I agree that there might be problems with M$ Access, but there are problems with all databases, including MySQL (e.g., no referential integrity in free download version). It's capable enough for the query the OP is trying to execute.
    The problem is with his code, not Access or the bridge driver. He'll go through a lot of effort to switch databases and still have this problem. Better to understand what HE'S done wrong and fix it so he'll do it correctly for all databases, including Access.
    You just need to be more careful with your query, I'm sure.
    %

  • Access variables in Package.

    Hi I have a apackage called share.server , in which I have defined
    Hashtable hash;
    i have another file in share package as Impl, here i want to call the "hash"
    how can i access the same "hash" in Impl.java from FilServer which is in share.server package.
    Please respond urgent, assignment is due soon.
    Thanks for any response.

    what?!
    variables belong to classes, not packages. If you want to access variables between classes you need to define some kind of public interface for them (getters and setters... ring any bells?). This is basic basic OOP, and is called encapsulation. First thing you need to do is get a basic 'OOP with java' type book and read it fully. We can't help you if you can't help yourself/

  • Access variables within a timer

    How can I access variables within a timer?
    I mean variables, that I can use in another class that extends applet i.e.?

    The Code can be compiled now with the Java Compiler.
    But the image won't move on the screen.
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    public class ChangingApplet extends Applet {
      private Image EricsBild;
      private int x,y;
      private TimerTask update;
      public void start() {
      EricsBild = getImage(getCodeBase(), "heuschrecke.gif");
      x=5;y=5;
        update = new TimerTask() {
          public void run() {
            if (x<300) x++;
            if (y<200) y++;
            if (x>3) x--;
            if (y>2) y--;
            repaint();
        Timer t = new Timer(false);
        t.schedule(update, 1000, 1000);
      public void stop() {
        update.cancel();
      public void paint(Graphics g) {
        g.drawImage(EricsBild,x,y,this);
    }

  • Accessing variable in main mxml from component

    I have the following problem, i have a main mxml and
    component mxml which i import in my main file. I need to access
    variable in main mxml file from that component but i don't know how
    to reference my main mxml from component? Can someone please help
    me with this?
    thanks in advance

    Try this
    this.parentApplication.main_mxml.variableID = 34;
    Rgds
    JFB
    "msabljic" <[email protected]> wrote in
    message
    news:fd2u5k$a17$[email protected]..
    >I have the following problem, i have a main mxml and
    component mxml which i
    > import in my main file. I need to access variable in
    main mxml file from
    > that
    > component but i don't know how to reference my main mxml
    from component?
    > Can
    > someone please help me with this?
    >
    > thanks in advance
    >

  • Accessing Data within while loops

    I have LabView 6.0
    I have a while loop for my GUI that accesses various sub VIs. One of the Sub VI is a LED on/off thing, which basically checks the communication with the PIC board that I have. For turning the LED on or off, I have to sent a unique command.
    Since the Sub VI for the LED on/off is inside a while loop it continuously executes. I want the SubVI to execute only when the status of the boolean controlling the LED has changed from the previous value. I tried giving a feedback from the SubVI to indicate whether there is a change, but Labview will not allow such loops.
    I then took the SubVI outside the while loop, keeping the boolean control (so that it continuously checks) inside the while loop. I would like the SubVI to execute depending on the boolean control change. I tried using occurances, but I think these execute only once. I tried accessing the boolean control through a local variable, but the value of the local variable would not change outside of the while loop. (even tried property indicators).
    Any solution would be appreciated.
    I could post the VI, but there are too many sub VIs... Dunno if it would be appreciated.
    Thanks!

    If you need to post a VI, it is best to strip out those parts which do not have any effect on the problem you are facing. With subVIs, do a Save with Options..>>Development Distribution. This will create an .llb file with your VI and subVIs.
    Queues and global variables can transfer data between independent nodes. I am not sure when the datatypes of queues changed. In LV6 you may need to flatten your data to string typpe before passing it to a queue. The functional global or LV2 style global is a subVI consisting of a loop which executes only once and which contains the data in an uninitialized shift register. Many threads on this forum have discussed these options.
    Lynn

  • Accessing variables and functions between loaded external swfs?

    Using AS 3.0: Say I have a menu.swf that loads a content.swf
    below it using the following
    var newContent:Loader = new Loader();
    newContent.load(new URLRequest("fowContent.swf"));
    addChildAt(newContent,0);
    Now say I have a frame label in newContent that is an
    animation ending the display of that swf. Upon clicking of another
    menu button in menu.swf, can I access the content's ending sequence
    by:
    newContent.gotoAndPlay(newContent.endingSequence);
    Also can you use while loops in AS 3.0? I would like to have
    a boolean variable "ended" in the newContent that becomes true
    after the ending animation has played.
    while ( newContent.ended != true)
    //wait
    then have it run the function to load and display the new
    content.swf

    quote:
    Originally posted by:
    kglad
    p.s. you can't use a for-loop and you can't use a while-loop
    to effect any time delays. they both execute from beginning to end
    before anything is updated on-stage and no other code can execute
    outside of those loops (unless called from within the loop).
    Thank you very much for the help.
    Would I need to declare a MovieClip variable before using
    that statement or does that automatically cast newContent as a
    movieclip and go to the frame?
    So in order to achieve the flow I'm looking for.
    I'll have this in the menu.swf looking for clicks. It will
    run a function in the content.swf that runs the ending sequence and
    receives a string variable which is a concatenation of the
    buttonclicked (which is also the filename of next content) and
    .swf. (can I cast the event.target.name into a string the same way
    you casted the other into a movieclip?)
    function buttonClick(event:MouseEvent):void //in the menu.swf
    var nextFile:string = string(event.target.name) + ".swf";
    MovieClip(newContent.contentLoaderInfo.content).endSequence(nextFile)
    fowContent.addEventListener(MouseEvent.CLICK, buttonClick);
    In the content.swf I will have a public variable nextContent
    and the function that the menu.swf calls, which begins the ending
    sequence.
    public var nextContent:string;
    function endSequence(nextFile:string)
    nextContent = nextFile;
    gotoAndPlay(endingSequence);
    Then at the end of the movie sequence I could call this
    function that passes back the variable that was modified by the
    previous function and runs the loader.
    parent.loadNext(nextContent) //in the content.swf
    function loadNext(nextContent:string) //function in menu.swf
    newContent.load(new URLRequest(nextContent));
    addChildAt(newContent,0);
    I'm sure theres a better way to do this, and I don't even
    know if this will work. But I'd like to make sure it makes sense
    before I try to implement it.

  • Changing variable name within loop

    Instead of typing oit 8 different versions of this loop, I'd like to do something this where i increases value to define a new variable:
    for (int i = 1; i < 9; i++)
                double lbs[i] = (((dis * 2000) / 3456) * (ve)) * pr * 0.069 / 100;
                BigDecimal bd[i] = new BigDecimal (lbs);
    bd[i] = bd[i].setScale (1,BigDecimal.ROUND_UP);
    lbs[i] = bd[i].doubleValue ();
    String tflow[i] = Double.toString (lbs[i]);
    oFlow[i].setText (tflow[i]);
    i++;
    In PHP that's how I do it, but how about Java? I tried searching for "variable variables" since that's the only want I know how to describe it.

    I put what you gave me inside of public void CalcBoost() { ... } and I'm getting the error:java.lang.NullPointerException
            at Calculator.CalcBoost(Calculator.java:751)
            at Calculator.iBoostActionPerformed(Calculator.java:672)
            at Calculator.access$700(Calculator.java:69)
            at Calculator$8.actionPerformed(Calculator.java:299)
            at javax.swing.JTextField.fireActionPerformed(JTextField.java:491)
            at javax.swing.JTextField.postActionEvent(JTextField.java:672)
            at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:786)
            at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1530)
            at javax.swing.JComponent.processKeyBinding(JComponent.java:2438)
            at javax.swing.JComponent.processKeyBindings(JComponent.java:2473)
            at javax.swing.JComponent.processKeyEvent(JComponent.java:2401)
            at java.awt.Component.processEvent(Component.java:4909)
            at java.awt.Container.processEvent(Container.java:1569)
            at java.awt.Component.dispatchEventImpl(Component.java:3615)
            at java.awt.Container.dispatchEventImpl(Container.java:1627)
            at java.awt.Component.dispatchEvent(Component.java:3477)
            at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713)
            at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627)
            at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831)
            at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741)
            at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
            at java.awt.Component.dispatchEventImpl(Component.java:3506)
            at java.awt.Container.dispatchEventImpl(Container.java:1627)
            at java.awt.Window.dispatchEventImpl(Window.java:1606)
            at java.awt.Component.dispatchEvent(Component.java:3477)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)This now points to: for (int i = 0; i < oFlow.length; i++)

  • How to access variables in webservice

    Hai,
    I am using SAP Netweaver Developer Studio. I want to handle the error codes by using a variable in the session bean. but i am not able to access the variable . please help me asap.

    ok, the answer is here
    http://blog.flexexamples.com/2008/08/28/creating-a-component-instance-by-class-name-in-act ionscript-30/

  • Assigning value to array type variable in a loop

    Hi
    I have a scenario in which i am assigning value from a array type variable(x) to the invoke variable of a database adapter. The variable x is exact replica of the invoke variable.
    My copy operation in assign activity looks like this-
    <copy>
    <from variable="Var" part="InputParameters"
    query="/ns7:InputParameters"/>
    <to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"
    part="InputParameters"
    query="/ns7:InputParameters *(* bpws:getVariableData('iterator') *)* "/>
    </copy>
    It is inside a while loop activity.
    PS *()* are square brackets
    But it is erroring out at run time.
    Does anybody has an alternate idea to assign value to an array type?.
    i have seen that while extracting value from an array type variable it works fine
    A similar kind of operation is shown below.
    <copy>
    <from variable="Var" part="InputParameters"
    query="/ns7:InputParameters *(* bpws:getVariableData('iterator') *)* "/>
    <to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"
    part="InputParameters"
    query="/ns7:InputParameters"/>
    </copy>
    Thanks
    Ayush
    Edited by: Ayush fujitsu on Aug 14, 2009 4:36 AM

    Hi Ayush
    I suppose you are getting some error like "source node returns multiple elements".
    In second case there is no problem because you are assigning *InputParameters[bpws:getVariableData('iterator')]* (+suppose InputParameters[1]+) to target. Here it works fine because you are fetching oonly 1 value from source and assigning it to the target.
    Now in first case you are saying copy InputParameters to target[1] suppose. You know that source is an array which contains multiple index so which index field from the source will be assigned to the target.
    Try your process with only 1 source value it will work but when multiple values will be there it will fail. You have to merge both the cases and it will look like
    *<copy>*
    *<from variable="Var" part="InputParameters"*
    query="/ns7:InputParameters ( bpws:getVariableData('iterator') ) "/>
    *<to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"*
    part="InputParameters"
    query="/ns7:InputParameters ( bpws:getVariableData('iterator') ) "/>
    *</copy>*
    And the easiest way to do this is by the transform activity as said above.
    Regards
    Suryaveer
    Edited by: Suryaveer on Aug 15, 2009 11:19 PM

Maybe you are looking for