Can we rewrite a do-while loop as a while loop?

can we rewrite a do-while loop as a while loop?

Peter__Lawrey wrote:
You can replace
do {
// something
} while(condition);with
boolean first = true;
while(first || condition) {
// something
first = false;
If that '// something' contains a continue statement the transformation fails. Better make that:
boolean first = true;
while(first || condition) {
  first = false;
  // something
}kind regards,
Jos (<--- nitpicker ;-)

Similar Messages

  • How can I opearate indicator outside while loop?

    I do small program, I have many while loops and I want to connect wire (in my application) from each loop to AND gate then to another while loop, but how can I operate these wires to agree with the change of my application inside while loops.
    If not clear :
    In another words, suppose I want to operate indicator ouside the while loop. How can I operate indicator outside while loop, so when my application become TRUE (inside while loop) the indicator will be ON (outside while loop) and when my application become FALSE(inside while loop) the indicator will be OFF (outside while loop).
    Help me if you have any idea please..........................

    Hi Rammo,
    For the wire to carry the boolean condition from the while loop to an 'and' gate outside, the while loop must stop running
    If you want the while loop to keep on running and still pass a boolean value to a destination outside the while loop, use any one of these: property nodes, global or local variables.
    i am still not clear as to what you intend to say by this sentence
    " I want the wire that comes out from the while loop will become TRUE if it in my application is TRUE inside while loop and the opposite is true. Because I want to connect the wire that comes out from while loop to AND gate than to another application"
    plz tell me if the first part of this mail of mine answers your doubt or do you need more information?
    regards
    Dev

  • Can the case be changed while uploading the data or after uploading ????

    hi all ,
    can u pls help me ???  can the case of the data in a itab be changed while running the program? the data is uploaded to an internal table and then based on loop at that itab the conditions will evaluate to give the result.... but the problem is like wen the data is given in small letters the worste(last)  condition is executing even the data satisfies the condtion which is not supposed to happen. this is due to case sensitive problem ...can u pls help me ....can the case be changed while uploading the data r after uploading ????

    this is the itab declaration ..
    data: begin of it_input occurs 0 ,
           tra          like tstc-tcode,
         end of it_input.
    and then from the uploaded data the prog should check wheather it is having any userexits or not ...
    here comes the code...
    sort it_input by tra.
    delete adjacent duplicates from it_input  .
    loop at it_input.
               it_itab-sno = sy-tabix.
      select single * from tstc where tcode eq it_input-tra.
    if sy-subrc eq 0.
        select single devclass from tadir into v_devclass
                 where pgmid = 'R3TR'
                        and object = 'PROG'
                        and obj_name = tstc-pgmna.
             if sy-subrc ne 0.
             select single * from trdir where name = tstc-pgmna.
             if trdir-subc eq 'F'.
                select single * from tfdir where pname = tstc-pgmna.
                select single * from enlfdir where funcname =
                tfdir-funcname.
                select single * from tadir where pgmid = 'R3TR'
                                   and object = 'FUGR'
                                   and obj_name eq enlfdir-area.
             move : tadir-devclass to v_devclass.
              endif.
           endif.
           select * from tadir into table jtab
                         where pgmid = 'R3TR'
                           and object = 'SMOD'
                           and devclass = v_devclass.
           if sy-subrc = 0.
            select single * from tstct where sprsl eq sy-langu and
                                            tcode eq it_input-tra.
                      if not jtab[] is initial.
               loop at jtab.
                    select single modtext from modsapt  into str
                         where sprsl = sy-langu and
                                name = jtab-obj_name.
                    it_itab-tra        = it_input-tra.
                    it_itab-i_obj_name = jtab-obj_name.
                    it_itab-i_modtext = str.
                    append it_itab.
                    str = ''.
               endloop.
              endif.
            else.
                    it_itab-tra        = it_input-tra .
                    it_itab-i_obj_name = ' '.
                    it_itab-i_modtext = 'No user Exit exists'.
                     append it_itab.
            endif.
          else.
                    it_itab-tra        = it_input-tra .
                    it_itab-i_obj_name = ' '.
                    it_itab-i_modtext = 'Transaction Code Does Not Exist'.
                     append it_itab.
          endif.
    endloop.

  • Can you use soundtrack pro's loops in your youtube videos or do you need to purchase a license since it is royalty free?

    Can you use soundtrack pro's loops in your youtube videos or do you need to purchase a license since it is royalty free?
    I understand they are royalty free, I am just confused about using the actual loops for films, videos, etc - if there is a special license you must purchase or what?
    Yes sure, it's a library and may be used a lot - but is it legal or against agreement?
    And to clarify - what about music I create on the program , that is ok right?

    If you purchased the software you have the right to use the loops that came with the software in the software to make whatever you want.

  • How can we handle browser settings while dealing with the security ?

    Hi ,
    how can we handle browser settings while dealing with the security ?When we configured security in web.xml , during the first request the container is asking for the authentication credentials once they are provided it go's on. but when the user gives a fresh request from the second window within the same browser that time it is not asking for authentication. How can we overcome this.Is there anything to do with server configurations?
    How can we make the container no to keep the things or act like session?

    Ya... I am taking a small example need not happen always but a kind of possibility i am thinking off.
    once the user sign out and just left without closing the browser and a friend (suppose not a good friend ... just kidding...) of that user may open the same jsp or file .This time the security is breached. If that feature or property exists....
    I know what you might say ... the user will log-out before leaving where a programer might invalidate the session at the time of log out.
    Consider the case of a bad Programing or just a programer might forget to invalidate,At that time as a application administrator how can he solve that issue.
    Thanks.......
    Edited by: user8483670 on Jun 6, 2011 1:08 AM
    Edited by: user8483670 on Jun 6, 2011 1:09 AM

  • I have an unlocked iphone 4s bought from apple. Will be in London and Paris and would like to know if how I can purchase a data plan while on vacaqtion

    I have an unlocked iphone 4s bought from apple. Will be in London and Paris and would like to know if how I can purchase a data plan while on vacaqtion

    Can I still use the phone in Boston when I move there?
    Only on a supported GSM carrier.
    Will there be networks I cant use?
    Yes. CDMA networks.
    As I understand it the 4S supports GSM and CDMA networks worldwide.
    No, you've misunderstood. The GSM iPhone you can buy in Ireland supports GSM networks only i.e. AT&T

  • With iOs 7 and the iPhone can someone use the phone while also using a communication app such as Speak It or Assistive Chat? These are text to speech systems for people who cannot speak well. Thanks you!

    With ios 7 and the iPhone can someone use their phone while also using a text to speech app, such as Speak It or Assistive Chat? These apps are used by people who have difficulty with speech production.
    Thank you.

    My iPhone 5 wouldn't start after I turned it off a few minutes after writing this. It went into recovery mode and I had no choice but to connect to iTunes on PC and restore.
    I restored to factory setting first, just to validate my phone was okay. For a second consecutive iOS update, the  iPhone 5 did not update smoothly while connected to PC and iTunes - I had to retry two times before the progress bar for the update showed. (The exact same problem with the restart occured when I updated to 7.0.4.)
    The good news is that I was ultimately able to restore the iPhone 5 to factory settings while running iOS 7.0.6. I did have a backup from about a month ago lying around and was able to successfully restore with that as well, so the damage done is almost negligible since I had my contacts, notes, mail, etc. backed up to iCloud.
    Once I completed both restores, the sync with iTunes worked fine.

  • I'm trying to record audio into my iPad2 using GarageBand and an iRig, but I can't monitor my tracks at the same time as recording, meaning if I lay down a drum track and attempt to record guitar, I can't hear the drums while recording. Thoughts?

    I'm trying to record audio into my iPad2 using GarageBand and an iRig, but I can't monitor my tracks at the same time as recording, meaning if I lay down a drum track and attempt to record guitar, I can't hear the drums while recording. Thoughts?

    Hi, I have this exact same problem. I haven't been using an iRig, just a cheap USB-jack cable. I managed to do this with the first cable I bought, but since it broke I've been unable to find a replacement that allows me to hear the drums while recording. DId you manage to get over this issue? If so I would really like to know how. Thanks and best wishes.

  • How can i change the font while im coding?

    How can i change the font while im coding? I am not talking about the final product and inserting fonts in my documet i am talking about when i am in the progress of coding I want to change the font so it is way more pleaseing to the eye when I am staring at it while coding? please do help and thanks!

    Editing the source is a bit of a pain because you'll have to redo it after every update.  It's better to write yourself a mini-extension that adds a new stylesheet -- that is also very simple to do.  Just follow these instructions: https://github.com/adobe/brackets/wiki/Customize-Your-Code-Font.
    - Peter

  • TS1702 I have an app that appears to need to be updated. I clicked to update three days ago. It has started to update and will not finish. How can I delete the app while its in the middle of updating?

    IPhone 5
    I have an app that appeared to need to be updated. I clicked to update three days ago. It has started to update and will not finish. How can I delete the app while its in the middle of updating?

    Locked on an update can mean a couple of different things. So there are a number of things to try, but start with these.
    If you have a "waiting" icon, try tapping on the icon and see if you can pause the update/download. Of it pauses, tap on it again and see if it will resume.
    Try holding down on the icon until all of the icons on the screen wiggle. If the X to delete pops up on the waiting/stalled app -  tap the X to delete the app. Tao,the home button and the apps will stop wiggling.
    You can also try this and see if the downloads will resume. Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Can i change to ethernet while syncing thru wireless? apple tv 1st generation

    im syncing iTunes with my apple tv (first generation) for the first time thru a wireless connection but its taking too long. can switch to ethernet connection while the scycing is in progress to make the sync faster?

    Welcome to the Apple Community.
    No, you'd need to stop the sync, change connection and initiate a sync again. I doubt you'd lose much time having to start the sync again and you may well save a lot of time changing connection sooner rather than later if your wifi network is that slow.

  • Can't locate my user apple loops ?

    who can help I made some apple loops and imported a few, there in my loop browser and playable but I can't find them on my hard drive and there is no user-loop file ??/

    Hi
    User-made AppleLoops are stored in the <USER> Library:
    <USER>:Library:Audio:Apple Loops:User Loops:SingleFiles
    If you are running Lion, there is a problem in that the <USER> Library is a 'Hidden' Folder (don't ask!).
    To get to see it, in the Finder, Use the "Go:Go to Folder function and type '~/Library', or OPTION Click on the 'Go to Folder' function.
    HTH
    CCT

  • Can we use FCP conviniently while my mac pro is attached to a LED tv

    can we use FCP conviniently while my mac pro is attached to a LED tv (46inch).
    I am afraid if the icons will also blow up/get bigger and would become inconvinient to use.

    most large TV sets are still 1080p (1920 by 1080).
    The icons will appear to take up more space (in square inches) on the TV, but will be "grainy" compared to your monitor. The fundamental size of icons and items on screen (in pixels) will not change. When you return to using a monitor, things will be the same as before.

  • How can I have one thing open in Safari on my MacBook Pro and search for another thing in Safari without closing out of the other? For instance, How can I leave Pandora playing while I search Facebook?

    How can I have one thing open in Safari on my MacBook Pro and search for another thing in Safari without closing out of the other? For instance, How can I leave Pandora playing while I search Facebook?

    With Safari open use the Command + T keyboard shortcut to open a new tab.
    Or, Command + N to open a new window.

  • How can I rewrite this update stmt to improve its poor performance?

    Hi,
    I have the following update stmt that runs for over 6 hours. Here is the SQL and its plan:
                UPDATE TABLE1
                     SET mainveh = 'Y'
                 WHERE (comp#,polnum,a8dtef,a8deef,a8dtac,
                        DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
                    IN (SELECT comp#,polnum,a8dtef,a8deef,a8dtac,
                               MAX(DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
                          FROM TABLE1
                         GROUP BY comp#,polnum,a8dtef,a8deef,a8dtac);
    PLAN_TABLE_OUTPUT
    | Id  | Operation             | Name     | Rows  | Bytes |TempSpc| Cost (%CPU)|
    |   0 | UPDATE STATEMENT      |          |     1 |   108 |       |   798K  (1)|
    |   1 |  UPDATE               | TABLE1   |       |       |       |            |
    |   2 |   HASH JOIN           |          |     1 |   108 |  1079M|   798K  (1)|
    |   3 |    TABLE ACCESS FULL  | TABLE1   |    21M|   834M|       |   224K  (1)|
    |   4 |    VIEW               | VW_NSO_1 |    21M|  1364M|       |   440K  (1)|
    |   5 |     SORT GROUP BY     |          |    21M|   794M|  2453M|   440K  (1)|
    |   6 |      TABLE ACCESS FULL| TABLE1   |    21M|   794M|       |   224K  (1)|I'm using Oracle 10.2.0.3. The TABLE1 table has 21 million rows. The update stmt will update about 15 million rows. How can I rewrite this update stmt so it'll perform better? There is a primary index on all the columns selected in the subquery. That is the only index on TABLE1.
    Thank you!
    Edited by: user6053424 on Jul 21, 2010 6:59 AM

    Hi,
    Thank you for your suggestions. There is an index on the columns in the group by, it is the PK index on TABLE1. I'm suspecting that due to the amount of data to update, the optimizer decided that full table scan is cheaper than index scan. I'm very interested in the GTT idea, but still need some help if I decide to create a GTT from the subquery, because if I just do this:
    create global temporary table table1_tmp
    on commit preserve rows
    as SELECT comp#,polnum,a8dtef,a8deef,a8dtac,
               MAX(DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
          FROM TABLE1
         GROUP BY comp#,polnum,a8dtef,a8deef,a8dtac;then the original update stmt still has the DECODE and such in it, I'm not sure how much benefit that'll do to us:
    UPDATE TABLE1
                     SET mainveh = 'Y'
                 WHERE (comp#,polnum,a8dtef,a8deef,a8dtac,
                        DECODE(everif,'Y',10000,0)+auunit*100+vrcdsq)
                    IN (SELECT comp#,polnum,a8dtef,a8deef,a8dtac,???
                          FROM TABLE1);Your input is greatly appreciated! Thanks!

Maybe you are looking for