Count the number of carriage returns in a multiline text box

Hello,
I have a script to count the number of carriage returns at the end of each line of text in a multiline text box.
After running the script in the console, the result keeps showing as 0.
Can anyone please advise how the script can be revised to count the number of carriage returns?
var count = 0;
for (var i = 0;  i < this.getField; i++)
var f = this.getField("ActionAgenda");
if (f.value =="\u000d") count++
console.println("There are a total of "+ count + " carriage returns.");
Any assistance will be most appreciated.

Try this:
var count = 0;
var s = getField("ActionAgenda").valueAsString;
for (var i = 0; i < s.length; i++) {
    if (s[i] === "\r") count += 1;
console.println("There are a total of "+ count + " carriage returns.");

Similar Messages

  • How do I count the number of records returned in the CMIS query

    How do I count the number of records returned in the query CMIS?
    SELECT COUNT(*) FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition = \'RD_PROJETOS_EXCLUSIVOS\''}
    Euler Homero

    Hi Euler,
    interestingly enough, the reference guide for CMIS ( http://wiki.alfresco.com/wiki/CMIS_Query_Language ) that I found does not mention the COUNT function at all. On the other hand it states that: "The SELECT clause identifies which virtual columns to return in the result set. It can be either a comma-separated list of one or more queryNames of properties that are defined by queryable object types or * for all virtual columns."
    There are, however, some other posts like e.g. http://alfrescoshare.wordpress.com/2010/01/20/count-the-total-number-of-documents-in-alfresco-using-sql/ which state that they could make it working.
    Having asked in the WebCenter Portal forum, I assume that your content repository is WebCenter Content. The CMIS doc for the Content is available here: http://docs.oracle.com/cd/E23943_01/doc.1111/e15813.pdf (no COUNT there either). It does, however, mention explicitly that "CMIS queries return a Result Set where each Entry object will contain only the properties that were specified in the query.". This means your could rather investigate the Result Set. Note that there are also other means than CMIS how to get the requested result set (e.g. calling a search service directly via so-called RIDC).
    In the given context I am also interested what your use case is. OOTB CMIS in WebCenter Portal is used, for instance, in Content Presenter, where it is content rather than "parameters" what's displayed.

  • Count the number of columns return in an user-input sql query

    I need to do something like this
    I let an user input a sql query and then execute it
    assuming the sql query is always correct, it will return a Resultset
    then a table will pop up to accomodate the number of columns the resultset will produce
    i'm stuck at the part on how to check how many columns of data will be return in the resultset

         ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
         ResultSetMetaData rsmd = rs.getMetaData();
         int numberOfColumns = rsmd.getColumnCount();

  • A quick way to count the number of  newlines '/n' in string of 200 chars

    I am trying to establish the number of lines that a string will generate.
    I can do this by counting the number of '/n' in the string. However my brute force method (shown below) is very slow.
    Normally this would not be a problem on a 2800mhz Athlon (Standard) PC this takes < 1 second. However this code resides within a speed critical loop (not shown). The code shown below is a Achilles heal as far as the performance of this speed critical loop goes.
    Can anyone suggest a faster way to count the number of �/n� (new lines) within a text string of around 50- 1000 chars, given that there may be 10 � 100 newline chars. Speed is a very important factor for this part of my program.
    Thanks in advance
    Andrew.
        int lineCount =0;
        String txt = this.getText();
        //loop throught text and count the carridge returns
        for (int i = 0; i < txt.length(); i++)
          char ch = txt.charAt(i);
          if (ch == '\n')
           lineCount ++;
        }//end forMessage was edited by:
    scottie_uk
    Message was edited by:
    scottie_uk

    Well, here is a C version. On my computer the Java version (reply 9 above) is slightly faster than C. YMMV. For stuff like this a compiler can be hard to beat even with assembler, as you need to do manual loop unrolling and method inlining which turn assembly into a maintenance nightmare.
    // gcc -O6 -fomit-frame-pointer -funroll-loops -finline -o newlines.exe newlines.c
    #include <stdio.h>
    #include <string.h>
    #if defined(__GNUC__) || defined(__unix__)
    #include <time.h>
    #include <sys/time.h>
    #else
    #include <windows.h>
    #endif
    #if defined(__GNUC__) || defined(__unix__)
    typedef struct timeval TIMESTAMP;
    void currentTime(struct timeval *time)
        gettimeofday(time, NULL);
    int milliseconds(struct timeval *start, struct timeval *end)
        int usec = (end->tv_sec - start->tv_sec) * 1000000 +
         end->tv_usec - start->tv_usec;
        return (usec + 500) / 1000;
    #else
    typedef FILETIME TIMESTAMP;
    void currentTime(FILETIME *time)
        GetSystemTimeAsFileTime(time);
    int milliseconds(FILETIME *start, FILETIME *end)
        int usec = (end->dwHighDateTime - start->dwHighDateTime) * 1000000L +
         end->dwLowDateTime - start->dwLowDateTime;
        return (usec + 500) / 1000;
    #endif
    static int count(register char *txt)
        register int count = 0;
        register int c;
        while (c = *txt++)
         if (c == '\n')
             count++;
        return count;
    static void doit(char *str)
        TIMESTAMP start, end;
        long time;
        register int n;
        int total = 0;
        currentTime(&start);
        for (n = 0; n < 1000000; n++)
         total += count(str);
        currentTime(&end);
        time = milliseconds(&start, &end);
        total *= 4;
        printf("time %ld, total %d\n", time, total);
        fflush(stdout);
    int main(int argc, char **argv)
        char buf[1024];
        int n;
        for (n = 0; n < 256 / 4; n++)
         strcat(buf, "abc\n");
        for (n = 0; n < 5; n++)
         doit(buf);
    }

  • Programatically count the number of files in a folder

    Hi Folks
    I need to programatically count the number of files in a given folder and return the value to a Program Unit to be included in further processing.
    Can anyone point me in the right direction. I have looked at UTL_FILE but this does not offer what I want.
    Does anyone know of an obscure package in Oracle that I could use?
    I'm using 9i in a W2K environment.
    Many thanks
    Simon Gadd

    Hi,
    following a java based solution i found somewhere on Tom Kyte's AskTom forum.
    GRANT JAVAUSERPRIV to TESTUSER;
    dbms_java.grant_permission( 'TESTUSER', 'SYS:java.io.FilePermission', 'c:\', 'read' );
    create global temporary table DIR_LIST
    ( filename varchar2(255) )
    on commit delete rows
    create or replace and compile java source named "DirList"
    as
      import java.io.*;
      import java.sql.*;
      public class DirList
        public static void getList(String directory)
                           throws SQLException
          File path = new File( directory );
          String[] list = path.list();
          String element;
          for(int i = 0; i < list.length; i++)
              element = list;
    #sql { INSERT INTO DIR_LIST (FILENAME)
    VALUES (:element) };
    create or replace procedure get_dir_list( p_directory in varchar2 )
    as language java
    name 'DirList.getList( java.lang.String )';
    exec get_dir_list( 'c:\temp' );
    select count(*) from dir_list;

  • How do I count the number of *'s in a string?

    I need to count the number of * in a string of carakters. And the return the number. 0 for no *'s in the string 2 for two *'s in the string and so on.
    It's probably quite simple but I can't figure out how!

    Like this.
    james_t_dk wrote in message
    news:[email protected]..
    > I need to count the number of * in a string of carakters. And the
    > return the number. 0 for no *'s in the string 2 for two *'s in the
    > string and so on.
    >
    > It's probably quite simple but I can't figure out how!
    [Attachment Untitled 10.vi, see below]
    Attachments:
    Untitled_10.vi ‏18 KB

  • VB 2012 - Help Finding Specific Numbers in a Database Column and Count the Number of Times They Appear.

    Hello,
    I am doing a project that uses MS Access to access data about a baseball team . The MS Access Database provides the names, addresses, and age of the players. All the players are 12, 13, or 14 years old. I need to display the average age for the team on a
    label, which was easy. The problem is that I also have to display the number of players who are 12, 13, and 14 years old and I have no idea how to do that.
    Here is my code so far:
    Public Class frmBaseball
    Private Sub TeamBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TeamBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.TeamBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.LittleLeagueDataSet)
    End Sub
    Private Sub frmBaseball_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'LittleLeagueDataSet.Team' table. You can move, or remove it, as needed.
    Me.TeamTableAdapter.Fill(Me.LittleLeagueDataSet.Team)
    End Sub
    Private Sub btnAges_Click(sender As Object, e As EventArgs) Handles btnAges.Click
    Dim strSql As String = "SELECT * FROM Team"
    Dim strPath As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" & "Data Source=e:\LittleLeague.accdb"
    Dim odaTeam As New OleDb.OleDbDataAdapter(strSql, strPath)
    Dim datAge As New DataTable
    Dim intCount As Integer = 0
    Dim intTotalAge As Integer
    Dim decAverageAge As Decimal
    odaTeam.Fill(datAge)
    odaTeam.Dispose()
    For intCount = 0 To datAge.Rows.Count - 1
    intTotalAge += Convert.ToInt32(datAge.Rows(intCount)("Age"))
    decAverageAge = Convert.ToDecimal(intTotalAge / datAge.Rows.Count)
    Next
    lblAverage.Visible = True
    lblAverage.Text = "The average age of the team is " & decAverageAge.ToString("N2")
    lbl12.Text = "The number of 12 year olds is "
    lbl13.Text = "The number of 13 year olds is "
    lbl14.Text = "The number of 14 year olds is "
    lbl12.Visible = True
    lbl13.Visible = True
    lbl14.Visible = True
    End Sub
    End Class
    I think I should use a For..Next loop but I don't know how to identify and match using this database, and then count how many repeated 12, 13, 14 years old there are.
    Any help would be really appreciated.

    Hello,
    Conceptually speaking you would group the data and count. Beings this is school work the demo below is a static example and not suitable for your assignment, its to show a point. Now if you have learned about LINQ and Lambda this logic can apply to your
    question but need to work out using this your data which can be done. If not look at using SQL Grouping.
    Example of SQL grouping and count
    select country, count(country) as count from customers group by country
    Module Module1
    Public Sub GroupingDemo()
    Dim dt As DataTable = SimulateLoadFromDatabase()
    Dim TeamData = dt.AsEnumerable.GroupBy(
    Function(student) student.Field(Of Integer)("Age")) _
    .Select(Function(group) New With
    Key .Value = group.Key,
    Key .Info = group.OrderByDescending(
    Function(x) x.Field(Of String)("Name"))}) _
    .OrderBy(
    Function(group) group.Info.First.Field(Of Integer)("age"))
    Dim dictData As New Dictionary(Of String, String)
    For Each group In TeamData
    Console.WriteLine("Group: {0} count: {1} ", group.Value, group.Info.Count)
    dictData.Add(group.Value.ToString, group.Info.Count.ToString)
    ' The following is not needed but good to show
    For Each item In group.Info
    Console.WriteLine(" {0} {1}",
    item.Field(Of Integer)("Identifier"),
    item.Field(Of String)("Name"))
    Next
    Next group
    Console.WriteLine()
    Console.WriteLine("This data can be used to populate control text")
    For Each Item As KeyValuePair(Of String, String) In dictData
    Console.WriteLine("{0} {1}", Item.Key, Item.Value)
    Next
    End Sub
    Private Function SimulateLoadFromDatabase() As DataTable
    Dim dt As New DataTable With {.TableName = "MyTable"}
    dt.Columns.Add(New DataColumn With {.ColumnName = "Identifier", .DataType = GetType(Int32),
    .AutoIncrement = True, .AutoIncrementSeed = 1})
    dt.Columns.Add(New DataColumn With {.ColumnName = "Name", .DataType = GetType(String)})
    dt.Columns.Add(New DataColumn With {.ColumnName = "Age", .DataType = GetType(Int32)})
    dt.Rows.Add(New Object() {Nothing, "Bill", 13})
    dt.Rows.Add(New Object() {Nothing, "Karen", 14})
    dt.Rows.Add(New Object() {Nothing, "Jim", 13})
    dt.Rows.Add(New Object() {Nothing, "Paul", 15})
    dt.Rows.Add(New Object() {Nothing, "Mike", 14})
    dt.Rows.Add(New Object() {Nothing, "Jill", 13})
    Return dt
    End Function
    End Module
    Output in the IDE output window
    Group: 13 count: 3
    3 Jim
    6 Jill
    1 Bill
    Group: 14 count: 2
    5 Mike
    2 Karen
    Group: 15 count: 1
    4 Paul
    This data can be used to populate control text
    13 3
    14 2
    15 1
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Count the number of lines in a txt file

    I need to count the number of lines in a txt file, but I can't do it using readLine(). This is because the txt file is double spaced. readLine() returns null even if it is not the end of the file. thanks for the help

    I need to count the number of lines in a txt file,
    but I can't do it using readLine(). Then just compare each single byte or char to the newline (code 10).
    This is because the txt file is double spaced. readLine() returns
    null even if it is not the end of the file.Errm what? What do you mean by "double spaced"? Method readLine() should only return null if there's nothing more to read.

  • Count the number of occurence in table with toplink

    Hi !
    there is no way to build a query with expressionbuilder or .... to count the number of occurences in my table ?
    i don't want use query " select count(*) from table "
    thanks

    Not sure of the question. Are you looking to get the sql "select count(*) from table" from using the TopLink expression framework or are you getting that SQL already and want something else?
    If you are looking just to get the count from a table/class, you can use a ReportQuery:
    ReportQuery rquery = new ReportQuery(ClassToQueryOn.class);
    rquery.addCount(); //equivalent to count(*);
    session.executeQuery(rquery);
    You can use a report query to return data instead of objects, and use selection criteria just like a normal read query.
    Best Regards,
    Chris

  • How to count the number of Rows to be Updated before Update takes place..

    Hi all,
    I have a requirement, where i have to count the number of rows to be updated before updating it. SQL%ROWCOUNT gives the no. of rows updated ( after update takes place). How do i get to know the count of no. of rows to be updated/inserted/ deleted. I was looking for a simple solution, as above SQL%Rowcount. But i couldn't find any. I can use a Function and Return the value which will give me number of rows to be updated, But is there any Simple Logic other than this.. or any count function. Your Help is Appreciated. Thanks!

    If you really want to do this (I have no clue why you would need it), then you can piggy back on any existing pessimistic locking you may already have in place.
    However, it would require two loops through the records of which you want to know the count before you update, and a second pass to update them.
    I would really re-think the need for this, though.
    SQL> create table t0304(c number);
    Table created.
    SQL> insert into t0304 select rownum from all_objects where rownum <= 10;
    10 rows created.
    SQL> commit;
    Commit complete.
    SQL> select * from t0304;
             C
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.
    SQL> declare
      2    cursor mycursor is select * from t0304 where mod(c,2) = 0 for update;
      3    i number := 0;
      4  begin
      5    for r in mycursor loop
      6      i := i + 1;
      7    end loop;
      8    dbms_output.put_line(i);
      9    for r in mycursor loop
    10      update t0304 set c = c + 20 where current of mycursor;
    11    end loop;
    12  end;
    13  /
    5
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL> select * from t0304;
             C
             1
            22
             3
            24
             5
            26
             7
            28
             9
            30
    10 rows selected.
    SQL>Edited by: Steve Howard on Mar 4, 2011 5:57 PM

  • Need to know how to limit the number of rows returned on Oracle

    MS SQL Server has a command called 'set row count'.
    We are trying to find similar one on Oracle.
    What we are trying to do is that instead of using rownum in the query statement, we would like to find way to limit the number of rows returned. I understand that we can use JDBC resultSet object, but that's not what we want.
    I know Oracle has one called arraysize, but this would not limit the number of rows returned either.
    Pease help.
    Thanks

    I understand that we can use JDBC resultSet object, but that's not what we want.I'm not sure which feature of ResultSet you use and which not.
    But if this question has anything to do with JDBC (that's the forum where you put it), I'd recommend to use Statement.setMaxRows(). This will limit the count of rows which your statement will fetch into it's ResultSet.

  • Count the number of times a character is in a string using pl/sql

    I need to count the number of times ":" appers in the string ":XXX:CCC:BBB:".
    I have sound some solution using SQL but I do not want the context switch.
    Also I am on 10g so I can not use REGEXP_COUNT.
    Any help would be great.

    Hi,
    length(REGEXP_REPLACE(':XXX:CCC:BBB:','[[:alnum:]]'))counts all kinds of punctuation, spaces, etc., not just colons. Change any (or all) of the colons to periods and it will still return 4. Use '[^:]' instead of '[[:alnum:]]' if you really want to count just colons.
    Also, "SELECT ... FROM dual" is usually needed only in SQL*Plus or similar front end tools. In PL/SQL, you can call functions without a query, like this:
    x := NVL (LENGTH (REGEXP_REPLACE (txt, '[^:]')), 0);

  • I need to WAP to count the number of occurences of an alphabet in a string.

    I need to WAP to count the number of occurences of an alphabet in a string.I tried a lot and have surfed a lot regarding this problem.
    I m not the most proficient with java.but this is all i could come up with,and would appreciate some help here.I hope you guys would help me find a solution to this.
    e.g String : abcabrty
    Result should be
    a:2
    b:2
    c:1
    r:1
    t:1
    y:1
    public class chkoccurences
         public static void main(String args[ ])
              String user_Data=args[0];
              int counter=0;     
              try
                   for(int i=0;i<user_Data.length( );i++)
                        for(int j=0;j<user_Data.length( );j++)
                             if(user_Data.charAt(i) == user_Data.charAt(j))
                             counter++;
                        System.out.println(user_Data.charAt(i)+" exists "+counter+" time(s) in the word.");
                   System.out.println(" ");
              catch(ArrayIndexOutOfBoundsException e)
                   System.out.println("Check the array size.");
    }This is the output i get out of the program:
    a exists 2 time(s) in the word.
    b exists 4 time(s) in the word.
    c exists 5 time(s) in the word.
    a exists 7 time(s) in the word.
    b exists 9 time(s) in the word.
    r exists 10 time(s) in the word.
    t exists 11 time(s) in the word.
    y exists 12 time(s) in the word.What i think is i need an array to store the repeated characters because the repeated characters are getting counted again in the loop,if you know what i mean.
    Please, i would appreciate some help here.

    Criticism is welcomed
    public class tests {
         final int min = 10;
         final int max = 35;
         final char[] chars = new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
                   'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
                   'v', 'w', 'x', 'y', 'z'};
         public static void main(String[] args){
              tests t = new tests();
              String[] strings = new String[] {"aabcze", "att3%a", ""};
              for(String s : strings){
                   System.out.println(t.getAlphaCount(s));
         public String getAlphaCount(String s){
              int[] alphaCount = new int[26];
              int val;
              for(char c : s.toCharArray()){
                   val = Character.getNumericValue(c);
                   if( (val>=min) && (val<=max)){
                        alphaCount[val-min]++;
              StringBuilder result = new StringBuilder();
              for(int i=0; i<alphaCount.length; i++){
                   if(alphaCount[i] > 0){
                        result.append(chars[i] + ":" + alphaCount[i] + ", ");
              if(result.length() != 0){
                   result.delete(result.length()-2, result.length());
              return result.toString();
    }

  • How to count the number of 'True' outputs from an 'Equal?' function?

    In my program, I have an 'Equal?' function which returns 'True' whenever x=y. How can I count the number of 'True' and display? I mean, for example, when it say True, the counter should display '1', when it say true next time the counter should display '2', like wise 3, 4.... so on. Can any one help me to do this? Is there any function which conts and display the number of 'true' outcomes?

    Is your event structure in a while loop?  Then that's where the shift register can go.  But for portability a feedback node can be used if the VI is not reentrant.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Servlet to count the number of occurances of a particular node

    Hi
    I am looking for a servlet which will count the number of a particular node which I have supplied of an XML file.
    Can somebody please help me with this?
    Thankyou

    If you are using Xerces, after you have parsed your XML files using a DOMParser, get the document object from the parser like
    Document document = parser.getDocument();
    And then use the command getElementsByTagName("*"); // for all elements
    it will return the node list object (NodeList) which you can get the count (nodeList.getLength())

Maybe you are looking for

  • Tracking the changes in Scheduling agreement delivery schedule

    With Scheduling agreements, when goods receipt is done at receiving, system will validate against the Scheduled qty and delivery dates. If there is excess qty received, they need to either change the qty or the date to receive the same. Now current p

  • IPod won't sync purchased music, games, or video?

    Ok so i plugged my iPod in a few days ago to my computer to sync it. everything was going well until- "Some of the items in the iTunes library were not copied to the iPod because you are not authorized to play them on this computer." Now, i went into

  • MBP LED LCD Gradient Test - Software or Hardware issue?

    Hello! I've noticed some of the discussions around the new MBP's LED displays, and some people having issues with not-so-smooth gradients in LCDTest 1.1 or 2.0. My current, new, SR 15" MBP sports a darkish bar in the green area of the gradient, and a

  • FF4 does not display formatting correctly in Google Docs

    The formatting of documents is not displayed correctly in Google Documents. For example table borders disappear. Document formatting is displayed correctly in IE9. Screenshot attached for reference http://i.imgur.com/d1JDS.png

  • Premiere Pro CC 2014.2 Crashing on Startup

    Hi guys, My Premier Pro keeps crashing when it starts up. It only started happening a couple of days ago. I've pulled the below out of the event viewer. I have already tried the following; 1) Disabled intel graphics to leave just my AMD Radeon Graphi