Looping over arrays?

Hello,
I have a report which gives monthly totals of peoples
production which is categorized and totaled. I also need the
categories to have a Year to Date total with a combined year to
date total. Doing this with queries is easy, but has a huge effect
on load time. I am new to arrays and curious if this would be the
correct direction. Each person on the report has a reportOrder
which is sequential to the order on the report. If i had year to
date totals with the report order (YearToDateUser[1] ,
YearToDateUser[2], YearToDateUser[3]), is there a way to loop thru
to output in the same order? Is this the wrong way to skin this
cat? Any ideas would be greatly appreciated.
Thanks,
Matt

Silly me....That was simple.
<cfloop from="1" to="#qryGetOrder.recordcount#"
index="i">
<td
class="wt"><cfoutput>#ArraySum(yeartodatepersons
)#</cfoutput></td>
</cfloop>
Sorry to bother you all.

Similar Messages

  • Looping over an array avoiding scriptlets

    Hello,
    I want to loop over an array avoiding java scriptlets. Here is the code I would like to "clean".
    <%
    int rowCol=0;
    for(int i=0; i<countryArray.length; i++){
    rowCol++;
    Country country = (Country)countryArray;
    out.println("<tr " + ((rowCol%2==0)?("class=\"evenRow\""):("class=\"oddRow\"")) + ">");
    out.println("<td class=\"countryName\">" country.getName() "</td>");
    out.println("<td class=\"countryCapital\">" country.getCapital() "</td>");
    out.println("<td class=\"number\">" + country.getFormattedLandArea() + "</td>");
    out.println("<td class=\"number\">" country.getFormattedPopulation() "</td>");
    out.println("<td class=\"number\">" country.getFormattedGdp() "</td>");
    out.println("<td class=\"number\">" country.getFormattedGdp_per_head() "</td>");
    out.println("<td><a class=\"more\" href=\"pais.jsp?countryID=" + country.getId() + "\">m?s...</a></td>");
    out.println("</tr>");
    %>
    Can anyone give me some guidelines please?
    Thanks in advance,
    Julien.

    you mean this:
    <%
    int rowCol=0;
    for(int i=0; i<countryArray.length; i++){
      rowCol++;
      Country country = (Country)countryArray;
    %>
    <tr class="<%= rowCol%2==0? "evenRow" : "oddRow" %>">
    <td class="countryName"><%= country.getName() %></td>
    <td class="countryCapital"><%= country.getCapital() %></td>
    <td class="number"><%= country.getFormattedLandArea() %></td>
    <td class="number"><%= country.getFormattedPopulation() %></td>
    <td class="number"><%= country.getFormattedGdp() %></td>
    <td class="number"><%= country.getFormattedGdp_per_head() %></td>
    <td><a class="more" href="pais.jsp?countryID=<%= country.getId() %>">m?s...</a></td>
    </tr>
    <%
    %>

  • Looping over a structure of arrays

    Hi Guys, I am trying to loop over a structure of simple
    arrays. The structure's second column contains a 1 dimentional
    array.
    I can't seem to get the proper syntax for my loop.

    I want to be able to dynamically loop over my query and
    decrypt it as I pass it into my structure. I have figured the code
    out to loop over the query and pass it to the structure. My problem
    now is whn I go to decrypt it I get this Error.
    There has been an error while trying to encrypt or decrypt
    your input string: Input length (with padding) not multiple of 16
    bytes.
    How can I fix this?
    Here is my code could it be because my varchar columns were
    not long enough. Here is my code.

  • Looping over QoQ Where Clause

    I have two queries. One is a main query that we pull from a form submission. The second is a small query resultset that lists different subgroups in my company and what main group they belong to. I pull several QoQ from the main query. In the main query results, there is a column that holds the subgroup information. I am trying to do a Q0Q where I group the data from the main query into the main groups for analysis. Here is an example...
    Main Query
    record 1 - subgroup 1
    record 2 - subgroup 2
    record 3 - subgroup 3
    Second Query
    Subgroup 1 - Main Group 1
    Subgroup 2 - Main Group 2
    Subgroup 3 - Main Group 1
    So I am trying to loop over a QoQ on the main query where the result set would contain the information only from Main Group 1. So record 2 would be eliminated. I have tried using an IN clause with a cfloop, but I run into syntax trouble with the comma. I also tried looping over the QoQ as a whole and the resulting dump is only the last record.
    If there is anything else you need, let me know.
    Any thoughts?
    Clay
    P.S. Here is a code sampling...
        <cfquery name="rsGroup" datasource="nps">
        SELECT *
        FROM "GROUP"
        WHERE GROUP.PrimaryGroup = '#form.primarygroup#'
        </cfquery>
        rsGroup - <cfdump var="#rsGroup#">
        <cfloop query="rsGroup" startrow="1" endrow="#rsGroup.RecordCount#">
            <cfquery name="rsGroupQoQ" dbtype="query">
            SELECT *
            FROM rsNPS
            WHERE rsNPS.grp = '#rsGroup.group#'
            </cfquery>
        </cfloop>
        rsGroupQoQ - <cfdump var="#rsGroupQoQ#"><cfabort>

    ok...I figured it out. I thought I would post my solution in case anyone else runs into this. Also, if anyone out there has a better way, let me know.
    <!---Dummy array to house 'blank' value for adding of column to main query--->
    <cfset GroupArray = ArrayNew(1)>
    <!---Variable that adds mainGroup column to main query with blank data from dummy array--->
    <cfset addMainGroup = QueryAddColumn(rsNPS,'mainGroup',GroupArray)>
    <!---Loop that sets value on added mainGroup column based off of main query grp column value--->
    <cfloop query="rsNPS" startrow="1" endrow="#rsNPS.RecordCount#">
        <cfif rsNPS.GRP EQ "xxxxx"><cfset rsNPS.mainGroup = "yyyyy"></cfif>
        <cfif rsNPS.GRP EQ "xxxxxxxxxx"><cfset rsNPS.mainGroup = "yyyyyyyyyy"></cfif>
        <cfif ...etc. ...
    </cfloop>

  • CFScript Math expression - Summing up looped over data

    If I loop over numeric data and  I want to sum that data I am looking for the correct manner to do so. Of course I want to do this in cfscript.
    I know that I could go the route of doing a one demensional array and using the array sum function and I could also use stauctures.
    I am interested in different solutions to this problem.
    My end state is that I need to sum and average looped dynamic data for reporting purposes.
    For purposes of example static values will be helpful for better understanding.
    Thanks in advance.

    Owain,
    This is what I came up with and it outputs the looped data. Now I am trying to add it up and average the results.
    BTW Adam,
    Be delusional on a Microsoft or Oracle forum board.
    Now that would be some fun reading cutting through those flames! (In a patronising Kinda Way!).

  • Loop Over Nested Structure

    Hello,
    Can someone please demonstrate how I would use a cfLoop to
    loop over and output the contents of this fictious nested
    structure?
    Thank You!

    mletson wrote:
    > I figured it out. If anyone has a better solution,
    please let me know.
    >
    > <cfloop from="1" to="#structCount(student)#"
    index="x">
    >
    > <cfset variables.studentID = "student00" & x>
    >
    > <tr>
    >
    <td><cfoutput>#student[studentID]["firstName"]#</cfoutput></td>
    >
    <td><cfoutput>#student[studentID]["lastName"]#</cfoutput></td>
    >
    <td><cfoutput>#student[studentID]["phone"]#</cfoutput></td>
    > </tr>
    >
    > </cfloop>
    >
    A slightly simpler version using the structure form of the
    <cfloop...>
    tag. It also demonstrates both array notation, that you used,
    as well
    as dot notation. Finally it puts a single <cfoutput...>
    block around
    the entire loop. This can provide a small but accumulative
    performance
    improvement.
    <cfoutput>
    <cfloop collection="#student#" item="aStudent">
    <tr>
    <td>#aStudent["firstName"]# OR
    #aStudent.firstName#</td>
    <td>#aStudent["lastName"]# OR
    #aStudent.lastName#</td>
    <td>#aStudent["phone"]# OR #aStudent.phone#</td>
    </tr>
    </cfloop>
    </cfoutput>

  • Looping Over INSERT

    I've got a form. The form asks the visitor their address
    (first name, last name, street address, apartment number, city,
    state, and zip code... each a separate text field). This form is
    repeated 10 times on the page, allowing the visitor to enter
    multiple addresses. I've given each form field a unique name by
    just appending "_1" or "_2" after it. For example, my fields are
    named...
    FIRST FORM BLOCK
    first_name_1
    last_name_1
    SECOND FORM BLOCK
    first_name_2
    last_name_2
    Each form block (address) will be inserted into a table in my
    database as a new row. Is there a quick and easy way to loop over
    the insert 10 times, rather than have 10 separate INSERT statements
    in my code? A CFLOOP would work just fine if not for dynamic form
    field names, but I would have to take into account the "_X". I want
    to say I've done this before; I'm just overthinking.

    <cfloop from="1" to="10" index="i">
    <cfquery ...>
    INSERT INTO ...
    (aCol,bCol,cCol...)
    <!--- The important part, accessing the form structure
    with array
    notation --->
    #form['first_Name_' & i]#,
    #form['last_Name_' & i]#
    </cfquery>
    </cfloop>
    The array notation for a complex variables is a very powerful
    concept.
    Many advance techniques can be used with it.

  • Value Mapping: how to loop over a nested context in a adv. user function

    Hello,
    i have the following source structure:
    <rec> (1:1)
    <field1>aaa</field1> (1:1)
    <field2>bbb</field2> (1:1)
    <b><struc> <u>(1:unbounded)</u>
      <name>myName</name>
      <value>myValue</value>
    </struc></b>
    </rec>
    Destination structure:
    <rec> (1:1)
    <field1>aaa</field1> (1:1)
    <field2>bbb</field2> (1:1)
    <b><field3>bbb</field2> (1:1)</b>
    </rec>
    In order to fill the destination field3 i have to loop over the input-structure struc.
    My problem is, that i don't know how to get access to the name/value pair with a
    extended user-defined function. Since each occurrence in struc i not a simple string but consists of 2 fields, i guess it is not enough simply to loop over input String Array.
    Please help.

    just like u have a loop stmt in java prgm. a simple code:
    Here a and b are the strings that comes to the udf
    for(int i=0;i<a.length;i++)
         boolean found = false;
         int j = 0;
         for(j=0;j<b.length;j++)
              if (a<i>.equals(b[j]))
                   found = true;
                   break;
         if (found == true)
              result.addValue(c[j]);
         else
              result.addValue("");
    Message was edited by:
            Prabhu  S

  • Loops in arrays or structures

    Loops in arrays or structures
    I was given a project on html reports and
    They have advised me to use Loops in arrays or structures
    At this point I am a novice at this html reporting system. I
    would like to know how I can use loops in arrays or structures.
    How is it beneficial are
    1. Structures
    2. Arrays
    3. loops in for both
    for my reports.
    Countless thanks in advance

    Structures are great if you understand them, they are
    basically just arrays organized by keywords rather than index
    numbers.
    Arrays are very nice, as you can just run through loops to
    access each element, as they are all indexed by numbers 0-x.
    loops are great to navigate through both. All you have to do
    is set an loop to run through x amount of iterations of the array
    or structure (where x is the length of the array, or number of
    elements in the structure). Loops are great due to the small amount
    of code they require.

  • Loops and Arrays help

    Hi,
    I'm a freshman in college and new to java. I am completely lost and really need help with a current assignment. Here are the instructions given by my teacher...
    Building on provided code:
    Loops and Arrays
    Tracking Sales
    Files Main.java and Sales.java contain a Java application that prompts for and reads in the sales for each of 5 salespeople in a company. Files Main.java and Sales.java can be found here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Main.java
    and here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Sales.java It then prints out the id and amount of sales for each salesperson and the total sales. Study the code, then compile and run the program to see how it works. Now modify the program as follows:
    1. (1 pts) Compute and print the average sale. (You can compute this directly from the total; no new loop is necessary.)
    2. (2 pts) Find and print the maximum sale. Print both the id of the salesperson with the max sale and the amount of the sale, e.g., "Salesperson 3 had the highest sale with $4500." Note that you don't necessarily need another loop for this; you can get it in the same loop where the values are read and the sum is computed.
    3. (2 pts) Do the same for the minimum sale.
    4. (6 pts) After the list, sum, average, max and min have been printed, ask the user to enter a value. Then print the id of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of salespeople whose sales exceeded the value entered.
    5. (2 pts) The salespeople are objecting to having an id of 0-no one wants that designation. Modify your program so that the ids run from 1-5 instead of 0-4. Do not modify the array-just make the information for salesperson 1 reside in array location 0, and so on.
    6. (8 pts) Instead of always reading in 5 sales amounts, allow the user to provide the number of sales people and then create an array that is just the right size. The program can then proceed as before. You should do this two ways:
    1. at the beginning ask the user (via a prompt) for the number of sales people and then create the new array
    2. you should also allow the user to input this as a program argument (which indicates a new Constructor and hence changes to both Main and Sales). You may want to see some notes.
    7. (4 pts) Create javadocs and an object model for the lab
    You should organize your code so that it is easily readable and provides appropriate methods for appropriate tasks. Generally, variables should have local (method) scope if not needed by multiple methods. If many methods need a variable, it should be an Instance Variable so you do not have to pass it around to methods.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this.
    I'm not asking for someone to do this assignment for me...I'm just hoping there is someone out there patient and kind enough to maybe give me a step by step of what to do or how to get started, because I am completely lost from the beginning of #1 in the instructions.
    Any help would be much appreciated! Thank you!
    Message was edited by:
    Scott_010
    Message was edited by:
    Scott_010

    First ask the person who gave this asignment as to why do you require two classes for this , you can have only the Sales.java class with main method in it . Anyways.
    Let Main.java have a main method which instanciates a public class Sales and calls a method named say readVal() in Sales class.
    In the readVal method of sales class define two arrays i.e ids and sales. Start prompting the user for inputting the id and sales and with user inputting values keep storing it in the respective arrays .. Limit this reading to just 5 i.e only 5 salesPerson.
    Once both the arrays are populated, call another method of Sales class which will be used for all computations and output passing both the arrays.
    In this new method say Compute() , read values from array and keep calculating total,average and whatever you want by adding steps in just this loop. You can do this in readval method too after reading the values but lets keep the calculation part seperate from input.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this. I think this is ur personal stuff , but if you want to use web page , you probably will require to use servlet to read values from the html form passed to the server.

  • How can i loop over treeview selected nodes and then to delete each node if it's a directory or a file ?

    I have this code:
    if (s == "file")
    file = false;
    for (int i = 0; i < treeViewMS1.SelectedNodes.Count; i++)
    DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
    I know it's a file and it is working if it's a single file.
    On the treeView i click on a file right click in the menu i select delete and it's doing the line:
    DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
    And it's working no problems.
    But i want to do that if i selected some files togeather multiple selection then to delete each file.
    So i added the FOR loop but then how do i delete from the SelectedNodes each node ?
    The treeView SelectedNodes dosen't have FullPath like SelectedNode also doing SelectedNodes[i] dosen't have the FullPath property.
    Same as for if i want to delete a single directory or multiple selected directories:
    This is the continue of the code if it"s not a "file" (else) it's null i know it's a directory and doing:
    else
    file = true;
    RemoveDirectoriesRecursive(treeViewMS1.SelectedNode, treeViewMS1.SelectedNode.FullPath);
    Also here i'm using SelectedNode but if i marked multiple directories then i how do i loop over the SelectedNodes and send each SelectedNode to the RemoveDirectoriesRecrusive method ?
    My problem is how to loop over SelectedNode(multiple selection of files/directories) and send each selected file/directory to it's method like i'm doing now ?

    foreach (TreeNode n in treeViewMS1.SelectedNodes)
    // Remove everything associated with TreeNode n here
    I don't think it's any harder than that, is it?
    If you can multi-select both an item and one of its descendents in the tree, then you'll have the situation that you may have deleted the parent folder and all of its children by the time you get around to deleting the descendent.  But that's not such
    a big deal.  A file can get deleted externally to your program too - so you'll just have to deal with it having been deleted already (or externally) when you get around to deleting it yourself.

  • [Solved] Foreach loop that loops over all files in a folder does not consider first file found

    Hello,
    I have a foreach loop in SSIS (as part of Visual Studio 10 and with SQL Server 2012).
    It loops over all files in a folder (ForEach File Enumerator).
    I set the folder: OK
    Traverse Sub folders: OK
    I have set up a Variable in Variable Mappings called FileName so it shows User::FileName: OK
    Index of variable is 0: OK
    It almost works ok. Except that the first file it finds is never considered.
    I set a breakpoint then and the first file it finds, is shown in black in the watch variable window. All subsequent files found are shown in red font. When I change the names of the files so another file is the first file found then it skips the other one
    which now is the first file.
    What is going on here? Why does SSIS skip the first file it finds in a foreach file loop?
    Any suggestions highly appreciated.
    Thank you
    Andi
    Andreas

    "red font - interesting, any example to show us (image)
    It would be interesting to share with us whether you use any file masks or expressions.
    Arthur
    MyBlog
    Twitter
    It appears a variable value turns red when it changes between breakpoints. It started black for the first value (the first file, obtained BEFORE the execution reached the breakpoint), and then turned red. I was able to reproduce this behavior on a test environment.
    However, it did not skip any files.
    OP, please set up the test shown in the image below. Create a breakpoint in the sequence container for the "OnPreExecute" event.

  • Problem with Message-Mapping: Loop over Elements possible?

    Hi all,
    I want do create a Message-Mapping for an IDoc-to-File Scenario. In the Source Structure there are some Elements which can appear more than once (1..unbounded). I need a mechanism which loops over these elements and search for specified values. From the Element which contains an element with this specified value the mapping should write a value in the target structure.
    Here a simple example (source structure) for better understanding:
    <root>
       <invoice>
          <number> 10 </number>
          <sum> 200.00 </sum>
       </invoice>
       <invoice>
          <number> 20 </number>
          <sum> 150.00 </sum>
       </invoice>
       <invoice>
          <number> 30 </number>
          <sum> 120.00 </sum>
       </invoice>
    </root>
    Now the duty of the Mapping should be to search in the elements <invoice> for the number 30. And then the sum of the invoice with the number 30 should be written in a field of the target structure.
    I tried it out with a constant togehter with an equalsS-function and an ifWithoutElse-function, but it is working only then, if the invoice with the number 30 has the first position in the root context.
    Can anybody help me? Thanks
    With kind regards
    Christopher

    Hi,
    Write a UDF to sum the required values and map to target node.
    See while writing the UDF select the type as queue.
    number -- removecontext-UDF targetnode
    sum----removecontext--/
    number abd sum or the two inputs
    in UDF
    int nsum = 0;
    for(int i;i < number.length;i++){
      if number(i).equals("30") then
         nsum = nsum + valueOf(sum(i));
    result.addValue(nsum); // convert the nsum into string
    Regsrds
    Chilla

  • Message-Mapping: nested Loops over Elements

    Hi Experts,
    I have problems with my Message-Mapping in the IR. I have a source and a target structure. In the following I will give you easy examples of these structures:
    <u>source structure:</u>
       <E1EDP01>
          <E1EDP19>
             <QUALF> ... </QUALF>
             <IDTNR> ... </IDTNR>
          </E1EDP19>
          <E1EDP19>
             <QUALF> ... </QUALF>
             <IDTNR> ... </IDTNR>
          </E1EDP19>
       </E1EDP01>
       <E1EDP01>
          <E1EDP19>
             <QUALF> ... </QUALF>
             <IDTNR> ... </IDTNR>
          </E1EDP19>
          <E1EDP19>
             <QUALF> ... </QUALF>
             <IDTNR> ... </IDTNR>
          </E1EDP19>
       </E1EDP01>
    <u>target structure:</u>
    <LineItem>
       <IDTNR></IDTNR>
    </LineItem>
    <LineItem>
       <IDTNR></IDTNR>
    </LineItem>
    That means:
    For every <E1EDP01> in the source structure I create one <LineItem> in the target structure. One E1EDP01-Element can contain more than one E1EDP19-Elements. I have to loop over these E1EDP19-Elements, because I have to locate the Element <QUALF> with a given (fixed) value. The Mapping should put the value from the Element <IDTNR> from the source structure - where the QUALF-Element has this given value - in the IDTNR-Element of the target structure.
    I tried it with a UDF, but only the first <IDTNR> in the target structure got filled.
    Thanks for your help
    Christopher

    Thank you,
    but how I can set the Elements IDTNR and QUALF to the context E1EDP01?
    In the splitByValue-Function do I need "each value"?
    best regards
    Christopher

  • Looping over cfset tag

    Hey Guys,
    I am having a problem with cfloop. What I am trying to do is
    calculate points on an Oline March Madness Pool. I need to evaluate
    if the user picks are equal to the game winners. I can do it if I
    manually type each pick # and each game # but I would much rather
    loop over a cfset tag since there are 63 picks and games. You can
    check out my code below to get a better idea of what I am trying to
    do. While I know I can't include the #'s on the right side of the
    cfset tag in this way I included them anyways to better illustrate
    where I would like to loop it. Is there a way to do this, or will I
    have to manually set each pick?

    <cfif getGames.game#l# EQ
    userPoints[#userID#]["pick#l#"]>
    I'm going to guess this is line 27 or very near it.
    Your actual <cfset> line looks fine to me assuming all
    the relevant keys
    exist when they need to exist. I would have written it
    something like:
    <cfset userPoints[userID]["pick" & i] =
    variables["pick" & i]>
    The if statement should probably look like this:
    <cfif getGames["game" & i] EQ
    userPoints[userID]["pick" & i]>
    All your index variables are the letter "i" and not the
    number "1"
    aren't they? I don't believe a singe number is a valid CF
    variable name.

Maybe you are looking for

  • Can't access weblogic server from internet but can from intranet

    Hopefully this isn't the wrong place to post but I've searched through many many newsgroups to figure out where to post this but can't find a specific enough one. I've recently run into a problem with my weblogic server in that it can not be accessed

  • Adobe Form Print Problem - Header is cut off without print preview

    We are currently experiencing a problem when trying to print Adobe forms.  We have created several forms and are experiencing the same issue with all forms.  The issue occurs when we are trying to print a form.  If we choose a print preview prior to

  • ****FIX **** update to 7.0 - Album Art problem- Disable/ReEnable failed

    I have a 30gb videopod and updated to version 7. I too was experiencing problems with some tracks not showing recently added album art. I tried disabling and re-enabling album art on both my powerbook and xp computer and which lead to no album art wa

  • FCP7 Reconnect Media Issues after upgrading OS

    I've updated a 2009 MAC Pro 2.26 GHz Quad Core Intel Zeon from 10.5.8 to 10.6.8 and eventually want to get to 10.8. (Note - I did not do a clean install.) However, since that update I've had various problems files with MXF and XDCAM files opening or

  • Custom GRC  access control reports

    Hi, Is it possible to have custom reports for access control?  Specifically we are looking at developing reports based on roles and users for compliance calibrator (risk analysis and remidiation).  Thanks.