Can't we use while loop inside a fn

i am using a while loop inside a fn
it is showing error
the code is
while (a=1) loop
some condition
end loop;
the error is
PLS-00103: Encountered the symbol "WHILE" when expecting one of
the following:
* & = - + < / > at in is mod not rem then <an exponent (**)>
<> or != or ~= >= <= <> and or like between overlaps || year
DAY_
The symbol "*" was substituted for "WHILE" to continue.
PLS-00103: Encountered the symbol "LOOP" when expecting one of
the following:
. ( * % & = - + < / > at in is mod not rem then
<an exponent (**)> <> or != or ~= >= <= <> and or like
between ||
what is the error

It looks like the OP misskeyed the assignment operator and got compilations errors, and from that assumed that you can't use WHILE loops in functions on a Tuesday.
Message was edited by:
William Robertson
I was thinking of his is it possible to increment a value in a function, though I suspect the problem is similar.

Similar Messages

  • Event controll: How to stop a running while loop inside a event structure

    Hello,
    I have some problems with controlling a while loop inside a event structure (see attached VI).
    I habe 3 buttons ("Start Measurement, Stop Measurement, Quit Program"). When a measurement is running, it should be possible to stop the measurement by clicking on "Stop Measurement", but this does not work.
    Has anyone an idea?
    Thanks a lot and best regards,
    Michael
    Message Edited by MichaGue_01 on 04-23-2010 04:37 AM
    Solved!
    Go to Solution.
    Attachments:
    Event_Controll.vi ‏27 KB

    Hello,
    Try not to use while loops inside a Event structure.
    My approach is using two While loops (one will have only the Event structure).
    I had to use to Flag buttons that make it a bit more complicated but i am sure somebody will come up with a better idea, or you might want to have a think about it yourself.
    Have a look on the modified version on the attachment.
    Once you are happy how it works then you can Hide the 2 flag buttons from the Front Pannel by going to Block diagram right-click the indicators and choose option "Hide Indicators/Controls"
    I did it in LV 8.6 so i hope you can open it on your PC if not i can downgrade it.
    If you have any problem let us know.
    Regards
    Dimitrios
    Test Systems Computing Engineer
    Cummins Turbo-Technologies
    Attachments:
    Event_Controll[1]_modified.vi ‏18 KB

  • While loop inside a timed loop

    Hi everybody!
       I'm using:
           - LV 7.1 + RealTime;
           - compactFieldpoint;
       I've noticed a strange behaviour, when I put a while loop inside a timed loop.  Let's fix timed loop with these settings:
           - 1 KHz clock
           - 1 ms period (yes, I know it's short....)
           - offset 0 ms
           - Phase 0
           - Discard missed period (ON) and MAintain original Phase (ON);
           - Timeout: -1.
       If inside this loo, I put a traditional while loop, waiting (say) for an event to occur, and if this event does not arrive, my cFP-2020 hangs! I mean, it becomes unreachable for the debugger, and, more, if I run a ping to it's address, after some cycles it becomes unreachable also from ping!
       Clearly, this code statement lock the fieldPoint, because if I remove the inner while loop all works.
      I know that with 1 ms period, timed loop always finishes late, but I set to discard missed period and timeout to -1. 
       It seems to me that sometimes Timed Loop add heavi overhead to programs, I'm turning to all while loop based tasks, even if my application has to be real-time!
       Advices welcomed! Have a nice day!
    graziano
    Solved!
    Go to Solution.

    I think the issue here is that putting your while loop inside a Timed Loop increases the priority for that task. Timed Loops can have dynamic priorities set over eachother, but they all run between Above Normal and Time Critical priority. My guess is that the debugger and built-in TCP functions run at Above Normal priority or less. This means your cFP isn't hanging, it's doing what it thinks is best. It's trying to finish this task before handling any lower-priority tasks.
    The suggestion to put a Wait function in your loop is an OK one. Keep in mind that you can actually set your wait time to zero instead of one and get the same positive benefit of handling other tasks. I would also suggest that you might look into waiting for this event in a lower priority (non-Timed) loop, and then transmit the appropriate data to your Timed Loop using an RT-FIFO or something. That might give you better handling. Just a thought....
    Jarrod S.
    National Instruments

  • Exit a while loop inside an event case

    Hi All, I have a multi-page program. One of it is used to read some analog signal via a USB block continuously.
    What I want is when clicking this page, this while loop is activated. Then we can monitor the data. When we click other pages or "Stop" button, this while loop will be terminated. And we can use the other pages to do something else.
    Right now I got difficuties in stop the while loop. I do not want to stop the running of the whole program, just want to jump out of this while loop then do other operation.
    Could anyone give me some advise how to do it? Thank you very much! 

    Hi RavensFan, thank you for your reply.Actually this is not my real code  because the original one is very very compliacted.
    In real code, the tab control you see in inside the bigger while loop, that loop makes the whole program work.
    And as what I pointed, the purpose is when I click this tab (if we do not want it to trigger, we can place another "START" button to trigger), an internal while loop inside begins to run. This while loop keeps showing the real time analog signal.
    And if I do not want to use this "real time monitoring" function, I want to click somewhere (or doing anything else that can work) to jump out of this internal while loop and keep on using some other functions of the program.
    Could you advise about that? Thank you very much! 

  • Sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loop

    sir i have given lot of effort but i am not able to solve my problem either with notifiers or with occurence fn,probably i do not know how to use these synchronisation tools.

    sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loopHi Sam,
    I want to pass along a couple of tips that will get you more and better response on this list.
    1) There is an un-written rule that says more "stars" is better than just one star. Giving a one star rating will probably eliminate that responder from individuals that are willing to anser your question.
    2) If someone gives you an answer that meets your needs, reply to that answer and say that it worked.
    3) If someone suggests that you look at an example, DO IT! LV comes with a wonderful set of examples that demonstate almost all of the core functionality of LV. Familiarity with all of the LV examples will get you through about 80% of the Certified LabVIEW Developer exam.
    4) If you have a question first search the examples for something tha
    t may help you. If you can not find an example that is exactly what you want, find one that is close and post a question along the lines of "I want to do something similar to example X, how can I modify it to do Y".
    5) Some of the greatest LabVIEW minds offer there services and advice for free on this exchange. If you treat them good, they can get you through almost every challenge that can be encountered in LV.
    6) If English is not your native language, post your question in the language you favor. There is probably someone around that can help. "We're big, we're bad, we're international!"
    Trying to help,
    Welcome to the forum!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I make a while loop wait for input boolean?

    Hi.
    I'm trying to control a robotic arm with labview for my undergrad dissertation, and I have a decent polar coordinate control panel made, but there is one problem; it checks for changes in the coordinates every five seconds, while I want it to only check on the touch of a button (ie, go!, I've changed your coordinates!). The changes are calculated with a while loop comparing the last value of theta, x and z in a while loop with the current one. I can't find a way of putting that into a case structure. If there is a way of making the while loop progress at the push of a button, I think it would work. The VI's attached below.
    Thanks in advance for any help.
    Cathal Scanlon
    ps, sorry about the mess, I'm going to reorganise the while loop into 2 if I can get the control button working.
    Message Edited by CatScan on 02-08-2007 02:45 PM
    Attachments:
    Polar coord assignment1.vi ‏142 KB

    Have you tried using an event structure? To use one, right click on the structure to add an event. Set the event as whatever button you wish to monitor and set the event to "Value Change". If you put this inside a while loop any time the button is pressed, the event structure will run the contents inside the loop. There are a number of options to have the event structure activate.
    *** Warning! I'm probably the last guy you want answering your labVIEW questions, but I figured I might be able to help.

  • How can I make a while loop wait 10 seconds before iterations​?

    I am using labview to for an osmosis system that measures the amout of water lost from the reading on a scale.  
    I currently have the program displaying the data from 3 scales every second.
    I also need to calculate the flux through the membrane over time.
    I do this with a function that takes a change in the scale reading over time (with a shift register) followed by a series of mathematical conversions.
    The readings from the scale display OK every second, but I need to have at least 10 seconds between flux calculations.
    So my question is, how do I make a the shift register take one value from the scale, then wait 10 seconds before taking the second value?  That way I have the mass of water lost over a 10 msecond period.  
    Below is my current while loop for Flux using shift registers from data from 3 scales.  
    Any helkp would be great!
    Also, I'm new at LabVIEW...

    Bob_Schor wrote:
    Do you understand how Dataflow (a key idea behind LabVIEW) works?  If you put a Wait (ms) function (on the Timing Palette) with 10000 (10,000 milliseconds = 10 seconds) inside your While Loop, the principles of Data Flow will require all of the functions inside the While (specifically the Wait function) to finish their execution before the loop can run again.  As everything else in the loop takes approximately 0 seconds, this will make your loop run once every 10 seconds.
    Bob Schor
    I do not think that is a good idea. 
    The inner loop should be in sync with the outer loop, not run independent on it's own timer.
    If the inner loop is running independently you run the risk of using stale data.
    Actually  altenbach is right the inner loop does not need to be a for loop at all, but rather just a case like my suggestion (without the for loop) and the shift registers should be out on the main loop.
    My suggestion was a quick solution going by what little bit of the block diagram I could see, but if the entire code was posted I am sure we would see where more improvements could be made and possibly even a better solution.

  • Ending a while loop inside a while loop

    How do I make a while loop run as long as the while loop that contains it is running? I tried wiring both conditional terminals to a stop button in the outer loop, but that doesnt seem to work? Is there another way?
    Thanks.

    Hi Jasonalan,
    I am not sure what you are trying to implement, but it is true that the loops are not terminating because of data dependency. The stop button in the outer loop will not be read until the inner loop terminates.
    If you wish to terminate the two nested loops using a single stop button, you should read the stop button inside the inner loop and wire it to the conditional terminals in both the inner and outer loop. Again, there is no point in doing this unless you have some other logic along with the stop button to stop the loops. If only the stop button is being used to stop both the inner and outer loops, the outer loop will only execute once. In that case, you can just use a sequence structure followed by a single while loop.

  • Stopping a while loop inside a while loop

    Hello,
    I have a while loop which is inside a while loop which houses my enetire application, When stopping the inner while loop portions of my outer loop stop working, How do I setup the inner while stop that it will not interfeer with the outer while loop?
    Thanks,
    Gil,

    It sounds like he is using a simple archetecture.  But switching to a different archetecture may not be necessary.  Simply because it doesn't work, doesn't mean scrap the whole thing and start over.  He's got a bug and needs to fix it.  Is it the best archetecture to use, absolutely not, but simple or general archetectures can be effective based on the application.
    Post your VI so we can take a look and give you some pointers and suggestions for improvement.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • Using while loops instead of for loops in arrays?

    I am new to java and doing a java tutorial on using arrays and for loops. What im trying to find out is how it is possible to use a while loop instead.
    I would be very grateful if anyone can suggest a way of changing my code to use a while loop.
    The code I have written is:
    public class DetermineGrade
    public static void main(String[]args)
    final char[] mark = {'A','B' ,'C' ,'D' ,'F' };
    char [] grade = new char[5];
    int [] Score ={95,35,65,75};
    for (int i=0; i<4; i++)
    if (Score >= 90)
    grade= mark[0] ;
    else if (Score >=80)
    grade = mark[1] ;
    else if (Score >=70)
    grade = mark[2] ;
    else if (Score >=60)
    grade = mark[3];
    else grade = mark[4];
    for (int i=0; i<4; i++)
    System.out.println("grade = " + Score + ", " + grade);
    Thankyou LB

    Im trying to underdstand the differences in the
    different loops. I can grasp the for loop but I dont
    see how a while loop works, or how it id different
    from the other?
    for (j = INIT; j < MAX; j++) {
        // do stuff
    }is the same as
    j = INIT;
    while (j < MAX) {
        // do stuff
        j++;
    }Lee

  • How to use while loops to implement a simple climate control.

    Hi,
    I am currently a 4’th year computer systems engineering student in South Africa doing a primitive climate control project in LabVIEW 8.0. Although my knowledge and skill level of LabVIEW is far from that of an expert, I really enjoy working with it. The project consists of a motor driving some fan blades, a resistor heater and an analog temperature sensor. The basic functionality entails that a user specifies a desired temperature and then the program will heat if the current temperature is lower than desired or cool if the current temperature is above the desired temperature.
    What I want to add is an acceptable temperature difference so that the fan and heater do not switch constantly as the threshold temperature is reached. Rather leave the current temperature to linger between the maximum (current + acceptable difference) or minimum (current – acceptable difference) allowed temperature before heating or cooling it to the desired temperature once again.
    I have attached 2 VI’s:
    Final Assignment: I tried to achieve the sensible climate control by making use of a formula node. As soon as I substituted the if statements in the formula node with while statements, the VI did not respond. It did not give any errors, it just didn’t respond.
    Final Assignment2: I tried the same but by making use of while loop structures. The while where my Input DAQ is works fine, but none of the other while loops work.
    Please advise me on possible solutions for my problem/project.
    Thank you in advance.
    D. Weppenaar
    Attachments:
    Final Assignment1.vi ‏254 KB
    Final Assignment21.vi ‏256 KB

    1. Your VI does not respond because your formula node is trapped in an infinite loop and cannot exit if you're out of the deadband. Replace the words "while" with "if" (or similar) and you might be getting somewhere. Sorry, I don't have DAQ installed, but what determines the loop rate?
    2. You have a dataflow issue. Only the inner loop on the left will run. All other loops must wait because they depend on data from the first loop. data is only available at an output tunnel of a loop once the loop finishes and a loop cannot start until all input tunnels contain data. Also the first loop can never stop, because the stop button is outside the loop and will never get read once the inner loop starts. The stop button needs to be in the innermost loop.
    Most likely, all code segments should run synchronized, so delete all the inner loops. They serve no purpose. All yon need is the big outer loop as in the first code.
    There are many ways to directly observe what is going on. For example you could run the VI in execution highlighting mode while watching the diagram.
    Clearly, you need to become more familiar with LabVIEW basics. Maybe do a tutorial? Right now you might think that dataflow is a hindrance while in fact it is one of the most powerful advantages of dataflow programming. You simply need to be familiar with its logic.
    LabVIEW Champion . Do more with less code and in less time .

  • How to validate input using while loop?

    I've written a short program that asks the user to enter their gender. I have a setGender method that checks that the user has entered either M or F before assigning the value to the gender variable. If they haven't, the program continues to ask for their gender until they type M or F. My problem is using the while loop to validate input (pls see below). It works when the user enters the wrong character but it continues to ask for input even after the user enters M or F. How can I fix this loop so that it stops on receiving the correct input and assigns it to the variable?
    cheers
    Chris
    import java.io.*;
    public class TestInput
    private char gender;
    public void checkGender()throws IOException
    System.out.print("Enter your gender: ");
    gender = (char)System.in.read();
    System.in.skip(2);
    setGender(gender);
    System.out.println("Your gender is: " + gender);
    public void setGender(char g)throws IOException
    if (g == 'M' || g == 'F')
    gender = g;
    else
    while (g != 'M' || g != 'F') //Problem area - loop continues after user enters M or F
    System.out.println("Enter M or F for passenger's gender: ");
    gender = (char)System.in.read();
    System.in.skip(2);
    } //end class

    // old code
    while (g != 'M' || g != 'F') // At least one of these comparisons will be true no matter what is given.
    //  what you really meant?
    while (g != 'M'   &&   g != 'F') // keep going while you don't have a valid answer

  • While loop inside a event structure

    Dear
    I have no much concepts on event structure.
    Let's assume there is a dialog box with Okay and Cancel button.
    I put the event structure for Okay and Cancel button.
    In Okay event, there is a while loop for detecting some data continuously.
    In this case, I want to use Cancel button to stop the while loop during the detection.
    How can I do to receive signal from the Cancel button?
    Thank you in advance.

    I'm not sure that the event structure should be used to handle that situation : while the OK event is executing, either the Front panel is locked and new occuring event will be stored until the OK event is completed (so the Cancel button action will not be detected !) or the Front panel is unlocked (see below *) and the Cancel button action will stop the loop, but the Cancel button event case will not be executed, since the event has already been processed in the OK case !
    You should probably use a single button to run/stop the loop, as shown in the attachment
    * While editing the event case, unmark the "Lock front panel for this event complete" at the bottom. But of course, the code in the cancel case will not run, since the event occuredMessage Edité par chilly charly le 03-31-2007 05:27 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Event button.vi ‏11 KB

  • 'While Loop' inside a 'Repeater' executes only once

    Hi,
    I am using a 'While Loop' action inside a 'Repeater'. The while loop executes only for Repeater.CurrentItem = 1 and not for the subsequent items. Any clue?
    Regards,
    V M.

    And the 'While_Loop.Break' = "false". Thaks for the tip.
    Regards,
    V M.

  • Can we run two while loops independently in one application?

    I am acquiring two channels using PCI-6052.both channels to be read at 2ks/s,but I want to scans read at a time different for each channel,So I put two AI-read vi's in two different while loops.but the second while loop waits until the first is completed.Can we run independently both while loops?

    Dear Haider Abbas,
    you can scan two different channels at the same time with the same AI Read if your hardware device is cabable of it, e.g. you must have one A/D converter for each channel. If you have one A/D converter only and your channels are multiplexed then it won't work.
    You can try running both loops indepentendly by using delays but in this case the data acquisition will not be at the same time. You have also to consider that every time you call for AI Read the DAQ card will be initialised with takes some time
    Hope this will help you.
    Stephan

Maybe you are looking for

  • Manual Princing Condition not copied using BAPI

    Hi Guys, Something pretty weird has been happening.. when I create a Sales Order over VA01 with reference a Contract, the Sales Order take the COMPLETE Contract Princing Condition, so its perfect. But When we're trying to use the BAPI (BAPI_SALESORDE

  • Time out parameter to avoid Table locking

    Hi, I am looking at any configurable parameter if any for setting the time out parameter to avoid Table locking.Now what's happening is : If i run select ...for update from one session,oracle is applying a lock till i do a commit.And if i run the sam

  • Finding the form number - Simple Q !

    I am trying to process the form values inside a PL/SQL block on that page. I get the values and after processing I insert the values into a table. I have created a PL/SQL block.. and I am sure the block is called properly because everything is proces

  • BSP htmlb:tableView id="TV_VBAK" table= "//select/I_VBAK"

    Hai Experts, I have a small doubt in bsp appllication, shall we write like... <htmlb:tableView id="TV_VBAK" table= "//SELECT/I_VBAK"> I am using Class ZCL_CONTROLLER_SALES1 in controller. thanks in advance... with regards babu

  • Is the classic css panel only available in C6? I hate the dumbed-down css designer panel

    Im currently testing Dreamweaver CC 2014 during the Trial period. So far I like the interface but I HATE the css designer panel. I've been using Dreamweaver for 7 years and the classic css panel was one of the key components I use on a daily basis. F