How to loop with varying values depending on where you are in the loop

Hi,
I have need of loops / nested loops that pick different figures depending on where you are in the loop.
The whole function needs to run through 'ml' times. 'ml' is a dynamic figure.
Loop 1 = While the loop is within the first 12 iterations, 'exconemp' must equal 100. For iterations 13 - 24, 'exconemp' must equal 102.5, for 25 - 36 it will be 105.06, for 37 - 48 it will be 107.69. This needs to change every 12th iteration until it has reached 'ml'. The calculation takes the value of the previous 'exconemp' and then multiplies that by 0.025.
Loop 2 = While the loop is within the first 120 iterations, 'abc' must equal 0.015 and any further iterations must use 0.01. This must also work in a way to figure out whether 'ml' is higher or lower than 120 and work accordingly.
My main issue is this - how do I get the loops to run through as this:
While the iteration is < 12, do this, THEN take the final figure (12th iteration) and start on 13 - 24, do this THEN etc etc.
How do I produce a THEN statement? I can get the code to pick up the final values, but not change along the way.
I think that I may be better creating an array for Loop 1, but I am not entirely convinced of this. I also think it would be better/tidier if I can get 'month 1 total' and 'month 2 total' into the loops, but am not sure on how to do this.
The values that I need to produce are (only first 36 shown):
1 - 12 = 125.55, 251.65, 378.31, 505.52, 633.29, 761.63, 890.53, 1019.99, 1150.03, 1280.63, 1411.81, 1543.57
13 - 24 = 1679.05, 1815.12, 1951.79, 2089.06, 2226.93, 2365.41, 2504.50, 2644.20, 2784.52, 2925.45, 3067.00, 3209.18
25 - 36 = 3355.19, 3501.85, 3649.15, 3797.11, 3945.71, 4094.96, 4244.87, 4395.44, 4546.68, 4698.57, 4851.14, 5004.38
var ml = 240 // dynamic figure, multiple of 12 up to 780
var exconemp;
var exconem = 100;
var inf = 0.025;
var tree;
var tec;
var power;
var fvis;
var abc;
var fvee;
var tfv;
function myfunction() {
//Loop 1
//while (ml <= 12) {
  exconemp = exconem;
//while (ml > 12) {
// exconemp = exconem*inf;
//end Loop 1
  trace("exconemp=", exconemp); // employees contribution
tree = exconemp/(1-0.2)-exconemp;
tec = exconemp + tree;
  trace("tree", tree);
  trace("tec", tec);
power = Math.pow(1+0.07, 1/12);
//Loop 2
//while (ml <= 120) {
  abc = 0.015;
//while {
  //abc = 0.01;
//end Loop 2
fvis = power*(1-abc/12);
trace("fvis=", fvis);
fvee = tec*fvis;
trace("fvee=", fvee); // month 1 total
tfv = (tec+fvee)*fvis;
trace("tfv=", tfv); // month 2 total
for (var i:Number = 0; i < ml; i++)
      tfv = (tec+tfv)*fvis;
  trace("tfvloop=", tfv);
I hope that I have explained this well enough.
Many thanks in advance.

I think this will do it although I am not quite getting the numbers you posted.
stop();
var ml = 48; // dynamic figure, multiple of 12 up to 780
var exconemp;
var exconem = 100;
var inf = 0.025;
var tree;
var tec;
var power;
var fvis;
var abc = 0.15;
var fvee;
var tfv;
myfunction();
function myfunction()
    exconemp = exconem;
        for(var index:uint = 1; index <= ml; index++)
            trace(index + "--------------------------------");
                tree = exconemp/(1-0.2)-exconemp;
                tec = exconemp + tree;
                power = Math.pow(1+0.07, 1/12);
                fvis = power*(1-abc/12);
                fvee = tec*fvis;
                    if(index == 1)
                        trace("month 1 total=", fvee);
                    else if(index == 2)
                        tfv = (tec+fvee)*fvis;
                        trace("month 2 total=", tfv); // month 2 total
                    else
                        tfv = (tec+tfv)*fvis; //now that we are here the tfv self perpetuates on itself
                        trace("month " + index + " total=", tfv); // month n total
            if(index % 12 == 0)
                exconemp = exconemp*(1+inf);
                trace("changed exconemp to: " + exconemp);
            if(index % 120 == 0)
                abc = .01;
                trace("changed abc to: " + abc);

Similar Messages

  • How do you know where you are in the Lion queue??

    Can someone tell me how you know where you are in the queue for the Lion download? I am just left with the waiting signal over the lions head?

    Look here ...
    iCloud: iCloud storage and backup overview
    https://www.apple.com/support/icloud/backup/

  • Display a message in a For Loop  with field value

    Hello All,
    pls,i wanna display a message in a For Loop with field value the code is:
    FOR Q1 IN GET_SUM_EXP_QUANTITY LOOP               .
    INSERT INTO PLN_PLAN_DISTRIBUTION_WAY
    (FIN_YEAR_CODE , MONTH_CODE , MATERIAL_CODE , DISTRIBUTION_WAY , EXPECTED_QUANTITY , GROUP_CODE)
    VALUES (:PLN_PLAN.FIN_YEAR_CODE , TO_CHAR(V_FROM_DATE,'MM') , Q1.MATERIAL_CODE , 1 , V_MONTHLY_QTY , Q1.GROUP_CODE);
    MESSAGE(':PLN_PLAN.FIN_YEAR_CODE'||:PLN_PLAN.FIN_YEAR_CODE ||' '||'V_FROM_DATE = '||TO_CHAR(V_FROM_DATE,'MM'), 'Q1.MATERIAL_CODE'||' '|| Q1.MATERIAL_CODE||' '||'DISTRIBUTION_WAY'||' = 1'||'EXPECTED_QUANTITY'||' = '|| V_MONTHLY_QTY||'GROUP_CODE'|| ' '|| Q1.GROUP_CODE);
    FORMS_DDL('COMMIT');
    How 2 display a message with the value:
    Q1.MATERIAL_CODE
    Q1.GROUP_CODE
    message(Q1.MATERIAL_CODE)     
    gave me numeric or value error on run time when pressed on button
    Regards,
    Abdetu..

    Thanks 4 reply..
    again they r in a For Loop as mentioned above...
         INSERT INTO PLN_PLAN_DISTRIBUTION_WAY
                                                           (FIN_YEAR_CODE , MONTH_CODE , MATERIAL_CODE , DISTRIBUTION_WAY , EXPECTED_QUANTITY , GROUP_CODE)
                                            VALUES (:PLN_PLAN.FIN_YEAR_CODE , V_REPAIR_MONTH , Q1.MATERIAL_CODE , 1 , V_REPAIR_Qty , Q1.GROUP_CODE);
    FORMS_DDL('COMMIT');
    The fields in bold r required to be displayed for testing puposes..
    this gives me numeric or value error in runtime..
    Best regards,
    Abdetu..

  • Hello I have encounted a problem with Photoshop. Normally when you start a new documant, you are given the options to have A4, A3, ect page set ups. These inbuilt page set ups seem to have disapeared, does anyone please know how to fix this? Many thanks

    Hello I have encounted a problem with Photoshop. Normally when you start a new documant, you are given the options to have A4, A3, ect page set ups. These inbuilt page set ups seem to have disapeared, does anyone please know how to fix this? Many thanks Ben  [email protected]

    Hello Trevor
    Thanks for your message. You can custom set pages but there are no preset of page sizes like A4, A3, ect. I cannot click the size preference, nothing comes up
    Ben

  • I have Outlook 2011 installed on my Mac Pro, but I can not install it icloud. I can only get through imail, iCal and Address Book in Mac native anyone know teach me how to work with Outlook 2011 icloud? thank you

    I have Outlook 2011 installed on my Mac Pro, but I can not install it icloud. I can only get through imail, iCal and Address Book in Mac native anyone know teach me how to work with Outlook 2011 icloud? thank you

    "iCloud requires iOS 5 on iPhone 3GS or later, iPod touch (3rd and 4th generation), iPad, or iPad 2; a Mac computer with OS X Lion; or a PC with Windows Vista or Windows 7 (Outlook 2007 or 2010 or an up-to-date browser is required for accessing email, contacts, and calendars). Some features require a Wi-Fi connection. Some features are not available in all countries. Access to some services is limited to 10 devices."
    From here >  http://www.apple.com/icloud/

  • How do I with an iTune account set up in Germany access the UK store?

    Hi there,
    Have watched fellow non-Germans have trouble accessing UK or other national stores for downloads when they set up their iTunes account in Germany. How can I set up my iTunes account so that my store is the UK one?
    Thanks

    You cannot.
    You can ONLY use the itunes store of your country of residnece ( proven by the issuing country of your credit acrd and the valid billing address on that card) AND ONLY while you are inside the borders of that country.
    You cannot use other countrys itunes store.  This is a violation of the terms of service of the itunes store.
    "The Service is available to you only in the United Kingdom. You agree not to use or attempt to use the Service from outside this location. iTunes may use technologies to verify your compliance."
    http://www.apple.com/legal/itunes/uk/terms.html#SERVICE
    It is the same for each country.

  • HT2128 Does any one know how to attach a document from your mail, while you are already in your e-mail, meaning not having to look for your file first and then open the e-mail.

    Does any one know how to attach a document from your mail, while you are already in your e-mail, meaning not having to look for your file first and then open the e-mail.

    Luis
    Good question - and one that a lot of (business) people would like solved!
    Your question prompted me to do some research, and I found this workaround posted by Scott Grossberg:
    His solution actually addresses a second problem too - how to attach a document when replying to an email message. In your case you may not need to consider the "reply" aspect - but if not right now, it'll come in useful someday!
    I've pasted it verbatim - if it works for you (it does for me) then all credit goes to Scott for solving the problem. There's just one thing I'd add to his solution: you will probably want to rename the message, as by default Goodreader gives it the Subject line: Mail with GoodReader attachments.
    THE GOODREADER OPTION
    1.  CREATE the document you want to send.
    2.  SAVE it to GoodReader (this will require you to buy and install the app).
    3.  Go to your email and OPEN the email thread to which you want to Reply and attach your file.
    4.  COMPOSE your Reply.
    5.  DOUBLE TAP the message.
    6.  TAP SELECT ALL. This will copy the entire email thread.
    7.  OPEN GOODREADER on the iPad and go to the file you want to send as part of your Reply.
    8.  At the bottom of the GoodReader screen you will see an EXPORT icon (it looks like a rectangle with an arrow pointing to the right).
    9.  TAP the Export button.
    10.  TAP EMAIL FILE. Depending on your needs, tap either SEND FILE “AS IS” or “FLATTEN ANNOTATIONS.” This will open a compose message screen with the chosen document already attached.
    11.  TAP in the body of the email screen. TAP PASTE. This will place your composed Reply and the prior email thread into the message.
    12.  ENTER the Recipients’ names in the TO: field of your message.
    13.  SEND your email Reply.
    The modified version (= when composing a new message rather than a reply):
    1 Make sure that the doc you want to attach is saved in GoodReader
    2 In the message you are composing, double tap, select all, and then copy.
    3 Open GoodReader and select the file you want to attach
    4 Select the export button at the bottom of screen
    5 Select e-mail file
    6 Position cursor in body of the email message, tap and paste. You may want to delete the "sent from GoodReader" text that precedes the attachment.
    7 Rename your message (as by default it will be Mail with GoodReader attachments)
    8 Add the recipient's address in the To field.
    Hope this helps! All thanks to Scott for this workaround.

  • How to return a profile in Game Center. where you want to enter the old nikneim?

    How to return a profile in Game Center. where you want to enter the old nikneim?

    It's not actually round.  It is slight flattened vertically.
    Anyway...
    I have an Action that places guides at 50% (50pc) vertically and horizontally to give me the exact center of an image file, or you place them manually with View > New Guide.
    After doing that I would place the circular select from that center point using Shift and Alt (Opt) and get it more or less where I wanted it.  Then change the selection into a work path.
    You can use Free Transform to reshape and position that work path by selecting it in the Paths panel.
    Then place your text, and if you still need to fine tune, use Free Transform again, but on the Type layer.
    You could also use Free Transform to reshape the BG graphic to make it round.

  • GB won't open- This is what I get... Path does not exist: /Library/Audio/Apple Loops Index  st: /Library/Audio/Apple Loops Index w/out this directory you cannot use the Loop Browser

    Path does not exist: /Library/Audio/Apple Loops Index  st: /Library/Audio/Apple Loops Index w/out this directory you cannot use the Loop Browser.  Then I get this message...
    Instrument Library Invalid
    GarageBand Ecpects a valid instrument foledr in /Libraty/Application Support/GarageBand
    Please choose a valid instrument Library folder or quit and re-install GB
    Any solutions?

    Is this a new installation of GarageBand or has it worked before on the same computer?
    Or have you transferrred your GarageBand from a different computer?
    The error message is saying, that your GarageBand installation is incomplete. There are essential foldrs missing in your system library. 
    Check, if indeed both folders are missing or if only the permissions are set incorrectly.
    Your system library (the folder "System" directly on your system drive) should have the following folders inside the folder "Audio", and they need to be readable by the system and by administrators.
    And in the folder /Library/Application Support there should be the Instrument Library.
    If these folders do not exist (or no longer exist), restore them from your backup-  If your GarageBand version is a new installation, the application may not hve been downloaded or installed completely, then reinstall GarageBand.
    What is your GarageBAnd version, and how did you install it originally?
    Regards
    Léonie

  • While making a backup copy in Itunes of my Iphone I receive the following error message: While making a backup copy of this Iphone (-35) an error has occurred.  Do you want to continue with altering this Iphone? When you continue al the material on this I

    While making a backup copy in Itunes of my Iphone I receive the following error message: While making a backup copy of this iPhone (-35) an error has occurred.  Do you want to continue with altering this Iphone? When you continue al the material on this Iphone will be lost.
    I reinstalled iTunes but that dit not help. After synching iTunes with my iPhone it also asks to authorize my pc and when i Click on ok, it says it is already authorized.
    Please can somebody help me, so I can make backup.
    Greetz,
    Derk

    It's likely that your backup is corrupt. Try deleting the backup, then right click on the name of the phone in iTunes and choose "back up". To delete go to iTunes Preferences, Devices tab. Highlight and delete the most recent backup. Note that sometimes deleting this way leaves some garbage around that can still interfere with a new backup, so you should verify that the backup folder is empty.
    from: http://support.apple.com/kb/HT4946
    The folder where your backup data are stored varies depending on the computer's operating system.   Make sure the backup folder is included in your periodic data-backup routine.
    iTunes places the backup files in the following places:
    Mac:  ~/Library/Application Support/MobileSync/Backup/
    Windows XP:  \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    Note: To quickly access the Application Data folder, click Start, and choose Run. Type %appdata% and click OK.
    Windows Vista and Windows 7:  \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\
    Note: To quickly access the AppData folder, click Start. In the search bar, type %appdata% and press the Return key.

  • HT4061 How do I consolidate purchases from two different ids that are on the same bank account, and eliminate the extra id without losing any purchases?

    How do I consolidate purchases from two different ids that are on the same bank account, and eliminate the extra id without losing any purchases? I want my music to match on both ipad and computer.

    Purchases are forever tied to the AppleID they were bought with. There is currently no way to consolidate AppleIDs. Sorry.

  • How to unlock icloud activation if you are not the owner

    how to unlock icloud activation if you are not the owner

    Contact AppleCare (or Apple ID Support), upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    I'm not exactly sure what procedures are in place for such events but Apple can assist in such cases, but it may take a while and you may need to provide a death certificate and a note from the executor that the iPad has been willed to yourself, along with an original proof of purchase.

  • The area on my toolbar where you can change the white balance mode is now gone from my toolbar.  How can I get it back?

    The area on my toolbar where you can change the white balance mode is now gone form my toolbar.  How can I get it back?

    Your basic panel must have been accidentally deselected.
    Simply right-click on one of the other panels e.g. Tone Curve and choose basic again - see image below.
    You can also select solo mode, if you prefer to work in one panel at a time with the others collapsing automatically when you click on another tab.

  • HT1435 how long does the recycle program take or do they give you an ipod straight away when you are at the store.when you buy from the store do they do free ipod engraving

    how long does the recycle program take or do they give you an ipod straight away when you are at the store.when you buy from the store do they do free ipod engraving

    How recently did you switch?  If it's less than 60 days, then Verizon simply reinstates your previous account.  The fact that you were on the EDGE plan and mailed the devices back, and they apparently are somewhere in the system, could cause complications, and it might just work out that you just go back on the same plan and they set you up with the same devices.  I'm not sure how it will go - but since you are still being billed for the devices... 

  • HT4796 Migration assistant is telling me that it has lost connection with my Mac and to ensure they are on the same network.  They are, and an ethernet cable is plugged into them.  What do i do?

    Migration Assistant has been running since yesterday evening.  My Dell is now telling me that its trying to reconnect to my Mac and to ensure they are both using the same network.  I have an Ethernet cable plugged in them and they are both on the same WiFi.  What can I do?

    Hello Wyodor,
    thanks for your reply on my question.
    You are wright the index file is 308 KB.
    And offcourse that I delete my files and documents is not an Iweb problem, but because my English is not that good, that I thougt I try to tell the whole story, and hope people can read trough the lines.
    Why I didn't use Iweb to upload to the server is because the server company recommanded to use file zilla. And I am a nobody with this kind of things, so I did exactly what they tell me to do.
    No, i did not make a backup of Iweb and the domain file, but reading other messages on this forum showed me that I can maybe try to make empty the cashfile (?)
    and otherwise I have bad luck and have to make my website again. Offcourse I have a lot of examples from all the pages (copied from the local map to my USB stick) and my website is aprox. 15 Mb, (not so big) so it will cost me a few nigths.
    But I'm still hoping on a miracle :-)
    greetings Lasource

Maybe you are looking for

  • Can't view shared images via browser

    I use an old version of Skype, and I do not want to update. Whenever somebody sends an image via Skype, I see this message:   <user> sent a photo.   This device doesn't support Skype's new photo sharing features yet, but you can still view it in your

  • Help with duplicate results

    Hi, I need help desperately. The following is an example of the data that I have. I have two tables one name Customers and the other named Orders. The tables have the following attributes CUSTOMER CustomerNum, CustomerName, OrderNum ORDER OrderNum, O

  • Connecting two printers one IMAC

    Is it possible to connect two printers to an IMac ? One is a HP printer,fax,scanner and the other ia a canon printer only. Currently, the Canon is connected via USB, and working fine, and I can print from my laptop over my wireless network. What woul

  • IOS text field problem.

    I need the user to enter a word, so I added a simple text field to the stage.  However, it behaves strangely on the actual device (iPod Touch). Attached are two screenshots that show how the font size increases when the input is activated.  Has anybo

  • Import Accounts from AD to OD

    Hello All, How can I import accounts from the AD into the OD? I have my directories set up and working fine. My server is an OD master connected to an AD domain, and I can see all of the AD accounts in the Workgroup Manager. How can I now import thos