How do I exit a For Loop? Just Kidding! VISA and LVRT and App

Builder/Installer. Hi,
I am using LV6i and App Builder. I built a little program using the
VISA Config, Read Write, and Bytes at Serial port vi's.
I attached the build file also for ref.
[Image]
When built using the option to include the run time engine then
installed on a laptop, I get an illegal operation in lvrt.dll.
I have tried to install VISA on the laptop but this makes no difference.
I am new to VISA so any help is appreciated.
Thanks in advance for any help.
[See first answer for additional information]

[Attachment(s) for question]
Attachments:
Simple_Terminal.bld ‏2 KB

Similar Messages

  • How to terminate or exit a for loop when the user clicks on stop button

    Actually my problem is to stop a loop when i click on stop button.
    example:i have two buttons 'start' and 'stop'
    in start buttom i wrote a for loop as
    dim i as integer
    For i=1 To 100000
    print i
    Next
    when i click on start buuton it prints 'i' value up tp 100000.
    my question is when i click on 'Stop' button the for loop has to terminate or Exit from the  loop and should stops the execution.
    Is it possible to termianate or Exit the 'for loop'
    PS.Shakeer Hussain
    Hyderabad

    I am unable to stop the loop and application not at all allowing to Press the Stop button.
    It seems like Hung, any advise ?
    Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
            btnStop.Enabled = True
            btnSelectFile.Enabled = False
            btnStart.Enabled = False
            btnStop.Focus()
            Dim strFileName As String = txtFileName.Text.ToString
            Dim strLineText As String
            If System.IO.File.Exists(strFileName) = True Then
                Dim objReader As New System.IO.StreamReader(strFileName)
                While objReader.Peek() <> -1 And stopclick = False
                    strLineText = objReader.ReadLine()
                    MsgBox(strLineText, MsgBoxStyle.Information)
                    Application.DoEvents()
                    Thread.Sleep(My.Settings("strDelay") * 1000)
                    'System.Diagnostics.Process.Start(My.Settings("strFireFoxLocation"), strLineText)
                End While
            End If
        End Sub
        Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
            stopclick = True
            btnSelectFile.Enabled = True
            btnStart.Enabled = True
            btnStop.Enabled = False
        End Sub
    Raman Katwal
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How can I repeat a for loop, once it's terms has been fulfilled???

    Well.. I've posted 2 different exceptions about this game today, but I managed to fix them all by myself, but now I'm facing another problem, which is NOT an error, but just a regular question.. HOW CAN I REPEAT A FOR LOOP ONCE IT HAS FULFILLED IT'S TERMS OF RUNNING?!
    I've been trying many different things, AND, the 'continue' statement too, and I honestly think that what it takes IS a continue statement, BUT I don't know how to use it so that it does what I want it too.. -.-'
    Anyway.. Enought chit-chat. I have a nice functional game running that maximum allows 3 apples in the air in the same time.. But now my question is: How can I make it create 3 more appels once the 3 first onces has either been catched or fallen out the screen..?
    Here's my COMPLETE sourcecode, so if you know just a little bit of Java you should be able to figure it out, and hopefully you'll be able to tell me what to do now, to make it repeat my for loop:
    Main.java:
    import java.applet.*;
    import java.awt.*;
    @SuppressWarnings("serial")
    public class Main extends Applet implements Runnable
         private Image buffering_image;
         private Graphics buffering_graphics;
         private int max_apples = 3;
         private int score = 0;
         private GameObject player;
         private GameObject[] apple = new GameObject[max_apples];
         private boolean move_left = false;
         private boolean move_right = false;
        public void init()
            load_content();
            setBackground(Color.BLACK);
         public void run()
              while(true)
                   if(move_left)
                        player.player_x -= player.movement_speed;
                   else if(move_right)
                        player.player_x += player.movement_speed;
                   for(int i = 0; i < max_apples; i++)
                       apple.apple_y += apple[i].falling_speed;
                   repaint();
                   prevent();
                   collision();
              try
              Thread.sleep(20);
              catch(InterruptedException ie)
              System.out.println(ie);
         private void prevent()
              if(player.player_x <= 0)
              player.player_x = 0;     
              else if(player.player_x >= 925)
              player.player_x = 925;     
         private void load_content()
         MediaTracker media = new MediaTracker(this);
         player = new GameObject(getImage(getCodeBase(), "Sprites/player.gif"));
         media.addImage(player.sprite, 0);
         for(int i = 0; i < max_apples; i++)
         apple[i] = new GameObject(getImage(getCodeBase(), "Sprites/apple.jpg"));
         try
         media.waitForAll();     
         catch(Exception e)
              System.out.println(e);
         public boolean collision()
              for(int i = 0; i < max_apples; i++)
              Rectangle apple_rect = new Rectangle(apple[i].apple_x, apple[i].apple_y,
    apple[i].sprite.getWidth(this),
    apple[i].sprite.getHeight(this));
              Rectangle player_rect = new Rectangle(player.player_x, player.player_y,
    player.sprite.getWidth(this),
    player.sprite.getHeight(this));
              if(apple_rect.intersects(player_rect))
                   if(apple[i].alive)
                   score++;
                   apple[i].alive = false;
                   if(!apple[i].alive)
                   apple[i].alive = false;     
         return true;
    public void update(Graphics g)
    if(buffering_image == null)
    buffering_image = createImage(getSize().width, getSize().height);
    buffering_graphics = buffering_image.getGraphics();
    buffering_graphics.setColor(getBackground());
    buffering_graphics.fillRect(0, 0, getSize().width, getSize().height);
    buffering_graphics.setColor(getForeground());
    paint(buffering_graphics);
    g.drawImage(buffering_image, 0, 0, this);
    public boolean keyDown(Event e, int i)
         i = e.key;
    if(i == 1006)
    move_left = true;
    else if(i == 1007)
         move_right = true;
              return true;     
    public boolean keyUp(Event e, int i)
         i = e.key;
    if(i == 1006)
    move_left = false;
    else if(i == 1007)
         move_right = false;
    return true;
    public void paint(Graphics g)
    g.drawImage(player.sprite, player.player_x, player.player_y, this);
    for(int i = 0; i < max_apples; i++)
         if(apple[i].alive)
              g.drawImage(apple[i].sprite, apple[i].apple_x, apple[i].apple_y, this);
    g.setColor(Color.RED);
    g.drawString("Score: " + score, 425, 100);
    public void start()
    Thread thread = new Thread(this);
    thread.start();
    @SuppressWarnings("deprecation")
         public void stop()
         Thread thread = new Thread(this);
    thread.stop();
    GameObject.java:import java.awt.*;
    import java.util.*;
    public class GameObject
    public Image sprite;
    public Random random = new Random();
    public int player_x;
    public int player_y;
    public int movement_speed = 15;
    public int falling_speed;
    public int apple_x;
    public int apple_y;
    public boolean alive;
    public GameObject(Image loaded_image)
         player_x = 425;
         player_y = 725;
         sprite = loaded_image;
         falling_speed = random.nextInt(10) + 1;
         apple_x = random.nextInt(920) + 1;
         apple_y = random.nextInt(100) + 1;
         alive = true;
    And now all I need is you to answer my question! =)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    package forums;
    import java.util.Random;
    import javax.swing.Timer;
    import javax.imageio.ImageIO;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class VimsiesRetardedAppleGamePanel extends JPanel implements KeyListener
      private static final long serialVersionUID = 1L;
      private static final int WIDTH = 800;
      private static final int HEIGHT = 600;
      private static final int MAX_APPLES = 3;
      private static final Random RANDOM = new Random();
      private int score = 0;
      private Player player;
      private Apple[] apples = new Apple[MAX_APPLES];
      private boolean moveLeft = false;
      private boolean moveRight = false;
      abstract class Sprite
        public final Image image;
        public int x;
        public int y;
        public boolean isAlive = true;
        public Sprite(String imageFilename, int x, int y) {
          try {
            this.image = ImageIO.read(new File(imageFilename));
          } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("Bailing out: Can't load images!");
          this.x = x;
          this.y = y;
          this.isAlive = true;
        public Rectangle getRectangle() {
          return new Rectangle(x, y, image.getWidth(null), image.getHeight(null));
      class Player extends Sprite
        public static final int SPEED = 15;
        public Player() {
          super("C:/Java/home/src/images/player.jpg", WIDTH/2, 0);
          y = HEIGHT-image.getHeight(null)-30;
      class Apple extends Sprite
        public int fallingSpeed;
        public Apple() {
          super("C:/Java/home/src/images/apple.jpg", 0, 0);
          reset();
        public void reset() {
          this.x = RANDOM.nextInt(WIDTH-image.getWidth(null));
          this.y = RANDOM.nextInt(300);
          this.fallingSpeed = RANDOM.nextInt(8) + 3;
          this.isAlive = true;
      private final Timer timer = new Timer(200,
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            repaint();
      public VimsiesRetardedAppleGamePanel() {
        this.player = new Player();
        for(int i=0; i<MAX_APPLES; i++) {
          apples[i] = new Apple();
        setBackground(Color.BLACK);
        setFocusable(true); // required to generate key listener events.
        addKeyListener(this);
        timer.setInitialDelay(1000);
        timer.start();
      public void keyPressed(KeyEvent e)  {
        if (e.getKeyCode() == e.VK_LEFT) {
          moveLeft = true;
          moveRight = false;
        } else if (e.getKeyCode() == e.VK_RIGHT) {
          moveRight = true;
          moveLeft = false;
      public void keyReleased(KeyEvent e) {
        moveRight = false;
        moveLeft = false;
      public void keyTyped(KeyEvent e) {
        // do nothing
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        //System.err.println("DEBUG: moveLeft="+moveLeft+", moveRight="+moveRight);
        if ( moveLeft ) {
          player.x -= player.SPEED;
          if (player.x < 0) {
            player.x = 0;
        } else if ( moveRight ) {
          player.x += player.SPEED;
          if (player.x > getWidth()) {
            player.x = getWidth();
        //System.err.println("DEBUG: player.x="+player.x);
        Rectangle playerRect = player.getRectangle();
        for ( Apple apple : apples ) {
          apple.y += apple.fallingSpeed;
          Rectangle appleRect = apple.getRectangle();
          if ( appleRect.intersects(playerRect) ) {
            if ( apple.isAlive ) {
              score++;
              apple.isAlive = false;
        g.drawImage(player.image, player.x, player.y, this);
        for( Apple apple : apples ) {
          if ( apple.isAlive ) {
            g.drawImage(apple.image, apple.x, apple.y, this);
        g.setColor(Color.RED);
        g.drawString("Score: " + score, WIDTH/2-30, 10);
      private static void createAndShowGUI() {
        JFrame frame = new JFrame("Vimsies Retarded Apple Game");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new VimsiesRetardedAppleGamePanel());
        frame.pack();
        frame.setSize(WIDTH, HEIGHT);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args) {
        SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              createAndShowGUI();
    }Hey Vimsie, try resetting a dead apple and see what happens.

  • Stopping output tasks properly before exiting a For-loop

    Hi,
    I've been having some trouble exiting a For-loop conditionally. The problem is that when the loop is stopped conditionally (a button is pressed) the DAQ (NI USB 6353) outputs get stuck to whatever value they were in. I tried stopping the DAQ Assistant output task (1 sample on demand)  before exiting the loop but that didn't solve the problem. Should this perhaps be done one iteration before exiting the loop or can it be done in the same iteration round?
    What would be the "right" way to exit a for loop with output tasks so that the output signals would be 0V after exiting? I know that I could "force" feed the DAQ Assistant with 0V control before exiting but in this case that would be quite difficult...
    Any ideas? Help is appriciated.

    Yes, I get it... However at this point I don't think that's an option.
    Would this kind of solution work? ( I am not able to test all possible solutions in the real system which is why I would like to get a confirmation first)
    The idea is to connect the output of the "Or" port to the "Stop" -ports of the DAQ Assistants in the loop.
    Edit. Will the output automatically go to 0V if I just stop the task? I am not really sure about this.
    Thank you.
    Attachments:
    exit-loop.jpg ‏8 KB

  • How to get out of for loop in eclipse debugging

    How to get out of for loop in eclipse debugging for java classes ?
    I am in a for loop in a code. i want to get out of it ...but how ?

    is changing the behaviour of a running class like that really going to be any use for debugging? what's the actual problem?

  • Does Anyone Knows How To Disable The "Check For Updates" Option in Adobe Edge Code and Reflow?

    Does Anyone Knows How To Disable The "Check For Updates" Option in Adobe Edge Code and Reflow?
    Thanks in Advance

    I don't think there is a way for Edge Code. I'm not sure about Reflow.
    Why don't you just upgrade? That will stop the notifications.
    Randy

  • How to code a parallel 'for loop' and 'while loop' where the while loop cannot terminate until the for loop has finished?? (queues also present)

    I've attached a sample VI that I just cannot figure out how to get working the way that I want.  I've labeled the some sections with black-on-yellow text boxes for clarity during the description that follows in the next few sentences.  Here's what I want:
    1) overall -- i'm intend for this to be a subVI that will do data acquisition and write the data to a file.  I want it to use a producer/consumer approach.  The producer construct is the 'parallel for loop' that runs an exact number of times depending on user input (which will come from the mainVI that is not included).  For now I've wired a 1-D array w/ 2 elements as a test case.  During the producer loop, the data is acquired and put into a queue to be delt with in the consumer loop (for now, i just add a random number to the queue).
    2) the consumer construct is the 'parallel while loop'.  It will dequeue elements and write them to a file.  I want this to keep running continuously and parallel until two conditions are met.
          i. the for loop has finished execution
          ii. the queue is empty.
       when the conditions are met, the while loop will exit, close the queue, and the subVI will finish. (and return stuff to mainVI that i can deal with on my own)
    Here's the problems.
    1)  in the "parallel for loop" I have a flat sequence structure.. I haven't had time to incorporate some data dependency into these two sequential sections, but basically, I just care that the "inner while loop" condition is met before the data is collected and queued.  I think I can do this on my own, but if you have suggestions, I'm interested.
    2)  I can easily get the outer for and while loops to run sequentially, but I want them to run in parallel.  My reasoning for this is that that I anticipate the two tasks taking very different amounts of time. .. basically, I want the while loop to just keep polling the queue to get everything out of it (or I suppose I could somehow use notifiers - suggestions welcome)...  the thing is, this loop will probably run faster than the for loop, so just checking to see that the queue is empty will not work... I need to meet the additional condition that nothing else will be placed in the queue - and this condition is met when the for loop is complete. basically, I just can't figure out how to do this.
    3) for now, I've placed a simple stop button in the 'parallel while loop', but I must be missing something fundamental here, because the stop button is totally unresponsive.  i.e. - when I press it, it stays depressed, and nothing happens.
    suggestions are totally welcome!
    thanks,
    -Z
    Attachments:
    daq01v1.vi ‏59 KB

    I'd actually like to add a little more, since I thought about it a bit and I'm still not quite certain I understand the sequence of events...
    altenbach wrote:
    zskillz wrote:
    So i read a bit more about the 'dequeue element' function, and as I understand it, since there is no timeout wired to the dequeue element function, it will wait forever, thus the race condition I suggested above can never happen!
    Yes, you got it!
    As I've thought about it a bit more, there's a few things that surprise me... first, the reason the 'dequeue element while loop' errors is not because there's nothing in the queue, it's becaues the queue has been released and it's trying to access that released queue...   However the problem I have is this --- Even though there's no timeout wired to the dequeue element, I still would think that the while loop that contains it would continue to run at whatever pace it wanted -- and as i said before.. most of the time, it would find that there is nothing to dequeue, but once in a while, something is there.  however, it seems that this loop only runs when something has been enqueued.  the reason I say this is illustrated in the next code sample MODv2 that's attached below.  I've added a stop button to the "queue size while loop" so the program runs until that is pressed.  I've also added a simple conditional in the "dequeue while loop"  that generates a random number if it a button is pressed... but this button is totally non-responsive... which means to me that the "dequeue while loop" isn't actually continuously running, but only when an element is added to the queue.  this still seems almost like the 'dequeue while loop" waits for a notifier from the queue telling it to run.  can you explain this to me? because it is different from what I expect to be happening.
    rasputin wrote:
    I tried to open your VIs but it doesn't work. LV
    is launched, the dialog box (new, open, configure...) opens and then...
    nothing. Not even an error message. I guess it isn't a problem of LV
    version or a dialog box would appear saying this. Could you, please,
    send a image of the code?
    Thanks,
    Hi Rasputin, I'm using LV8.  I assume that was your problem, but who knows.  I've attached a pic of of altenbach's solution since it's what I needed.
    thanks
    -Z
    Message Edited by zskillz on 10-20-2006 11:49 AM
    Attachments:
    daq01v1MODv2.vi ‏63 KB
    daq01v1MODpic.JPG ‏116 KB

  • How do i configure a FOR loop to have the behavior of the step Loop Type: Pass/Fail count?

    Hello,
    I'm using the Pass/Fail count set to one Pass to capture an event generated by my DUT.  I originally used a numerical compare step with the Looping type of Pass/Fail count to accomplish this.  Unfortunately the implementation changed and now I need to execute a few steps that can not be combined within one code module as before. Nor can these steps be put into a subroutine.  One of the steps executes a .NET asembly and I haven't figured out how to pass the reference to the subroutine.  When the subroutine is intered the reference is lost and the methode does not execute correctly.
    I have an evaluation function the exits the loop when the expected conditions are met. Everything works except for the Overall Pass/Fail result of the For loop.  If the loop exits due to the first numerical compare test passing, I want the loop overall execution to report as "Passed".  If the loop reaches it's predetermined number of iterations, the overall result needs to report as "Failed".  It would also be nice to have the radio button functionality of "Record Result of Each iteration".  Some conditions require a wait over a minute for the event to occur and I don't want to generate needless data for the report.
    Currently I get the pass/fail status for each For loop iteration, but only "Done" for each loop iteration.  I don't want the initial few failures to cause the test to fail.
    Does anyone know how to do this? Suggestions?
    Thanks,

    I have 2 steps in the loop that can not be combined into one step. This forces me to implement the behavior in some form of loop.  A While Loop could be an option.  I would need to pass the Step.Result.Status from the Multiple Numerical compaire step to the condition of the While Loop.  I tried to use the Step.TS.ID without success.  Some form of reference to the numerical compare step would be needed. I'm using a For Loop as I do want to limit the number of iterations of the loop.  In the case where the loop iterations are reached, the event I am trying to detect did not occur at the correct time and a failure needs to be reported.
    I came up with something based on my comments in the second post:
    1) To start with I configured a Locals.ForLoop_5 variable.  This is used to set the limit on the loop iterations and for comparison after the loop has finished executing. More on that later.
    2) The first step inside the loop invokes a method within a .NET assembly that has been packed in a DLL This method gets the required data from the DUT and stores it to a text file.
    3) The next step is the Multiple Numeric Limit step.  This step invokes a VI that extracts the data from the text file.  This step has been customized in several ways.
      i)  In Run Options, the Results Recording Option was disabled.  This prevents recording of "Failed" while the loop executes when waiting for the event to happen.
      ii) In Run Options, the Step Failure Causes Sequence Failure is unchecked.  Same reasoning as i)  These steps are not true failures.
      iii) A Post Action is configured to go to the nexxt step after the For Loop End step On Condition True with the logic of Step.Result.Status == "Passed".  This causes the loop to exit when the first "Passed" is encountered which corrolates with the event I'm trying to detect. On Conditon Fail remains set to default.
    4)  The step after the For Loop End is an expression step with everythin set to default except for the Status Expression logic set to: Locals.Loopindex < Locals.ForLoop_5 ? (Step.Result.Status = "Passed") : (Step.Result.Status = "Failed"). This step performs the overall Pass/Fail reporting for the For Loop.  If the number of loop iterations is less than the maximum it could have only gotten there by the previous logic triggered by the numerical compare passing, therefore "Passed".  If the loop index has reached the limit, then the event was not detected, therefore Failed.
    I have tested this work around with success, it just a pain to now have to implement this on my 40 some odd For Loops.
    If there is a better way, I'd still like to hear it.

  • How do I exit a while loop which has a 'read from spreadshee​t' pop up in it?

    I have a while loop which calls 'read from spreadsheet'. My problem is that after entering a filename the loop repeats too quickly for me to hit the end loop button. How do I exit the loop without adding a delay after the read thereby slowing the loop when I don't want to exit. If I select cancel I get 'error 43'. Is there a way to to use an error handler to prevent this from popping up and use it to end the loop?

    It's the error handler inside Read From Spreadsheet that creates the message. Specifically, one of the VIs called is Read Lines From File. The last VI in there is General Error Handler. You can delete it and save it with a different name. You should also modify it to return the error cluster. You'll also want to modify Read From Spreadsheet to return the error cluster so that you can trap the error in your VI. When cancel is selected, error code 43 is generated. Stop the loop when you see 43.

  • How would I implement a FOR loop in real time?

    I am using a cRIO and would like to have several processes running in parallel.  A main functin will have a loop in it which will count up and an certain time intervals pass data to a parallel process.  I am not sure how LV will check the current time value and determine if it is time to send the parallel process information (it will send the parallel process a command to start at time X and stop at time Y).  I see the code in C as:
    for (i; i <= 60; i++)
         if (i==30)
            Function(1); //send "1" to function to  start action, equivalent of setting a variable in LV and continuously reading that variable in the parallel function
         if(i==45)
            Function(0); //send "0" to function to stop condition
        delay(1second);
    I am confused about how to create a loop that has a predetermined (changeable) time period that allows me to compare the timer to set times (i.e. 30 and 45) and perform a function if they are equal.  I can handle that compare part but I am not sure how to implement the loop.  Any help would be greatly appreciated.

    Hi,
    Why don't you use "Elapsed time.vi" ? Compare it with the time you require. Also you can use register event function to let the other process know a certain condition has occurred.
    Gaurav k:smileyhappy:
    Gaurav k
    CLD Certified !!!!!
    Do not forget to Mark solution and to give Kudo if problem is solved.

  • How do I break a for loop (inside) and a while loop (outside) at the same time by a control button

    I have a while loop (outside) and a for loop (inside) and a control button within the for loop.  I want to stop the program by click the botton without finishing the for loop.  How can I do that?
    Thank you in advance.

    HI Please find attached snapshot Regards, Santosh
    Message Edited by SanRac on 12-17-2009 05:12 AM
    Message Edited by SanRac on 12-17-2009 05:13 AM
    Attachments:
    Snap1.png ‏4 KB

  • ? on How to Load Variable Within For Loop

    Hello,
    I'm a PL/SQL newbee so I apologize up front if this is a basic question. In summary, I'm trying to build a field name within a FOR LOOP and also load this field with it's associated data from an input record and finally load the data to the output record and pipe the row. I can successfully build the field name but don't know how to load it with data from the input record.
    Here is a sample from the code.
    The input table is shown with the 6 different Fnma codes. Instead of checking each code for data, I want to build the field name, load this field name with data from the input record and move the data to the output record.
    CURSOR cur_loan(prod_date_in IN DATE) IS
    Select
    Ln.Ln_No,
    Ln.Prod_Date,
    Ln.Ln_Fnma_Ftr1_Cd,
    Ln.Ln_Fnma_Ftr2_Cd,
    Ln.Ln_Fnma_Ftr3_Cd,
    Ln.Ln_Fnma_Ftr4_Cd,
    Ln.Ln_Fnma_Ftr5_Cd,
    Ln.Ln_Fnma_Ftr6_Cd,
    from LOAN Ln
    where PROD_DATE = '16-FEB-11';
    Here is the FOR LOOP that successfully builds the field name in l_feat_code_name. Then I "assume" by moving this field to l_output that l_output will contain the actual data, not the field name. However, it appears to contain the field name instead of the data.
    FOR l_To IN 1 .. 6
    LOOP
    l_feat_code_name := ('l_loan_rec.ln_fnma_ftr'||l_to||'_cd');
    l_output := l_feat_code_name;
    IF (l_output is not null or
    l_output <> ' ') THEN
    l_out_rec.Inv_Type := l_Fnma_Cd;
    l_out_rec.feat_code := l_output;
    l_out_rec.Src_Delete_Flag := l_src_delete_flag_n;
    PIPE ROW(l_svc_ln_rec);
    END IF;
    END LOOP;
    How can I move the data itself into the l_out_rec.feat_code output record? Thanks in advance.

    Hi,
    l_output is defined as follows:
    l_output varchar2(20) ;
    I appreciate your example.
    Again, after I build l_feat_code_name it contains the column name from the input record, Ln_Fnma_Ftr1_Cd, ....Ftr2...., .....Ftr3..... and so on up to Ftr6. However, I also need the **data value** of Ln_Fnma_Ftr1_Cd, ....Ftr2...., .....Ftr3..... and so on up to Ftr6. My question is how to get the data value. You see below when I move l_feat_code_name to l_output I'm expecting l_output to contain the **data value**. Instead, when I display it in DBMS_output, it shows the column name.
    CURSOR cur_loan(prod_date_in IN DATE) IS
    Select
    Ln.Ln_No,
    Ln.Prod_Date,
    Ln.Ln_Fnma_Ftr1_Cd,
    Ln.Ln_Fnma_Ftr2_Cd,
    Ln.Ln_Fnma_Ftr3_Cd,
    Ln.Ln_Fnma_Ftr4_Cd,
    Ln.Ln_Fnma_Ftr5_Cd,
    Ln.Ln_Fnma_Ftr6_Cd,
    from LOAN Ln
    where PROD_DATE = '16-FEB-11';
    Here is the FOR LOOP that successfully builds the field name in l_feat_code_name. Then I "assume" by moving this field to l_output that l_output will contain the actual data, not the field name. However, it appears to contain the field name instead of the data.
    FOR l_To IN 1 .. 6
    LOOP
    l_feat_code_name := ('l_loan_rec.ln_fnma_ftr'||l_to||'_cd');
    l_output := l_feat_code_name;
    IF (l_output is not null or
    l_output ' ') THEN
    l_out_rec.Inv_Type := l_Fnma_Cd;
    l_out_rec.feat_code := l_output;
    l_out_rec.Src_Delete_Flag := l_src_delete_flag_n;
    PIPE ROW(l_svc_ln_rec);
    END IF;
    END LOOP;

  • Can I exit a FOR loop before it has completed its iterations?

    Or is there a way to easily slave a while loop to an array input? I essentially need to search an array for a specific entry. Non of the built in VI's will search the array the way I need to do it. I tried wiring the array to a while loop and searching each element, but if the match is never found, the while loop never returns. Is there a setting on a while loop to force it to return if an input array completes?
    The For loop will work, but it forces me to step through the entire array each time and I have to play games to ignore values after I have found and set the one I need.
    Thanks for any help
    Chris

    Hello –
    I am attaching a very simple example program to show what Alberto and Dennis explained (or at least what I understood their approach would be, please apologize if I misunderstood).
    Another option is to use the Search 1D Array function, located in the Functions >> All Functions >> Array subpalette.
    Hope this helps.
    SVences
    Applications Engineer
    National Instruments
    Attachments:
    Example.vi ‏29 KB

  • How to define function within for loop pls help?????

    Hi this is the problem i have a class, and within that class there is an actionPerformed function, in this class i also create an instance of another class, this other class also contains an actionPerformed function, which wis executed if a jButton has been pressed, when I try to place this actionPerfromed function within a for loop of a function i get an error saying illegal start of experssion, and that the class should be defined abstract as it does not define actionPerformed, when i take it out of the for loop it compliles fine, i need the function to be placed within the for loop because it needs to know the variable of the for loop, is there anyway around this? Thanks, below is the code:
    public class DisplayTransitions extends JFrame implements ActionListener
    public void add()
    for(int i = 0; i < char2.size(); i ++)
    mPanel.add(tim[i] = new JButton("Time"));
    tim.addActionListener(this);
    public void actionPerformed(ActionEvent ae)
         if (ae.getSource() == tim[i])
              timeIncr();

    This is your for loop using an anonymous inner class for the listener:
                for (int i = 0; i < char2.size(); i++) {
                    mPanel.add(tim[i] = new JButton("Time"));
                    tim.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() == tim[i]) {
    timeIncr();
    Learn more about anonymous inner classes from a good Java book or the Java tutorial (try http://java.sun.com/docs/books/tutorial/java/javaOO/QandE/nested-answers.html).

  • How to define exit plug for interface view?

    hi experts,
                  I am trying to define exit plug for interface view , but i am not able to make interface view into change mode. it doesnt allow me. what should be done/
    Thanks,
    saurin shah.

    Hi ,
           Check the Interface in the Window this will reflected in the Interface Window
    Regards
    Vikranth

Maybe you are looking for

  • Error 7 report generation

    Good Day, I seem to be having a little trouble with the report generation tool.  I'm running Labview 7.1, have the MS Report Toolkit.  I have a construct that creates and formats an Excel Report.  It works fine when running it from the developement e

  • ColdFusion 11: custom serialisers. More questions than answers

    G'day: I am reposting this from my blog ("ColdFusion 11: custom serialisers. More questions than answers") at the suggestion of Adobe support: @dacCfml @ColdFusion Can you post your queries at http://t.co/8UF4uCajTC for all cfclient and mobile querie

  • Problem: 'Could not read from source' when exporting project.

    Hi everybody I am using Adobe Premiere CS4 on my MacBook Pro 15'' (i5 processor, 4 GB RAM, 500 GB Harddisc, 256 MB video memory (high-clockspeed)) Everything works well except of one big thing, every time when i try to export my finished project the

  • I need help with my mobile site using Go daddy

    my website will not work properly

  • Can you transfer apps?

    I think i have a defective iPod Touch that i just purchased a few days ago. I've purchased a few apps, and installed several free ones. I notice a folder in my documents where the apps are located. Will i lose all my apps if i take this back and exch