Infinite Loop Question - should be simple

Ok I think I have a simple question to ask here. I am attempting to create a program that creates an infinite loop for multiples of two...
ex: 2, 4, 8, 16, etc...
The math behind it is simple, x^2 when x = 2. I then want the result of each equation to be squared, and infinitely.
Here is the code Ive written so far, I think Im close, but I may be way off... any hints or clues as to my next step would be appreciated.
public class loopytest {
   public static void main (String[] args)
   int x = x^2;
   while (x = 2)
   System.out.println("Value of x is " + x);
}

int x = x^2;You have to initialise "x" first.
You should give it an actual value (e.g. 2) for this case.
int x = 2;If you want to get the value of x from arguments. (e.g. java YouProgram 2)
You should change this part of code similar to the follow.
int x = args[1];But this one hasn't used the Math.pow(), you should read the API and amend it.
while (x = 2)This one is actually assign x with value 2.
If you want to compare an int, you should use "A == B", "A.equals(B)" for Object.

Similar Messages

  • Infinite loop in a catch {} statement, should be simple

    Hi, I'm trying to take integer input from the console using a Java Scanner object, and I enter an infinite loop if there is an IO error inside the catch statement. Please let me know if you know what I'm doing wrong:
    do
    try
    Problem = false; //this is a bool
    start = Input.nextInt(); // Input is a Scanner, start is an Intenger
    catch (Exception IOException) {
         Problem = true;
         System.out.println("Bad value.\n");
         //The infinite loop is inside this statement.
    while (Problem == true);
    This code block is intended to take integer input, then, if there's an IO error, try to do it again, indefinitely, until it has successfully given Start a value. As it stands, if executed, if there is not an IO error, it works; if there is an IO error it enters an infinite loop in the catch statement. Please forgive my incompetence, any help is appreciated :)

    Hi, thanks for the advice to both of you, your suggestion that it is stuck seems to be correct.
    I add to the catch statement:
    Input = new Scanner(System.in);
    To reset it, and it works now. This is probably not the best way to do things, but I'm just a student and it's for a homework assignment that does not require try / catch / for so it works for this, thank you for the help! :)

  • Infinite Loop (newbye question)

    Hi guys,
    I have a question :
    I am trying to have a piece of text blink by changing its alpha
    To reach that goal I have two options :
         - A Classic tween with Alpha variation and then go back to first frame
         - Change the alpha with an AS3 script using loops
    I am trying the second option for a smoother result .
    Though I think that an infinite loop make Flash crash (which append indeed when I tested)
    Do you know what I should add top the below code to make it work ?
    I need to call 'decreasealpha' first then 'increasealpha' and back to 'decreasealpha' and this endlessly ... but don't know how to do it
    var alphamax:Number = 0.40;
    var alphamin:Number = 0.15;
    Text_mc.alpha = alphamax;
    function decreasealpha (a:MovieClip):void
    while (a.alpha > alphamin)
    a.alpha = a.alpha-0.01;
    a.alpha=alphamin;
    function increasealpha (a:MovieClip):void
    while (a.alpha < alphamax)
    a.alpha = a.alpha+0.01;
    a.alpha = alphamax;
    Many Thanks

    Get rid of the while loop altogether.  Essentially you are not letting Flash update at each increment.  Use timer to callback into your decrease/increase-alpha functions.  Or better yet, use a tween simulater (like Tweener)...
    protected function decreasealpha()
         Tweener.addTween(Text_mc, {alpha:alphamin, time:1.0, onComplete:increasealpha});
    protected function increasealpha()
         Tweener.addTween(Text_mc, {alpha:alphamax, time:1.0, onComplete:decreasealpha});
    Cheers,
    Jason

  • InDesign infinite loop when exporting INDD as IDML - one specific document

    Hi,
    I have several thousand INDD files that are generated using CS4. We are migrating to CC server so need to be able to run scripts against these files. One of the scripts performs some (simple) manipulations and then saves as IDML...
    Except...
    With a percentage of our files (I've found two out of less than a hundred files that I've tested) the export to IDML task never completes. InDesign server simply hangs, permenantly. The only way to get our server back is to manually terminate the process using Task Manager and then restart. I have looked at the INDD files using InDesign client and can see nothing whatsoever the matter with them. However, even in client, even after deleting _ALL_ content, when I try to save as IDML, I get the export process hanging (see screenshot below).
    So, I guess I have two questions;
    1. How can I modify InDesign server to detect and recover from this form of infinite loop?
    2. Does anybody have any idea what could be causing the infinite loop? (And how to resolve it?)
    Thanks,
    Gaius

    You should try a divide and conquer for the InDesign file.
    That is split it in two and then try export to IDML
    Whichever sides hangs is where the problem lies. You can keep halving this document until you find the problematic page/pages.

  • Infinite loop creating new page due to column header overflow.

    i am getting an error and some pages "Infinite loop creating new page due to column header overflow. " --
    using report builder 9, i have a fairly simple report - that contains 4 subreports.
    for some pages i get the error - it seems if there is more data than would fit on 1 page.
    smaller pages work fine.
    the subreports are all simple queries and dumps....
    containing page header, column header, detail sections.
    page header has just a text bar of the name of the section.
    column header has the field names
    detail section has the data - 1 row for each row in the recordset.
    nothing i do seems to change getting "Infinite loop creating new page due to column header overflow. " on a page with more than 15-20 records returned.
    any ideas would be appreciated.

    Try these links if you are still having the issue:
    http://community.jaspersoft.com/questions/543302/receive-infinite-loop-creating-new-page-d ue-column-header-overflow-exception
    http://community.jaspersoft.com/questions/500177/infinite-loop-due-page-header-overflow

  • Switching loop question

    Hello everyone!
    I need some clarification of the switching loops. I apologise if my question is too simple, but i really cannot find answer in books, internet. Thanks in advance!
    Please look at the attached topology. This is my test lab for switching loops learning. For simplification purpose IPs, MACs and interface's names were shortened (FF=FF:FF:FF:FF:FF:FF).
    Initial conditions:
    SW-1:
    Cisco Catalyst 3750-V2, 12.2(50)SE5 IPServices, with default, factory config.
    For an unmanaged switch simulation purpose, interfaces 1/1, 1/2, 1/3, 1/4 were configured with switchport host macros and spanning-tree bpdufilter enable command (additional to default factory config).
    Interfaces 1/2 and 1/3 were interconnected with straight through patch cord specifically for creating a switching loop. Just booted up, not learned any MAC-address.
    SW-2:
    Cisco Catalyst 3750-V2, 12.2(50)SE5 IPServices, with default, factory config.
    Just booted up, not learned any MAC-address.
    Both PCs:
    Have a clear ARP-cache.
    Test:
    PC-1 sent ICMP-echo to PC-2. SW-1 received an ARP-request from MAC A (MAC-address of PC-1's NIC) to MAC FF (L2 broadcast as mentioned before) on its 1/1. Because of the initial conditions there is broadcast storm now. MAC A is flapping between 1/2 and 1/3. Next, PC-2 received an ARP-request from MAC A and sent ARP-reply. That ARP-reply arrived at SW-1 and started unicast storm additional to broadcast storm.
    This is clear for me.
    Question:
    What i don't understand is why the SW-1 sends ARP-reply from PC-2 back to the SW-2 (interface 2/1)?
    P.S. apologise for my english. Thanks again!

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    If there's only one or two non-STP switches, in a full mesh, you'll be okay.  Once you have at least three non-STP switches, in a full mesh, you have a loop between them.

  • Device Driver stuck in infinite loop

    This propblem maybe only happed 2 times in the frist 6 months of my computer purchase, but the past few months it's been happening more and more untill it happens every day, or just about anytime I play a video game.
    The exact error message is "The device driver got stuck in and infinite loop, this usually indicates a problem with the device itself or the device driver programming the hardware incorrectly"
    The specs of my computer are
    Windows Vista(Home Premium)
    Gateway Fx6800-01e
    Intel(R) Core(TM) i7 CPU  920 @ 2.67GHz   2.67GHz
    3.00 GB Memory
    64-bit Operating System

    Kindly try to boot the system into Safe mode and then uninstall the display driver.
    After this you should able too boot the system into normal mode. Download the latest driver from lenovo website
    http://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/7ld152ww.exe
    Best Regards,
    Tanuj
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution".! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • How to create an infinite loop that cannot be cancelled?

    Hi , im new around java and i need a program that keeps on repeating after each each input/uses(generally meant for different user) and cannot either stop using "Cancel" or "x" while stopping only using the "stop" button
    I got a few lines of codes that look like this : String arg = "";
    do{
    JOptionPane.showInputDialog("hi");
    }while ( arg != "y" || arg!= "Y");
    and it cannot be stop with both cancel and"x"(which i wanted)
    but when i used this logic with
    Valid validUserInput = new Valid();
    do {
    userInput = validUserInput.validUserInput(a);
    switch(userInput){
    case 1 : validUserInput.optionOne(b);break;
    case 2 : validUserInput.optionTwo(c);break;
    case 3 : validUserInput.optionThree(d,e);break;
    default : validUserInput.validUserInput(f);
    }while(looping != "" || looping != " ");
    it does not really work(while it will keep looping, it can be easily stop by pressing cancelled or "x")
    So is there any logic or method that can prevent the program from being stop?
    Thankyou!

    elricscript wrote:
    "That is helpful. It gives him a direction where he can focus his research. Namely, 'how to run a program in kiosk mode' rather than 'how to create an infinite loop that cannot be cancelled.'"
    No... He already mentioned he wants to "e.g Interactive kiosk", so saying "properly kiosk it" isn't adding any new information. Rather it's just giving the person a dead point of: you're doing it wrong. Pointing out someone is wrong is not a positive enlightenment. Pointing someone in the right direction is more productive.
    >"That is helpful. It gives him a direction where he can focus his research. Namely, 'how to run a program in kiosk mode' rather than 'how to create an infinite loop that cannot be cancelled.'"
    No... He already mentioned he wants to "e.g Interactive kiosk", so saying "properly kiosk it" isn't adding any new information.
    Yes it is. He asked how to do it using some Swing trickery, and I said it won't work. Which is true. The OP didn't already know that, clearly, hence the question. Now he does. That's pretty much new information if you ask me.
    Rather it's just giving the person a dead point of: you're doing it wrong.Right. He is. However, the problem is now no longer related to Java, and not something I can help him with. You should try that: not answering questions you don't know the answer to. It's actually more helpful than posting misleading, wrong answers.
    Pointing out someone is wrong is not a positive enlightenment. I'm giving basic technical help, not yoga lessons.
    Pointing someone in the right direction is more productive.As already stated, I am as ignorant of how to make a Java application into a kiosk app as the OP is. What value can I add in light of that information? I began by answering a question that was not stated to be about kiosks. Once the question moved outside of my area of knowledge, I stopped trying to answer.
    I notice you're not giving him any help, being more interested in admonishing others as you are.

  • Igxprd 32, device driver stuck in an infinite loop

    Just attempted to reset a hard drive on our T61 to its factory settings (Windows XP) using the "Recovery CD Set"  (rescue and recovery cd, supplemental product recover cd, and 6 product recovery cd's).  During the final step, the computer reboots itself; however, Windows can't load.  I keep getting an error on a small blue screen, referencing a problem with "igxprd32" and that the device driver got stuck in an infinite loop.  How can I fix this issue.  (Product ID 6465CT0)  Thank you!

    Kindly try to boot the system into Safe mode and then uninstall the display driver.
    After this you should able too boot the system into normal mode. Download the latest driver from lenovo website
    http://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/7ld152ww.exe
    Best Regards,
    Tanuj
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution".! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • MVC problem - infinite loop?

    I'm going to use a horribly oversimplified example to make my point here, because if I were to describe the actual code I'm looking at, it would take the better part of the afternoon and I'd probably bore you all to tears in the process. So, for the sake of argument, let's assume the following model object:
    public class MyModelObject
      private int a;
      private int b;
      private int c;
      public void setA(int newA)
        a = newA;
        b = newA + SOME_CONSTANT;
        c = newA + SOME_OTHER_CONSTANT;
      public void setB(int newB)
        this.setA(SOME_CONSTANT-newB);
      public void setC(int newC)
        this.setA(SOME_OTHER_CONSTANT-newC);
      public int getA()
        return a;
      public int getB()
        return b;
      public int getC()
        return c;
    }So what we see from this is that the setter for one class property actually changes the value of all three class properties (whether this is good design or not is questionable, but keep in mind this is a horribly simplified example for discussion purposes). The point is that the rules regarding the internal state of MyModelObject are governed entirely within that class - the controller and view don't know about these rules (again, questionable design, but bear with me here).
    Now let's imagine we have a view class that displays a MyModelObject instance and allows the user to change the value of a, b, or c. We also have a controller class that observes the view and responds to changes. When the user modifies the value of, let's say b, the controller will respond to that change by calling the setB() method in MyModelObject. Problem is, now the model and the view are out of synch... someone has to tell the view that the other two class properties have also been modified as a result of calling setB() - whose responsibility is this? Should the model inform the view that something has changed so that the view can redisplay it, or should the view observe the model and automatically redisplay whenever the model is modified?
    More importantly - let's say the controller is observing the view for changes, and the view is observing the model for changes... how do you avoid an infinite loop? For example, the user changes the value of b in the view, which causes the internal state of MyModelObject to be modified, which causes a change in the view, which causes a change in the model, and so on and so forth.
    A twist on the above problem is that it is illegal in some Swing components (JTextPane, for instance) to modify the view while a change notification is in progress... so something like this would throw an IllegalStateException:
    //somewhere in the controller
    public void insertUpdate(DocumentEvent docEvent)
      //update the model
      myModelObject.handleChange(docEvent);
      //now redisplay since the model has changed:
      myTextPane.display(myModelObject);
      // IllegalStateException is raised - Attempt to mutate in notification
    }This fails because you can't change the state of the view component in the event handler for a view change event. How do you get around this using proper MVC architecture? Or am I completely out to lunch here?

    The view shouldn't send events to the controller unless they make sense... For example, it shouldn't fire a change event when the user types in a new value. But only if the user presses enter, or the view loses focus (if this gesture is taken as equivalent).
    So when the change of the view comes from the side-effects of a setter of some property, it should fire no event (so that it will not loop). So it sounds no big problem (if such a distinction of events is easy - it should).

  • Infinite Loop in PS-CS5?

    I have just installed PS Ext. CS5 (v12.0.1 x64) on my 2009 Mac Pro, upgraded from CS3 and I am running into what appears to be an infinite loop. I am still trying to find the exact repro for the bug (i will call it that because its my default nomenclature for strange or odd behavior in a program).
    What happens is I am doing some simple editing and opening up .psd files, while others are open. The monitor starts to flash at a high rate of speed, like it is opening up a new image over and over, but can't quite render it. The computer then becomes unresponsive and the only way I have found to regain control is to hard boot the machine, holding the power button in until the machine turns off.
    When the machine starts up again, everything is fine. I have had this occur 3 times in the last 2 days.  I have never had this happen in CS3 version.
    Anyone seen this?

    This looks like the problem that most people were having with MacOs 10.6.4 and some NVidia drivers. Apple released a software update for the drivers a couple of days ago, so if you are on 10.6.4 you should try the update and it should take care of the problem.
    Hope this helps!
    Andre

  • FBL5N - BSEG-REBZG values cause infinite loop FDM_COLL_INVOICE_GET_BY_REF

    Hello,
    We have a problem where function FDM_COLL_INVOICE_GET_BY_REF looks at BSEG records in a loop. It finds the next BSEG record by using the contents of BSEG-REBZG.
    Unfortunately, some of our BSEG records point back to each other. We have the situation where BSEG "A" points to BSEG "B", and BSEG "B" points back to BSEG "A".
    For example:
    BSEG-BELNR   9100011111  ->  REBZG = 9111122222
    BSEG-BELNR   9111122222  ->  REBZG = 9100011111
    This data is causing the loop to execute infinitely as the exit conditions are never met.
    I cannot find a SAP Note that addresses this issue. It looks like the code involved is related to items in Dispute and Part Payments.
    Has anyone out there experienced this issue?
    Many thanks,
    Stuart.

    What release are you on?
    There is note 1105687 addressing the scenario when a credit memo is entered as an invoice reference in an invoice item which can cause such an infinite loop, but that note is only valid up to rel. 6.03
    There is also note 919415 but it is for even older systems.
    If you are on a current release, then creating an OSS message is your best bet.
    It would be theoretically possible to have a recent release with some already posted documents that were entered before the patch fixing such endless loops were applied... how likely is to have such old documents is another question. SAP support should help you to clean up the problematic records if this is the case.

  • SQL stored procedure Staging.GroomDwStagingData stuck in infinite loop, consuming excessive CPU

    Hello
    I'm hoping that someone here might be able to help or point me in the right direction. Apologies for the long post.
    Just to set the scene, I am a SQL Server DBA and have very limited experience with System Centre so please go easy on me.
    At the company I am currently working they are complaining about very poor performance when running reports (any).
    Quick look at the database server and CPU utilisation being a constant 90-95%, meant that you dont have to be Sherlock Holmes to realise there is a problem. The instance consuming the majority of the CPU is the instance hosting the datawarehouse and in particular
    a stored procedure in the DWStagingAndConfig database called Staging.GroomDwStagingData.
    This stored procedure executes continually for 2 hours performing 500,000,000 reads per execution before "timing out". It is then executed again for another 2 hours etc etc.
    After a bit of diagnosis it seems that the issue is either a bug or that there is something wrong with our data in that a stored procedure is stuck in an infinite loop
    System Center 2012 SP1 CU2 (5.0.7804.1300)
    Diagnosis details
    SQL connection details
    program name = SC DAL--GroomingWriteModule
    set quoted_identifier on
    set arithabort off
    set numeric_roundabort off
    set ansi_warnings on
    set ansi_padding on
    set ansi_nulls on
    set concat_null_yields_null on
    set cursor_close_on_commit off
    set implicit_transactions off
    set language us_english
    set dateformat mdy
    set datefirst 7
    set transaction isolation level read committed
    Store procedures executed
    1. dbo.p_GetDwStagingGroomingConfig (executes immediately)
    2. Staging.GroomDwStagingData (this is the procedure that executes in 2 hours before being cancelled)
    The 1st stored procedure seems to return a table with the "xml" / required parameters to execute Staging.GroomDwStagingData
    Sample xml below (cut right down)
    <Config>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    </Config>
    If you look carefully you will see that the 1st <target> is missing the ManagedTypeViewName, which when "shredded" by the Staging.GroomDwStagingData returns the following result set
    Example
    DECLARE @Config xml
    DECLARE @GroomingCriteria NVARCHAR(MAX)
    SET @GroomingCriteria = '<Config><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><Watermark>2015-01-30T08:59:14.397</Watermark></Target><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName><Watermark>2015-01-30T08:59:14.397</Watermark></Target></Config>'
    SET @Config = CONVERT(xml, @GroomingCriteria)
    SELECT
    ModuleName = p.value(N'child::ModuleName[1]', N'nvarchar(255)')
    ,WarehouseEntityName = p.value(N'child::WarehouseEntityName[1]', N'nvarchar(255)')
    ,RequiredWarehouseEntityName =p.value(N'child::RequiredWarehouseEntityName[1]', N'nvarchar(255)')
    ,ManagedTypeViewName = p.value(N'child::ManagedTypeViewName[1]', N'nvarchar(255)')
    ,Watermark = p.value(N'child::Watermark[1]', N'datetime')
    FROM @Config.nodes(N'/Config/*') Elem(p)
    /* RESULTS - NOTE THE NULL VALUE FOR ManagedTypeViewName
    ModuleName WarehouseEntityName RequiredWarehouseEntityName ManagedTypeViewName Watermark
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity NULL 2015-01-30 08:59:14.397
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity 2015-01-30 08:59:14.397
    When the procedure enters the loop to build its dynamic SQL to delete relevant rows from the inbound schema tables it concatenates various options / variables into an executable string. However when adding a NULL value to a string the entire string becomes
    NULL which then gets executed.
    Whilst executing "EXEC(NULL)" would cause SQL to throw an error and be caught, executing the following doesnt
    DECLARE @null_string VARCHAR(100)
    SET @null_string = 'hello world ' + NULL
    EXEC(@null_string)
    SELECT @null_string
    So as it hasnt caused an error the next part of the procedure is to move to the next record and this is why its caught in an infinite loop
    DELETE @items WHERE ManagedTypeViewName = @View
    The value for the variable @View is the ManagedTypeViewName which is NULL, as ANSI_NULLS are set to ON in the connection and not overridded in the procedure then the above statement wont delete anything as it needs to handle NULL values differently (IS NULL),
    so we are now stuck in an infinite loop executing NULL for 2 hours until cancelled.
    I amended the stored procedure and added the following line before the loop statement which had the desired effect and "fixed" the performance issue for the time being
    DELETE @items WHERE ManagedTypeViewName IS NULL
    I also noticed that the following line in dbo.p_GetDwStagingGroomingConfig is commented out (no idea why as no notes in the procedure)
    --AND COALESCE(i.ManagedTypeViewName, j.RelationshipTypeViewName) IS NOT NULL
    There are obviously other ways to mitigate the dynamic SQL string being NULL, there's more than one way to skin a cat and thats not why I am asking this question, but what I am concerned about is that is there a reason that the xml / @GroomingCriteria is incomplete
    and / or that the procedures dont handle potential NULL values.
    I cant find any documentation, KBs, forum posts of anyone else having this issue which somewhat surprises me.
    Would be grateful of any help / advice that anyone can provide or if someone can look at their 2 stored procedures on a later version to see if it has already been fixed. Or is it simply that we have orphaned data, this is the bit that concerns most as I dont
    really want to be deleting / updating data when I have no idea what the knock on effect might be
    Many many thanks
    Andy

    First thing I would do is upgrade to 2012 R2 UR5. If you are running non-US dates you need the UR5 hotfix also.
    Rob Ford scsmnz.net
    Cireson www.cireson.com
    For a free SCSM 2012 Notify Analyst app click
    here

  • Update routine infinite loop

    Hello Experts,
    For loading ODS2 we are making a lookup on ODS1 for 0material based on
    purchaing document number, item line item.
    Is there any mistake in the start routine or update routine.
    Because the load goes in infinite loop. I think update routine should be changed.
    Any suggestions are appreciated
    Start routine:
    data: begin of itab occurs 0,
            pur_doc like /BIC/AZODS100-OI_EBELN,
            item like /BIC/AZODS100-OI_EBELP,
            material like /BIC/AZODS100-material,
          end of itab.
    clear itab.
    select OI_EBELN OI_EBELP MAT_PLANT from /BIC/AZODS100
             into table itab.
    Update routine for 0material
    loop at itab where pur_doc = COMM_STRUCTURE-OI_EBELN
                       and item = COMM_STRUCTURE-OI_EBELP.
           RESULT = itab-matplant.
    endloop.

    Hi,
    this takes a long time, because with each record of your data packaged it is doing the loop and scanning each row of the internal table. Use the following instead.
    Start routine:
    types: begin of t_itab,
    pur_doc like /BIC/AZODS100-OI_EBELN,
    item like /BIC/AZODS100-OI_EBELP,
    material like /BIC/AZODS100-material,
    end of t_itab.
    data: itab type hashed table of t_itab with unique key pur_doc item.
    select OI_EBELN OI_EBELP MAT_PLANT from /BIC/AZODS100
    into table itab order by oi_ebeln oi_ebelp mat_plant.
    I hope these fields are the key of the ods object.
    Update routine for 0material
    data: wa_itab type t_itab.
    read table itab into wa_itab with table key pur_doc = COMM_STRUCTURE-OI_EBELN
    item = COMM_STRUCTURE-OI_EBELP.
    if sy-subrc = 0.
    RESULT = wa_itab-matplant.
    else.
    clear result.
    endif.
    Hope this helps
    regards
    Siggi

  • 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 .

Maybe you are looking for