Count Occurences within in an Array

Hi,
I have an array with numbers, I want to count how often the number 5 is stored in it, does anyone know the syntax?
thanks,
Rich

Hi Jason,
Sorry, I think I am mising something really basic here,
I have an Array created in a subreport declared:
shared numbervar array RespondentArray1;
there is then various code which poulates it depending on which IF conditions are met as it cycles through the records.
In my main report I want to count the occurneces of say the number 5.  But I was expecting to drop the array name only (RespondentArray1) into where you have {@Array}.  But I get an error if I do that. The formula where the array is declared and populates is in a subreport.
Can you please advise of what I should be replacing in your code?
My looping would work, but I dont think it is very efficient especially as I have lots of counts to do on various numbers,
thanks,
Richard.

Similar Messages

  • TestStand crashes when a SequenceCa​ll step that counts failures within a list

    I have TestStand 4.0 and TestStand 4.1 installed on my system, as does everyone else in my department.  I am the only one with a 64bit machine and cannot execute a sequence in 4.0 that I can execute in 4.1.  Everyone else can execute the sequence in both.  The sequence generates a report and TestStand crashes when the sequence reaches a step that performs a sequence call which counts the number of failures within a list (array). 
    We are fresh out of ideas.  Any suggestions would be greatly appreciated.  If more information is needed, please ask.
    Thanks!

    When you say '64-bit machine' do you mean 64-bit Operating System?
    If so, which 64-bit operating system are you using, XP x64 or Vista x64? 
    TestStand 4.0.1f1 is only supported on Windows 2000 and XP x86.
    TestStand 4.1 is supported on Windows 2000, XP x86, Vista x86, and Vista x64.
    If you are trying to use XP x64, we have not tested it, and it is not guaranteed to work in all cases.  If you are using Vista x64, then it is expected that TestStand 4.1 will work, but TestStand 4.0.1f1 was never tested with any version of Vista, and so may not work.
    Josh W.
    Certified TestStand Architect
    Formerly blue

  • Counting occurences

    Hello Experts,
    I have the following query related to counting occurences of a particular characteristic related to the Calendar month
    1) When I choose the option "Average of all values" within exception aggregation for the calculated keyfigure that I am using for the count, it counts all the values including duplicates .i.e. if the charcteristic has repeated occurences for a given month, then it is counted distinct occurence. However, in this case it is not showing me "0" for no occurence but just displaying a blank
    2) But when I choose the option "Counting all values" within exception aggregation for the calculated keyfigure that I am using for the count, it does provides me "0" for no occurences but it counts the repeated value as single occurence
    How can I get around this? I mean to get repeated values to be counted as separate occurences and also being able to show "0" for no occurence.
    Any help will be appreciated
    Thanks,
    Rishi

    Hi ,
    Please use exception aggregation as you already did  with count all values.
    But you need to select a specific reference chars to select the unique count.Plant or the Month can be a option.
    In BI7.0 U have concept of nested aggregation:
    Create a CKF1 with reference to one Char. and craete another CKF2 using the earlier CKF1 and put again a reference on some other char.
    that will solve the problem.
    Please take care of the selection of Char while doing reference char.

  • Converting a single entry within an array into 16 entries within a new array. Building an array without knowing the exact amount of array entries.

    I'm developing a VI that reads a text file and does a manipulation on the data it reads. The VI does the following: First, it reads all the ASCII characters from a text file, converts them to 8-bit words, until EOF occurs. Then I do some simple conversion to each byte. The result is that each bit entry of the byte now gives 2 3-bit entries, making a total of 16 3-bit values returned for each byte within the original array. For example, when I read element #0 of the byte array, I get the byte value of 1011000. My VI then converts this to 16 seperate 3-bit values. I can do the conversion just fine. My pro
    blem is figuring out how to put these 16 elements into an array to be written out of my 6534 card. I know how to do the DIO write part, but the problem is how do I combine the 16 elements into an array for thousands of bytes read from the text file? Also, the size of the file that I read is unknown until it is read, so I may have to output many sucessive outputs as described above. The first element read would give 16 3-bit elements for the new array, the second byte read would give another 16 3-bit elements and so on upto N values in the original array. Any ideas ?

    Place a for loop, wire N with your readed string lenght, pass the string inside and wire it to string subset, with the lenght entry wired to 1 and the offset entry to the loop counter (i). Then, you can play with every character inside the loop, and have an output array composed with the result of every character.
    Hope this helps

  • How to count occurences of a certain string in incoming real-time data? Also displaying RTC data. Current VI included

    I use LabView student Express 7 on a Windows XP system.
    Time-frame: we are doing final integrations for our balloon experiment today. We just got told that the press wants to view real-time data, which we haven't programmed for. I need help to get a working VI at the latest by 25.02.2004 before 0800(morning) (GMT+1).
    Note on license
    It is a student balloon flight, and the data will not be used in scientific work, so the I am not breaking any license agreements (I hope).
    Problem synopsis:
    The balloon continually transmits data at 9600baud. The data is a semi-repeating header followed by a constant lenght data-package arranged like this:
    BEXUS[h][m][s]BEXUS[h][m][s]
    [Raw binary data, 7channels*8sub-channels*8bits]
    What the groundstation is doing right now:
    Take all incomming data and save (append) the data to a file without any data-handling. (We figured we would go post-processing).
    What I need to change in less than 24 hours:
    - Add a "package" counter
    - Add a display of the clock data (RTC)
    How I planned to implement the changes:
    -RTC display:
    The RTC data is in BCD format, since that means that if you look at the data as hex numbers, you get the hours and minutes and seconds out in "clear text". That is 12 hours is 0x12hex. I figured that I can do a match pattern BEXUS and pass the "after substring" to another match pattern BEXUS from which I feed the "before substring" to a type-cast VI (casting string to u8) and displaying that, which should give me a display of "123000" for the time 12:30:00... I couldn't get it to work at all when I tried out the supplied "beta" vi.
    - Package counter:
    Counting how many BEXUS that gets detected and dividing by 2. I don't know how to do this. I've looked on the forum (a good thread on the problem: "how do I count the number of *'s in a string") but these use either loops or arrays... and I'm not sure how this works when I'm getting the data in at realtime. I cant make an array and then count it, since then the array would grow fast and possibly interfere with saving of the data??? Saving the data is critical.. without that file we cant do post-processing.
    Since my time is so limited (I'm not even supposed to do the groundstation software but they called on me in the last minute because no-one else had time/wanted too/could do it) I hope that you could make an exception and provide me with working VI's (based on the one I have attached) so that I can show something to the press! (Free comercial for NI!! Since the student version shows the National Instruments water-mark on all VI's!!! Possible TV time!!)
    Thanks!
    PS: even if you are to late (after 25) post anyway!
    Why:
    -I can learn from it
    -the launch might be delayed due to weather conditions
    -others might find it amusing!
    Thanks again!
    Attachments:
    BexusII_groundstation.vi ‏46 KB

    I have a valid example data file attached to this thread.
    If you open BEXTEST.bin in a hex-editor of your choice, you'll see the BEXUS as 42 45 58 55 53 and then the time as 00 28 09 etc.
    I couldn't get Joe Guo's VI to work. It doesn't count packages correctly, and the time is not displayed correctly either.
    The file was saved using a straight save to file VI.
    The data is from actual launching area tests performed a few mintues ago. The time displayed is "On time" e.g. how long the gondola has been powered up.
    I have a spare T-junction, so I can hook into the balloon real-time data as we fly, in case anyone care to see if they can figure out why the latest version of Joe Guo's program is not displaying correctly.
    I will monitor this
    thread during and after flight to see if anyone can make it in time!
    Thanks for the great effort!!
    Attachments:
    bextest.bin ‏53 KB

  • How do you change the colors of individual cells within a 2D array?

    How do you change the colors of individual cells within a 2D array of numeric indicators?
    I want the VI to check a data value and if it is failing, white out a square at a specific index coordinate.  I have it working with color boxes, but I'm not sure how to use the property node function, to change the color of individual cells, by coordinates.
    I have attached the VI using color boxes. If you run the VI, the box corresponding to the Step control should turn white.
    I want to do the same thing, using numeric indicator boxes inside the array.
    Thanks for any suggestions...
    Attachments:
    Fill DME matrix.vi ‏95 KB

    Get rid of all these sequences! That's just bad form.
    Your code has a few logical problems. Why do you create a boolean array if you later only look at the last element (Yes, the FOR loop does nothing useful, except in the last iteration because your outputs are not indexing. All other iterations are useless, you only get the result of the last array element. My guess is that you want to color the index white if at least one of the numbers is out if range. Right?
    It is an absolute nightmare to manage all your numeric labels. Just read them from a 2D array. Now you can simply find the index of the matched elements and don't have to spend hours editing case structure conditions.
    Attached is a simple example how you would do what I meant (LV7.1). Modify as needed.
    Message Edited by altenbach on 04-04-2006 02:04 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Fill_2DME_matrixMOD.vi ‏70 KB

  • Counting occurences of a string (in a cell)

    This is a little like the topic "Counting occurences of a word," except I want to be able to count how many times a specified search string occurs in a cell, not count how many cells contain the string. I would also like a formula that gave the offset of the starting character of the search string into the cell, such that a zero signified that the search string did not occur.
    Basically, I want a general set of tools to parse a cell's string data, enabling me to determine where in the cell's string data each occurrence of another string is located & to extract parts of the string data relative to where the search string occurs.
    For example, if the cell contains the string, "1ab2cd2e" I want to be able to extract "cd" & "e" based on the characteristic that they follow "2."

    Here it is:
    --(SCRIPT decoupeur.app]
    Save the script as a Script, an Application or an Application Bundle named decoupeur
    Put the file in the folder
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    To use it,
    Select the group of cells to convert
    Copy to the clipboard
    Select the destination cell
    Goto Scripts > Numbers > decoupeur
    You will be asked to define the separator to use.
    Given the separator "2", the strings of the kind "1zer6sd2az2rt8aa2er7kkk5uu2a"
    would be parsed and return az TAB rt TAB er TAB a
    The converted values will be pasted at the cursor.
    Yvan KOENIG 30juin 2008
    property theApp : "Numbers"
    property menuFenetre : 10
    property premierNom : 6
    property nomDuDocActif : ""
    property theDelim : ""
    property listeLignes : {}
    property listeTemp : {}
    property msg90 : ""
    property msg91 : ""
    property msg92 : ""
    --=============
    on run
    tell application "System Events" to if not (UI elements enabled) then set (UI elements enabled) to true (*
    Active le GUI scripting
    • Enable GUI scripting *)
    my nettoie()
    my controleVersion()
    set nomDuDocActif to my getFrontDoc()
    if nomDuDocActif = "" then return
    my prepareMessages()
    try
    set txtDatas to the clipboard as Unicode text
    on error (*
    The clipboard was empty *)
    return
    end try
    set my listeLignes to every paragraph of txtDatas
    set srcNbRows to count of my listeLignes
    if txtDatas contains tab then (*
    several columns *)
    error "Can't treat several columns" number 8001
    else (*
    single column *)
    tell application theApp
    set choix to choose from list {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} with prompt msg90 default items {"2"} OK button name msg91 cancel button name msg92
    end tell
    if choix is false then error -128
    set theDelim to item 1 of choix
    repeat with i from 1 to srcNbRows
    if item i of my listeLignes is not "" then set item i of my listeLignes to my decipher(item i of my listeLignes)
    end repeat
    end if
    set the clipboard to my recolle(listeLignes, return)
    my pasteIt()
    my nettoie()
    end run
    --=============
    on pasteIt()
    tell application theApp to activate
    tell application "System Events" to tell (first process whose title is theApp)
    click menu item nomDuDocActif of menu 1 of menu bar item menuFenetre of menu bar 1
    keystroke "v" using {command down}
    end tell
    end pasteIt
    --=============
    on decoupeur(n)
    local d, ms, m
    set d to n div 1
    set ms to (n - d) * 60
    set m to round (ms)
    return (d as text) & "°" & m & "’" & (round ((ms - m) * 60)) & "”"
    end decoupeur
    --=============
    on decipher(source)
    local i, itm, shortimem, j
    set my listeTemp to my decoupe(source, theDelim)
    set my listeTemp to items 2 thru -1 of my listeTemp
    repeat with i from 1 to count of my listeTemp
    set itm to item i of my listeTemp
    set shortItem to ""
    repeat with j from 1 to length of itm
    if character j of itm is not in "1234567890" then
    set shortItem to shortItem & character j of itm
    else
    exit repeat
    end if
    end repeat
    set item i of my listeTemp to shortItem
    end repeat
    return my recolle(my listeTemp, tab)
    end decipher
    --=============
    on getMinutesSeconds(t, d)
    local ll
    set ll to my decoupe(t, d)
    return {(item 1 of ll) as integer, (item 2 of ll) as text}
    end getMinutesSeconds
    --=============
    on decoupe(t, d)
    local l
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to ""
    return l
    end decoupe
    --=============
    on recolle(l, d)
    local t
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to ""
    return t
    end recolle
    --=============
    on nettoie()
    set AppleScript's text item delimiters to ""
    set my listeLignes to {}
    set my listeTemp to {}
    set nomDuDocActif to ""
    end nettoie
    --=============
    Get the name of the active document
    on getFrontDoc()
    local nw, mm
    tell application theApp to activate
    tell application "System Events" to tell (first process whose title is theApp)
    set nw to name of every menu item of menu 1 of menu bar item menuFenetre of menu bar 1
    if (count of nw) < premierNom then
    set mm to ""
    else
    repeat with i from premierNom to count of nw
    set mm to item i of nw
    if (value of attribute "AXMenuItemMarkChar" of menu item mm of menu 1 of menu bar item menuFenetre of menu bar 1) is not in {"", "•"} then exit repeat
    end repeat
    end if -- (count of nw)…
    end tell
    return mm
    end getFrontDoc
    --=============
    on controleVersion()
    local v
    try
    set v to version of application theApp
    set menuFenetre to 10 (* index of the Windows menu *)
    set premierNom to 6 (* index of the first docName in the list of menu names
    The list contains one more item than the displayed menu *)
    on error (*
    • We are here if Numbers ignores the instruction get version *)
    tell application "System Events" to set v to get version of (get (application file of (get first process whose title is theApp)))
    if v starts with "1" then
    set menuFenetre to 10
    set premierNom to 6
    else (* ready for a Numbers v2 ignoring AppleScript *)
    set menuFenetre to 10
    set premierNom to 6
    end if
    end try
    end controleVersion
    --=============
    on parleAnglais()
    local z
    try
    tell application theApp to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z = "Cancel")
    end parleAnglais
    --=============
    on prepareMessages()
    if my parleAnglais() is false then
    set msg90 to "Choisir le séparateur"
    set msg91 to " OK "
    set msg92 to "Annuler"
    else
    set msg90 to "Choose a separator"
    set msg91 to " OK "
    set msg92 to "Cancel"
    end if
    end prepareMessages
    --=============
    --[/SCRIPT]
    Yvan KOENIG (from FRANCE lundi 30 juin 2008 11:16:52)

  • Counting occurence in image

    I don't know nothing about NI image DAQ, I'm new to this, I'm a Labwindows/CVI programmer and recently a client asked me if its possible to count cells occurences in an image. Before investing money in such system (seems to be very expensive) I would like to know if NI VISION functions are powerfull enough to count occurences of a human cell in an image ?
    Thank you,

    The short answer to your question is yes and there are similar examples on the IMAQ Vision demonstration CD. I would suggest you try and organize a demo from your local NI office.
    Application Note 107 gives a good tutorial on this topic and you can get access to it at the following link:
    http://zone.ni.com/devzone/conceptd.nsf/webmain/1D977AE5ED42CB0C86256869007215CC?opendocument&node=DZ52495_US
    As far as support for LabWindows/CVI is concerned, you may see a lot more "traffic" regarding LabVIEW on Developer Zone, but rest assured the capability of the CVI version of IMAQ Vision is virtually identical and there should be enough help either direct from NI or through Developer Zone to help with your application.
    With regards to questions about cost, t
    he cost of the application will have to be considered versus the benefits of introducing an autonomous inspection system. Your customer may find that the increases in throughput i.e. number of samples/images per hour that can be inspected or the reliability of the results produced (most people will strive towards a 100% inspection imaging application) will offset the initial development costs. This is particularly true if your customer is currently manually inspecting the samples (for example under a microscope).
    Jeremy

  • Arrays - counting occurence

    Hello everyone :)
    A practical at college is requiring me to create a program that simulates throwing 3 dice a total of 5000 times and for it to tally the number of times that all possible answers have occurred. For example, with 3 dice the lowest you can get is 3 (three 1's) and highest, 18 (three 6's). Roll the three dice, see which of the 16 different outcomes (3-18) you have, and add 1 to the total number of occurrences that outcome has produced. After 5000 throws, I will need to see which outcome happened most often. I've been told I must use an array for counting the occurrences and it's the array part which is confusing me.
    Implementing the 3 dice and a method that simulates them being thrown was easy but I just do not have a clue how to:
    1) get it to be done 5000 times and
    2) the outcomes be tallied
    Heres the code I have so far..
    import java.lang.Math;
    public class ThreeDice
        public static int throwDie()
                double x = Math.random();
                double x2 = Math.random();
                double x3 = Math.random();
                x = (x * 6.0) + 1.0;
                x2 = (x2 * 6.0) +1.0;
                x3 = (x3 * 6.0) +1.0;
                int dice1 = (int)Math.floor(x);
                int dice2 = (int)Math.floor(x2);
                int dice3 = (int)Math.floor(x3);
                return dice1 + dice2 + dice3;
        public static void main(String args[])
        }the throwDie method has to be used in main method but I'm stuck as for what to do next I'm afraid.

    Hello Looce and thank you for the welcome,
    Using my (very limited) knowledge I've managed to get the first part done (roll the 3 dice 5000 times) and for now I've just set it to print all 5000 results and alas it indeed prints 5000 results.
    The second part though I'm still stuck on, I was hoping google would be my savior but sadly not this time.
    I should have probably said in my first post that I'm a complete beginner for Java but with it being used both this year and next year for college, I hope to be fairly skilled in the use of it one day :)
    An update of the code:
    import java.lang.Math;
    public class ThreeDice
        public static int throwDie()
                double x = Math.random();
                double x2 = Math.random();
                double x3 = Math.random();
                x = (x * 6.0) + 1.0;
                x2 = (x2 * 6.0) +1.0;
                x3 = (x3 * 6.0) +1.0;
                int dice1 = (int)Math.floor(x);
                int dice2 = (int)Math.floor(x2);
                int dice3 = (int)Math.floor(x3);
                return dice1 + dice2 + dice3;
        public static void main(String args[])
                for(int i=0; i<5000; i++){
                    System.out.println(throwDie());
        }

  • Counting peaks within one minute intervals and outputting with time stamp

    I'm currently working on my senior design project for biomedical engineering. We are creating a piezoelectric sensor in order to measure respiration on a bed non-invasively. The sensor lays on bed under subject and records movement due to respiration. We currently have figured out how to detect peaks. However, now we want to count number of peaks detected within a 1 min time period and output that result with a 'timestamp'. We would like the output to be into excel as two columns, rate(number peaks in 1 min) and time. Time in minutes and not actual time is fine. Sampling rate was 500Hz.
    My current VI has peak detection criteria and can output total number of peaks and their locations.
    Any help would be greatly appreciated as this is our last step before verification and have been stuck on it for awhile. 
    It won't allow me to attach a tdms file in which our data is stored as, so I can't upload the data currently.
    Also attached is our current VI for peak detection labeled 3.26.Resp.PeakDetect.
    Thanks for any and all help!!
    Attachments:
    3.26.Resp.PeakDetect.vi ‏146 KB

    I see no need for a case structure.  Or did you set up a state machine that I missed?
    I recommend making a VI that does nothing but read your 30,000 samples and process it (counting the peaks and what not).  From there, you create the array for the number of peaks and the time (in minutes).  Then you can call that VI inside of a loop to build up the array of data points.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How do I count numbers within a specific range in a column?

    I'm creating a spreadsheet for my college courses where I enter each score from each class as I get them back and it continues to recalculate my grades in each course.  Now I'm on the part where I want to make a box that calculates the current GPA for the semester.  I know how I'm going to do it already but I need to figure one thing out first.  Say my scores are as follows:
    85.50%
    82.00%
    92.35%
    94.25%
    78.00%
    I need a working code that counts the amount of scores within a certain range, say for example, tell me how many scores are between 80.00 and 89.99.  I can figure out how many are above/below a certain value (80.00 again for example) with a code like this [scores being the column with the grades]:
    =COUNTIF(Scores,">=80.00") ---- this gives me "4" correctly
    BUT when I add another value and want it to limit scores to not just being equal to/above 80.00 but also below 90.00 it freaks out.  I tried the two following codes:
    =COUNTIF(Scores,">=80.00","<90.00")
    =COUNTIF(Scores,">=80.00",Scores,"<90.00")
    Neither work, i'm sure i'm just wording it wrong.  It should obviously spit out the number "2" with there being two B's.  Any help would be appreciated!

    Jeremy.Osborne wrote:
    I have set up a chart just like yours with the intervals (60-100) on the left and on the right I have no idea what to do.  Do I enter that code into each box? Right now it looks like:
    =INDEX(FREQUENCY(Scores, I have no idea what to put here)
    Jeremy,
    in my response, I gave you the expression I used to build the frequency table. It was:
    =INDEX(FREQUENCY(Data :: A,A),ROW()-1)
    If you build a document exactly as the one I illustrated, the same expression will work for you. If you use a different table name, you will have to adjust the reference.
    Regarding the COUNTIFS function, you must read carefully the syntax defined in the Function Browser or the Formulas and Functions user guide and follow it to the letter.
    Jerry

  • How do you count the position in an array?

    Label the elements in a 2D array by counting left to right across each row, and starting with the top row, working your way down. For the example above, we'd label each element like so:
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    16 17 18 19
    Such labels give the position in the linearized array (so called because we can store them in a one-dimensional array now). (We did this secretely when we constructed deck out of suit and rank. Check out pages 91�92 if you need to refresh your memory.)
    Come up with a way to calculate the row of an element in the two-dimensional array given its linearized position. For example, the row of element 6 is 1. Also devise a way to calculate the column of a element in the two-dimensional array given its position in the linearized array. For example, the column of element 6 is 2. (Remember, we start counting at zero.) Explain how you arrived at your answer.
    There is no code needed for this, and my question is how should I start this? I am not sure how to track down a value in a two dimensional array... can anyone help?

    Java arrays can be "ragged". Assuming the outer array represents rows and the inner array represents columns, the inner arrays that define the columns can be of different length. In your example you could have
    0 1 2
    3 4 5 6 7 8
    9 10 11 12 13 14
    15
    16 17 18 19
    So. unless you can specify that the column arrays will all be the same size, you'll have to have some way of determining the array size before it can be use in any calculation. You will find <anArray>length useful.

  • Counter variable within EL expression

    Hello,
    I want to set the value of a h:inputText by EL, consider the following example:
    <h:inputText id="field1" value="#{handlers.data[1]}"/>The property 'data' is an object array.
    Since I have many inputText tags I would like to generate them within a while loop. Thus, the above number '1' must be replaced by a variable (i++).
    Does anybody know how to print the value of a variable within an EL expression? <%= i++ %> does not work.

    I tried the c:forEach tag, but without success.
    Consider the following example:
    <c:forEach items="#{handler.myCollection}" var="it" varStatus="idx">
      <h:outputLabel for="field #{idx.index}" value="Field1" rendered="#{handler.labels >= #{idx.index}}"/>
      <h:inputText id="field #{idx.index}" value="#{handler.anotherCollection[#{idx.index}].fieldname}"/>
    </c:forEach>

  • Count layers within precomposed layer

    Hello dear scripters.
    I'm trying to count the layers within a precomposed layer.
    has somebody a solution for my problem?
    Thnx a lot.
    :F
    This is my code:
    var curComp = app.project.activeItem; // this is my acive comp
    var theSelection = curComp.selectedLayers; // i selected some comps
    var compLayer = theSelection[0]; // compLayer is also a comp
    // and here is my problem
    // this doesn't return the number of layers within my compLayer
    var theNumber = parseInt(compLayer.numLayers);
    alert(theNumber); // returns undefined but i need an integer

    Great. That works.
    Thnx again for your help Dan.
    :F
    Here is the working code.
    It takes a selection of comps in the active comp.
    Enables timeremapping.
    Adds a null as controller with some sliders.
    And adds an expression to the timeremapping
    this just works with CompItems.
    It is usefull if the layers in the comps are sequenced with one frame length
    // written by fabiantheblind
    // http://www.the-moron.net
    // with a hint by Dan E.
    // http://forums.adobe.com/message/3310628#3310628
    applyExpression ();
    function applyExpression(){
        // begin an Undo group
        app.beginUndoGroup("apply Expressions");
        // check if a comp is active
            var curComp = app.project.activeItem;
        if (!curComp || !(curComp instanceof CompItem))
            alert("Please select a Composition.");
            return;
        // get the selection
        var theSelection = curComp.selectedLayers;
        // you could use this for a null within the workarea
        //var theController = curComp.addNull(curComp.workAreaDuration);
        // add a null object to the comp for the slider controls
        var theController = curComp.layers.addNull();
        // make a unique name for the null. dont use the date its just a reminder
        theController.name =  prompt("Enter an unique name for the controller Null Object", "control_"+ Date().toString());
        // loop thru selection
        for (var layerId = 0; layerId < theSelection.length; layerId++)
            var layer = theSelection[layerId];
            // get the number of layers within the layer
            // -1 because
            // layers start at index 1 frames start at 0 Frames
            // Thnx Dan for the word ".source."
            var theNumber = parseInt(layer.source.numLayers -1);
            // add a slider control to the null obj.
            var theSliderEffect = theController("ADBE Effect Parade").addProperty("ADBE Slider Control");
            // change the name of the slider to something usefull
            theSliderEffect.name = layer.name + "_cntrl_" + layerId;
            // this is for the timeremapping to make em all hold keyframes
            var holdInt = KeyframeInterpolationType.HOLD;
            // get the timeremapping property and enable it
            var property = layer.property("ADBE Time Remapping");
                  layer.timeRemapEnabled = true;
                // set all keyframes to hold
          for (var i = 1; i <= property.numKeys; i++){
            property.setInterpolationTypeAtKey(i, holdInt, holdInt);
            // remove the last keyframe. dont need it
            property.removeKey(property.numKeys);
            // check if the property can take expressions
            // dont need it. but i need more checking
            if (!property.canSetExpression) { continue }
            // apply the expression with
            //the name of the slider
            // the name of the control null
            // and the number of layers within the comps
            property.expression = exprString(theSliderEffect.name, theController.name, theNumber);
        app.endUndoGroup();
    // this function builds the expression string
    function exprString(inEffName, inControllerName,inNum){
        // the name of the effect
        var theEffName =  inEffName;
        // the name of the control null obj
        var theCntrlName = inControllerName;
        // the number of layers within the timeremapped comps
        var theNumber = inNum;
        // the expr will be something like this: !!watch out german expression!! (replace "Schieberegler" with "Slider Control"):
        // this expression remaps the frame number within the comp to values from the slider
        // val = Math.floor(thisComp.layer("control").effect("MovementControl")("Schieberegler"))*thisComp .frameDuration;
        //if (Math.floor(thisComp.layer("control").effect("MovementControl")("Schieberegler")) < 0){val =0;
        //}if (Math.floor(thisComp.layer("control").effect("MovementControl")("Schieberegler")) > 3){val =3* thisComp.frameDuration;
        // build the string with the variables from the selection
        var theString = "val = Math.floor(thisComp.layer(\"" + theCntrlName + "\").effect(\"" + theEffName +"\")(\"Schieberegler\"))*thisComp.frameDuration;\n"+
        " if (Math.floor(thisComp.layer(\"" + theCntrlName + "\").effect(\""+ theEffName +"\")(\"Schieberegler\")) < 0){val =0;\n"+
        " }if (Math.floor(thisComp.layer(\"" + theCntrlName + "\").effect(\""+ theEffName +"\")(\"Schieberegler\")) > "+theNumber+"){val ="+theNumber+"* thisComp.frameDuration;\n }" ;
        // and return the string
        return theString;

  • Counting words within a file, please help!

    Hi i have written a program to read in a directories from inside another directory. I then want to count the files inside each of these directories.
    import java.util.*;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import java.io.*;
    import java.nio.CharBuffer;
    import java.nio.MappedByteBuffer;
    import java.nio.channels.FileChannel;
    import java.nio.charset.Charset;
    import java.nio.charset.CharsetDecoder;
    public class CalculateMax {
              static int indentLevel = -1;
              static void ReadIn(File path) {
                List alist = new ArrayList();
                int count = 0;
                File files[];
                //keep track of directory level
                indentLevel++;
                files = path.listFiles();
                for (int i=0, n=files.length; i < n; i++) {
                  for (int indent=0; indent < indentLevel; indent++) {
                  System.out.println( files);
         try
         FileInputStream in1 = new FileInputStream(files[i]);
         FileChannel channel1 = in1.getChannel();
         int LengthOfFile1 = (int)channel1.size();
         MappedByteBuffer buffer1 = channel1.map(FileChannel.MapMode.READ_ONLY , 0, LengthOfFile1);
         Charset charset = Charset.forName("US-ASCII");
         //Transform the sequence of bytes in charset into Unicode characters.
         CharsetDecoder decoder = charset.newDecoder();
         CharBuffer charBuffer1 = decoder.decode(buffer1);
         Pattern endLine = Pattern.compile (".*$", Pattern.MULTILINE);
         Pattern wBreak = Pattern.compile ("[\\p{Digit}\\p{Punct}\\s]");
         Matcher matchLine1 = endLine.matcher(charBuffer1);
         while( matchLine1.find()) {
         CharSequence line1 = matchLine1.group();
         //Get the words in the line
         String words[] = wBreak.split(line1);
         for (int j = 0, k = words.length; j < k; j++) {
         if(words[j].length() > 0) {
         alist.add (words[j]);
         count++;
         catch(IOException ioe)
         System.err.println ("read error: " + ioe.getMessage());
    System.out.println("count : " + count);
         if (files[i].isDirectory()) {
         ReadIn(files[i]);
         indentLevel--;
         public static void main (String args[]) {
              ReadIn(new File("Data\\amy.smith\\"));
    The problem is that it seems to keeps reading in each inner directory as one files, so that the words in of every file in each directory are being added together instead of counting each seperately. Does anybody know where i am going wrong here? Any help would be greatly appreciated
    Thanks!

    Thanks! Im just after discovering a big problem with this method of reading the files however. I calling a method on each file i read in which returns an int value, what i need to then do is add together the ints within each directory, so for say:
    Data//amy.smith//file1.txt = 1
    Data//amy.smith//file2.txt = 5
    Data//amy.smith//file3.txt = 9
    it should return 15, but within the loop where the int value is returned i cannot find a way to add together only the ints within the same directory
    static void ReadDir(File path) {
                    int totals = 0;
                   int common = 0;
                File files[]; 
                indentLevel++;
                files = path.listFiles();
                for (int i=0, n=files.length; i < n; i++) {
                  for (int indent=0; indent < indentLevel; indent++) {
                   common = (findCommonWords(firstFile(),readFile(files)));
         words = totals(common, totalF1(), totalF2(files[i])));
         //add words together here for the files in each directory
         if (files[i].isDirectory()) {
         ReadDir(files[i]);
         indentLevel--; // and going up
         //System.out.println(list1);
    Does anybody know how i could do this. I would greatly appreciate any help
    Thanks

Maybe you are looking for

  • ITunes will not open AND iTunes.exe will not LEAVE Task Manager

    Hello, I am also having the same issue with everyone else in that iTunes will not open. This happened to me about two weeks ago and I uninstalled and reinstalled the version that came with my iPod. I figured that after a couple of weeks Apple would h

  • New Hard Disc Drive for HP Pavilion dv6 because of 303 and 305 error messages

    Hello My laptop was getting slower and slower so I did a default restore via the recovery partition and when it rebooted to start the reformat and reinstall to factory condition I got a message on the screen telling me to run the hard disc drive test

  • Can we work with 2 ledgers in B1?

    Dear experts, I am using SAP Business one 8.8 and I want to know is there any way in which I can work with 2 ledgers? One is normal general ledger through which reports are made Balance sheet, P/L statement and cash flow statement where as other ledg

  • Java preferences.app

    I installed the recent Java preferences app yesterday, but it crashes. What's happening? Now it's impossible to set any preferences. Can I simply remove this set of three apps (Input Method Hotkey, Java Preferences and Jave Web Start)? They seem to b

  • Rule to be determined from Responsibility

    Hi, I know the responsibility number, I need to know in which rule it falls. How do I get this?