Logical line count

hey yall
I m trying to write myself a program that will count the number of logical lines in a java program. For example, if my input is
ddafa
//daga
daddfa
tab tab tab --tab s meaning white space i ve to skip
eaqr
my program should skip the comments, the white spaces, tabs, newline returns and return me 3.
I ve started thinking and editing and more thinking, and now I'm getting frustrated over how to skip white space.
Also, is there any way to skip white space upto, say a comment, in the middle of the page? Like this
The startsWith("/") didn't work.
Here is my program
  public class LOC   
       public static void main(String[] args)
         String file    = "a";
         int count = 0;
         InputStreamReader input = new InputStreamReader (System.in);
         BufferedReader stdin      = new BufferedReader(input);         
         try
            System.out.println("Enter name of file:> ");     
            file = stdin.readLine();  
            FileReader fr = new FileReader(file);
            BufferedReader in = new BufferedReader(fr); 
            String inputLine = in.readLine();          
            while(inputLine != null)
               while(!inputLine.startsWith("/"))
                  count++;
                           for (int i = 0; i < inputLine.length();  i++)
                              char c = inputLine.charAt(i);
                              if(!Character.isWhitespace(c))
                                 count++;   
        inputLine = in.readLine();  // to exit the e                   
               inputLine = in.readLine();
            }Somebody needs to help please.

Thanks to yall for ur quick and helpful responses. I skimmed thru the java documentation, and yes, trim appeared to be useful in skipping white space.
This is what I have accomplished with the addition of trim. I could not get the tricky slashSlashComment() class to work, so I figured out my own.
but...
Now I have another problem. If my input is all consecutive lines, my program runs fine. Forex, if i have
fdaf
          mofo
I get an answer of 4, which is perfect.
However, if I have one space between the lines, I lose data!
fdaf
dada
dada
     mofo
I get 2 lines.
Could this be due to trim() cutting all the white space between the two lines?
//===========================================================
// LOC.java
// Author: Denem Orhun
// Comp 6700 Software Process
//============================================================
   import java.io.*;
   import java.util.*;
    public class LOC   
       public static void main(String[] args)
         String file    = "a";
         int count = 0;
         char c = ' ';
         InputStreamReader input = new InputStreamReader (System.in);
         BufferedReader stdin      = new BufferedReader(input);         
         try
            System.out.println("Enter name of file:> ");     
            file = stdin.readLine();  
            FileReader fr = new FileReader(file);
            BufferedReader in = new BufferedReader(fr); 
            String inputLine = in.readLine();          
            while(inputLine != null)
               String newString =    inputLine.trim(); //get rid of the white space
               if((newString.length() == 0 || newString.charAt(0) == '/'))
                  inputLine = in.readLine();     
               if(newString.charAt(0) == "/n") 
                  inputLine = in.readLine();              
               else
                  count++; 
               inputLine = in.readLine();  // to exit the while loop                   
            System.out.println(c);
            in.close(); // close the input stream   
            System.out.println("Number of lines " + count);
             catch(FileNotFoundException exception)
               System.out.println("File not found");
             catch (IOException exception)
               System.out.println(exception);
   }I believe I m very close to the solution but I m sure its a very minor error in there. I ve been staring at the screen for lets see, since yall's posts and the screen is starting to blink lol...

Similar Messages

  • How to delete the logical lines in JTextArea

    Hi all,
    Now that I know how to find the logical line count in JTextArea as
    I found the following in the forum.
    public static int getLineCount (JTextArea _textArea)
    boolean lineWrapHolder = _textArea.getLineWrap();
    _textArea.setLineWrap(false);
    double height = _textArea.getPreferredSize().getHeight();
    _textArea.setLineWrap(lineWrapHolder);
    double rowSize = height/_textArea.getLineCount();
    return (int) (_textArea.getPreferredSize().getHeight() / rowSize);
    I want to delete the 4th line to the last line and append ... at the 4th, if the getLineCount exceeds 3. Does any body know how to do so?
    The intention is for the multiline tooltip as I just want to show
    the first three logical line and ... if the string is too long.
    Thanks
    Pin

    The code looks good to me. The only thought I have is that the y coordinate for the rowThree point is wrong and is referencing row four.
    I've been playing around with using a JTextArea as a renderer for a JTable. I have it working so that "..." appear when the text exceeds 2 rows. Try clicking on "B" in the letter column and then the update cell button a few times to add text. My code is slightly different than yours.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TestTable extends JFrame
         private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
         JTable table;
         Vector row;
         public TestTable()
              Object[][] data = { {"1", "A"}, {"2", "B"}, {"3", "C"} };
              String[] columnNames = {"Number","Letter"};
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              table = new JTable(model)
                   public String getToolTipText( MouseEvent e )
                        int row = rowAtPoint( e.getPoint() );
                        int column = columnAtPoint( e.getPoint() );
                        if (row == 0)
                             return null;
                        else
                             return row + " : " + column;
              table.setRowSelectionInterval(0, 0);
              table.setColumnSelectionInterval(0, 0);
              table.setRowHeight(0,34);
              table.setRowHeight(1,34);
              table.setRowHeight(2,34);
              table.setDefaultRenderer(Object.class, new TextAreaRenderer(2));
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
              JPanel buttonPanel = new JPanel();
              getContentPane().add( buttonPanel, BorderLayout.SOUTH );
              JButton button2 = new JButton( "Update Cell" );
              buttonPanel.add( button2 );
              button2.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        int row = table.getSelectedRow();
                        int column = table.getSelectedColumn();
                        String value = (String)table.getValueAt(row, column);
                        value += value;
                        table.setValueAt( value, row, column );
                        DefaultTableModel model = (DefaultTableModel)table.getModel();
                        model.fireTableCellUpdated(row, column);
                        table.requestFocus();
         public static void main(String[] args)
              TestTable frame = new TestTable();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
         private class TextAreaRenderer extends JTextArea implements TableCellRenderer
              public TextAreaRenderer(int displayRows)
                   setRows(displayRows);
                   setLineWrap( true );
              public Component getTableCellRendererComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             boolean hasFocus,
                                             int row,
                                             int column)
                   setText( value.toString() );
                   Dimension d = getPreferredSize();
                   int maximumHeight = getRows() * getRowHeight();
                   if (d.height > maximumHeight)
                        setSize(d);
                        int offset = viewToModel( new Point(d.width, maximumHeight - 1) );
                        replaceRange( "...", offset-3, getDocument().getLength() );
                   return this;
    }

  • How to get logical JTextArea line count

    Hi,
    I would like to get the logical JTextArea line count. The existing
    getLineCount method returns the line count based on "\n", which
    is not what I want.
    Any ideas?
    Thanks,
    Pin

    I found the following solution in the forum and it works.
    I haven't tested for all cases though...
    public static int getLineCount (JTextArea _textArea)
    boolean lineWrapHolder = _textArea.getLineWrap();
    _textArea.setLineWrap(false);
    double height = _textArea.getPreferredSize().getHeight();
    _textArea.setLineWrap(lineWrapHolder);
    double rowSize = height/_textArea.getLineCount();
    return (int) (_textArea.getPreferredSize().getHeight() / rowSize);
    Thanks,
    Pin

  • Compare two invoices with same distribution line count

    I am trying to pull data out of Oracle Payables - invoices for which the invoice amount ,the vendor and distribution line count is same.
    I could achieve pulling invoices with same Vendor having same amount.But finding hard to compare the counts.
    Can anyone share ideas on how to achieve this ... Tried self join but did not work.
    The query which I used is as follows :
    select invoice_num,invoice_id,invoice_amount,vendor_id,
    (select vendor_name from apps.po_vendors where vendor_id=aia.vendor_id) vendor_name,
    (select count(*) from apps.ap_invoice_distributions_all aid where aid.invoice_id=aia.invoice_id) line_count
    from apps.ap_invoices_all aia
    where invoice_amount in (select aiab.invoice_amount
    from apps.ap_invoices_all aiab
    where aiab.creation_date >='01-AUG-2012'
    and vendor_id=aia.vendor_id
    group by aiab.invoice_amount
    Having (count(aiab.invoice_amount) >1))
    and aia.creation_date >='01-AUG-2012'
    Thanks in Advance.

    I did try your query with sample records and counts are also correct plz chk the following, for me counts are correct as per your logic -
    select aia.invoice_num,aia.invoice_id,aia.invoice_amount,aia.vendor_id,
    (select vendor_name from
    (select 'XX' vendor_name, 'A' vendor_id from dual union all
    select 'XY' vendor_name, 'B' vendor_id from dual union all
    select 'XZ' vendor_name, 'C' vendor_id from dual union all
    select 'XA' vendor_name, 'D' vendor_id from dual ) po
    where vendor_id=aia.vendor_id) vendor_name,
    (select count(*) from
    (select 1 invoice_id from dual union all
    select 1 invoice_id from dual union all
    select 1 invoice_id from dual union all
    select 2 invoice_id from dual union all
    select 3 invoice_id from dual ) aid
    where aid.invoice_id=aia.invoice_id) line_count
    from
    select 10 invoice_num, 1 invoice_id,100 invoice_amount, 'A' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 11 invoice_num, 1 invoice_id,100 invoice_amount, 'A' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 12 invoice_num, 1 invoice_id,100 invoice_amount, 'A' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 13 invoice_num, 2 invoice_id,100 invoice_amount, 'B' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 14 invoice_num, 2 invoice_id,100 invoice_amount, 'B' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 15 invoice_num, 3 invoice_id,100 invoice_amount, 'C' vendor_id ,'01-SEP-2012' creation_date from dual union all
    select 16 invoice_num, 4 invoice_id,100 invoice_amount, 'D' vendor_id,'01-OCT-2012' creation_date from dual) aia
    where aia.invoice_amount in (select aiab.invoice_amount
    from
    select 10 invoice_num, 1 invoice_id,100 invoice_amount, 'A' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 11 invoice_num, 1 invoice_id,100 invoice_amount, 'A' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 12 invoice_num, 1 invoice_id,100 invoice_amount, 'A' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 13 invoice_num, 1 invoice_id,100 invoice_amount, 'B' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 14 invoice_num, 1 invoice_id,100 invoice_amount, 'B' vendor_id ,'01-AUG-2012' creation_date from dual union all
    select 15 invoice_num, 1 invoice_id,100 invoice_amount, 'C' vendor_id ,'01-SEP-2012' creation_date from dual union all
    select 16 invoice_num, 1 invoice_id,100 invoice_amount, 'D' vendor_id,'01-OCT-2012' creation_date from dual) aiab
    where aiab.creation_date >='01-AUG-2012'
    and aiab.vendor_id=aia.vendor_id
    group by aiab.invoice_amount
    Having (count(aiab.invoice_amount) >1))
    and aia.creation_date >='01-AUG-2012'
    o/p
    INVOICE_NUM,INVOICE_ID,INVOICE_AMOUNT,VENDOR_ID,VENDOR_NAME,LINE_COUNT
    10,1,100,A,XX,3
    11,1,100,A,XX,3
    12,1,100,A,XX,3
    13,2,100,B,XY,1
    14,2,100,B,XY,1
    -------

  • Order of delivery schedule line counter at schedule agreements from MRP run

    Currently we are using schedule agreements for our long term external suppliers, but we are facing a problem with the order of new delivery schedule lines created during MRP run.
    Because of master data settings like, lot size, rounding value, plan delivery time and planning time fence to set as firm new requirements, multiple schedule lines are created with no order for schedule line counter.
    Does anyone is aware of a BADI, user exit or customizing control to have this schedule line counter in order?
    Thank you
    Daniel Guillen
    IT
    Skyworks Inc.

    Hi,
    Pls put this query in SD fourms  and get immly help because this is technical fourms.
    Anil

  • Multiple small stories with variable line counts assigned to different editors

    I have a "best practice" question for you more experienced InCopy users about what workflow you recommend for my specific issue. I am experienced in InDesign, but am a InCopy newbie. I want to make sure I'm not missing a solution because my lack of experience with InCopy may be causing me not to see the forest for the trees.
    Short version: What is the best way to allow multiple editors access to each of multiple small stories separately (one story per editor), but to allow the line count of each story to be variable each week, while adjusting the rest of the stories along with it on the page (see image below)?
    Details: My publishing company's workflow is on CS6 with editors working in Word, and we're upgrading to CC2014 with InCopy. We have 7 in-house editors, and all files on an in-house server. We have quick deadlines (some are 15 minutes from editor writing copy to transmitting publication to subscribers). In the example below, we have 10 sections, and I have all seven editors writing different sections at the same time. A final editor has control over fitting the final page. My INDD files to test the new workflow use an assignment-based workflow. I understand I can place each of these sections as their own story, under the same assignment, so a different editor can have them checked out. However, each section does not have the same line count from week to week. Markets with more activity will get more lines.
    In our current workflow, we have multiple rough Word docs pulled into one master doc with a script, that the final editor edits to fit, so each section can be a different number of lines as long as the total is the same. Then production staff load it in. When we upgrade, we can use a hybrid workflow where the final editor just loads that final Word doc into one InCopy story and edits it to fit.
    It would be great if I just didn't understand how to make the text height variable for the story each editor is typing, and auto-adjust so the next story starts below where the story above it ends, and you all had an idea how I can do it!
    Thanks! Nancy

    I disagree to Seshu's answer to question 1.
    Correct answer of question 1 is C and <u><b>not A.</b></u>
    Sorry I didn't find time to check the rest.
    <u>To the examinee</u>
    I wouldn't assume all answers from SDN-ers are correct if my certification exam was knocking the door! I would rather try and find out the correct answers myself from the system instead of mugging these answers without any understanding of the technology involved! Find out the answers yourself from the system...that way it will help you to understand why the answer is 'C' and not 'A'...just knowing the answer is 'C' is not good enough...one has to understand "why" its 'C' and not 'A'. Hope you get my point! Good luck.

  • Link between Delivery schedule line counter from PO and the material docume

    Dear Gurus,
    I have one PO with single line item having delivery schedule -
    Material 1 -
    delivery schedule 01.01.2009     2000
                                                         01.03.2009    5000
    I have received quantity against this Po
    I want to know where I can find the link between Delivery schedule line counter from PO and the material document
    Best regards
    Sar

    There is no link from the MAterial document line item (Table Mseg) to the PO Schedule Line (EKET).
    If this is for Evaluating an on time delivery or GR, you may consider the following approach.
    PO details Po Date  QTY
    Sch1   01Jun2009   200   
    SCH2  08Jun2009   100
    GR Details
    GR1   01Jun2009   180
    GR2   07Jun2009   110
    GR3  09Jun2009      10
    Calculate a *** total qty for the PO Line.
    PO details Po Date  CUMUL QTY
    Sch1   01Jun2009   200   
    SCH2  08Jun2009   300
    Calculate a *** total qty for the ontime GR.
    PO details Po Date  CUMUL PO QTY  CUMUL GR on time
    Sch1   01Jun2009   200                180
    SCH2  08Jun2009   300                 290 (180+110)  the 3rd GR was too late
    Evaluate the PO SChedule Lines as follows:
    Po SCL qty + CUMUL GR QTY - CUMUL PO QTY = ADJ GR ON Time Qty
    SCH1 01Jun2009
    200 + 180 - 200 = 180 on time for 01Jun2009 date ( 90% fill rate)
    SCH2 08Jun2009
    100 + 290 - 300 = 90 on time for 08Jun2009 date (90 % fill rate) the first 20 of the GR on 07Jun2009 went to fill the late, early date.
    Best of luck !
    SCH2 100 +290 - 300 = 90 on time for 07Jun2009 date

  • Report:Setting the line-count in the output automatically

    i want to set the line-count in the report automatically irrespective of screen resolution.could you please explain.

    hi,
    try this,
    report zrich_0001  line-count 25(4).
    reward points if useful,
    regards,
    Raj,

  • Varying the line count in every page

    Hi All..
    I want to vary the line count in a page in my report.
    I have mentioned the line size n line count at the starting of the report, n it prints the same no of lines in every page but in the subsequent pages , I want to increase the line count .
    How can I do that ? 
    Thanks.

    Hi Naimesh..
    thanks for the reply .
    well,the code u suggested does not work..NEW-PAGE is jus a standalone command with which the line count cannot be associated.
    I actually have some header details that shud only appear on 1st page , n basing on the line count all works fine on 1st page ..but on the 2nd page the header details ned not appear , so only the itab details are getting printed , so the sy-tabix value remains the same but the line count is less than the 1st page leaving some space at the bottom of the page .
    And in the subsequent pages the printing takes place but from the begining of the page n also leaving more space at the bottom of the page.
    I want that equal no of lines get printed each page , also leaving equal no of lines at the bottom of each page.
    Hope I'm  sounding clear.
    Any answers ?
    Thanks.
    Sangeet.

  • Regarding line count in normal list

    Hi all,
    In normal list am giving line count as 32. Its showing output correctly in my system. But when am seeing my output in other system the second page header is coming in the first page. I think according to configuration line count may change. Plese tell what i need to do to get ouput correct irrespective of system(Is there any system variable is there to do this).

    This actuly configuration problem
    configuration of sap in that system not done properly'
    I am sying this becouse i also faced same problem
    so configer it again ....
    Waiting for reward points........................

  • Dynamic setting of line count and footer in classical report

    Hi all,
    In classical report,we can set line count and footer at the beginning of the report  as Line-count 6(2), here out of 6 lines 4 lines is for content and 2 lines is for footer (assume no standard heading), but if my report produces less content than 4 say 3 at run time ,then footer will not be displayed .Here again i have to set line count and footer as 5(2) in order to get the footer to be displayed ,so How can i achieve dynamic setting of the line count and footer,
    Thanks,
    Avinash

    Use RESERVE,
    START-OF-SELECTION.
    RESERVE 6 LINES.           "at the last of your code
    This will trigger a page-break & footer will be displayed.

  • How to allocate space for headers in reports through line size r line count

    hi ,
    may i know how to allocate space for a header ( we do the same for footer through line-count ( footer space ) ) through line size or line count in reports...
    thanks in advance..

    Hi..,
    There is no need to reserve any space for the header. TOP-OF-PAGE can by default allocates the space for the header.
    If you still having confusion just  go ahead with this link. This is the research on same thing in defferent way.
    [Link|lines reservation for TOP-OF-PAGE & END-OF-PAGE;
    Thanks,
    Naveen.I

  • Line size and line count

    Hi all,
    May i know about line size and line count impact on reports ?
    i mean depending on line sizes values i.e 200 etc hw it will effect report either in output display  or length ?
    and also ablout line count too.
    Thanks in advance.

    This information may help you
    *... LINE-SIZE width *
    Effect
    This addition specifies the line width of the basic list and details list of the program to width characters, and sets the system field sy-linsz to this value. The line width determines the number of characters in the line buffer as well as the number of columns in the list displayed. The value width must be a positive numeric literal. The maximum line width is 1,023 characters.
    When the LINE-SIZE is not specified, the line width of the basic list is set to a standard width based on the window width of the current Dynpro, but is at least as wide as a standard size SAP window. For the standard width, the contents of sy-linsz is 0. The LINE-SIZE overwrites the value of the like-named LINE-SIZE addition to the statement SUBMIT and can be overwritten during list creation with the like-named LINE-SIZE addition to the statement NEW-PAGE.
    Note
    The current maximum line width is stored in the constants slist_max_linesize of the type group SLIST. Also defined there is a type slist_max_listline of type c with length slist_max_linesize.
    *... LINE-COUNT page_lines[(footer_lines)] *
    Effect
    This addition specifies the page length for the basic list of the program to page_lines lines and fills the system field sy-linct with this value. If the LINE-COUNT is not specifed, and if page_lines are less than or equal to 0 or greater than 60,000, then the page length is set internally to 60,000. This setting overwrites the passed value of the like-named LINE-SIZE addition to the statement SUBMIT and can be overwritten during list creation with the like-named LINE-COUNT addition to the statement NEW-PAGE.
    If you optionally specify a number for footer_lines, a corresponding number of lines are reserved for the page footer, which can be described in the event block END-OF-PAGE.
    You must specify page_lines and footer_lines as numeric literals.
    Notes
    For screen lists, you should use the standard value since, as a rule, page breaks defaulted through LINE-COUNT are not adjusted to the window size.
    You should also use the standard value for print lists, so that you can still select the page size on a printer-specific basis. A print list should be created in such a way so that it can handle every page size.
    Specifying a fixed line count is only useful for form-type lists with a fixed page layout. Here, however, you should always check whether such forms can be created by other means, such as SAPScript forms.

  • Director 11 line.count problem?

    Hi all. My name is Natassa and this is my first time here!
    I am not new with Director, but can't figure out the
    following!
    There seems to be something wrong when working with text
    members regarding the line.count property. In our project, i parse
    through XML files and store data in text members which are placed
    on stage and run a mouseOver script using pointToLine(the mouseLoc)
    in order to change the color of the "active" line of the text
    member.
    The XML files are all utf-8 encoded, since we have english,
    greek and french text.
    I use a repeat loop so as to fill a text member with some
    titles.
    I have tried everything i could think of and could not solve
    my problem. So, i thought i should try something very basic and
    figure out what is going on.
    Nothing seems to be working!
    I have run the following basic scripts with the following
    output:
    Example A
    script:
    --I use numToChar(940) which is a greek character, since in
    our project we have english, greek, french all utf-8 encoded
    member("myText").text=""
    repeat with i=1 to 300
    myString = " line " & numToChar(940) &
    numToChar(940) & numToChar(940) & numToChar(940) & i
    member("myText").line[ i ] =myString
    put i,member("myText").line[ i ],
    member("myText").line.count
    end repeat
    Message window output:
    -- 1 " line άάάά1" 1
    -- 2 " line άάάά2" 2
    . (everything ok so far)
    -- 232 " line άάάά232" 232
    -- 233 " line άάάά233" 233
    -- 234 " line άάάά234" 208
    -- 235 "" 235 HERE IS THE PROBLEM - NO STING STORED IN THE
    TEXT MEMBER AFTER THIS LINE
    -- 236 "" 236
    -- 237 "" 237
    -- 299 "" 299
    -- 300 "" 300
    put member("myText").line.count
    -- 300
    put member("myText").line[300]
    Example B
    script:
    --I use numToChar(940) which is a greek character, since in
    our project we have english, greek, french all utf-8 encoded
    member("myText").text=""
    repeat with i=1 to 300
    myString = " line " & numToChar(940) &
    numToChar(940) & numToChar(940) & numToChar(940) & i
    member("myText").setContentsAfter(RETURN & myString)
    put i,member("myText").line[ i ],
    member("myText").line.count
    end repeat
    Message window output:
    -- 1 " line άάάά1" 2
    -- 2 " line άάάά2" 3
    . (everything ok so far)
    -- 232 " line άάάά232" 233
    -- 233 " line άάάά233" 234
    -- 234 " line άάάά234" 209 HERE IS THE
    PROBLEM - line.count DOES NOT WORK CORRECTLY
    -- 235 " line άάάά235" 210
    -- 299 " line άάάά299" 274
    -- 300 " line άάάά300" 275
    put member("clippings").line.count
    -- 275
    -- But if i copy the text of the member and paste it into a
    text editor, there are 300 lines!!!
    put member("clippings").line[300]
    -- " line άάάά300"
    As a result, the pointToLine(the mouse Loc) is not working
    well! The mouse is over a line and a different line has the
    "active" color...
    As you can see, the problem occurs after line 234!! :-|
    Does anyone else have the same problem? I have a deadline and
    can't figure out what to do!!
    p.s. I updated a director MX file to a director 11 file. A
    text member (contains greek and latin characters) opened in MX has
    a line.count of 384 (correct) and the same member opened in 11 gave
    a line.count of 275!!!!! Again the same problem with
    pointToLine()...

    >
    Example A
    >
    > -- 233 " line ????233" 233
    > -- 234 " line ????234" 208
    > -- 235 "" 235 HERE IS THE PROBLEM - NO STING STORED IN
    THE TEXT MEMBER
    > AFTER THIS LINE
    FWIW: I can replicate this problem, and it doesn't occur in
    DMX2004, so
    it's a new bug. It seems that line 234 gets the line number
    wrong (208)
    and it all turns to custard after that
    >
    Example B
    >
    > -- 232 " line ????232" 233
    > -- 233 " line ????233" 234
    > -- 234 " line ????234" 209 HERE IS THE PROBLEM -
    line.count DOES NOT WORK
    > CORRECTLY
    > -- 235 " line ????235" 210
    And I can replicate this too.
    However, I can "fix" your second example by referencing
    member.text.line
    instead of member.line. See the following alteration to your
    original
    handler:
    on test2
    member("myText").text=""
    c = numToChar(940)
    s = "line " & c & c & c & c
    repeat with i=1 to 300
    member("myText").setContentsAfter(RETURN & s & i)
    put i, member("myText").text.line
    , member("myText").text.line.count
    end repeat
    end
    I can't find a fix for your first example in a similar
    fashion. It's not
    permitted to execute member("myText").text.line =
    "string"
    > As a result, the pointToLine(the mouse Loc) is not
    working well! The mouse is
    > over a line and a different line has the "active"
    color...
    > p.s. I updated a director MX file to a director 11 file.
    A text member
    > (contains greek and latin characters) opened in MX has a
    line.count of 384
    > (correct) and the same member opened in 11 gave a
    line.count of 275!!!!! Again
    > the same problem with pointToLine()...
    Try instead measuring member.text.line.count instead of
    member.line.count
    I will try to replicate the pointToLine() issue and see if I
    can find a
    workaround.

  • How to get file line count.

    Hey guys,
    How to get file line count very fast? I am using BufferedReader to readLine() and count. But when dealing with big file, say several GB size, this process will be very time consuming.
    Is there any other methods?
    Thanks in advace!

    What I'd do is you create an infofetcher, register a listener, implement gotMore() and have that scan for '\n'
    Some might suggest getting rid of the listener/sender pattern or use multiple threads to make ii faster. This might help a little, but only if your I/O is super-duper speedy.
    you are welcome to use and modify this code, but please don't change the package or take credit for it as your own work.
    InfoFetcher.java
    ============
    package tjacobs.io;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.Iterator;
    * InfoFetcher is a generic way to read data from an input stream (file, socket, etc)
    * InfoFetcher can be set up with a thread so that it reads from an input stream
    * and report to registered listeners as it gets
    * more information. This vastly simplifies the process of always re-writing
    * the same code for reading from an input stream.
    * <p>
    * I use this all over
         public class InfoFetcher implements Runnable {
              public byte[] buf;
              public InputStream in;
              public int waitTime;
              private ArrayList mListeners;
              public int got = 0;
              protected boolean mClearBufferFlag = false;
              public InfoFetcher(InputStream in, byte[] buf, int waitTime) {
                   this.buf = buf;
                   this.in = in;
                   this.waitTime = waitTime;
              public void addInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        mListeners = new ArrayList(2);
                   if (!mListeners.contains(fll)) {
                        mListeners.add(fll);
              public void removeInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        return;
                   mListeners.remove(fll);
              public byte[] readCompletely() {
                   run();
                   return buf;
              public int got() {
                   return got;
              public void run() {
                   if (waitTime > 0) {
                        TimeOut to = new TimeOut(waitTime);
                        Thread t = new Thread(to);
                        t.start();
                   int b;
                   try {
                        while ((b = in.read()) != -1) {
                             if (got + 1 > buf.length) {
                                  buf = IOUtils.expandBuf(buf);
                             int start = got;
                             buf[got++] = (byte) b;
                             int available = in.available();
                             //System.out.println("got = " + got + " available = " + available + " buf.length = " + buf.length);
                             if (got + available > buf.length) {
                                  buf = IOUtils.expandBuf(buf, Math.max(got + available, buf.length * 2));
                             got += in.read(buf, got, available);
                             signalListeners(false, start);
                             if (mClearBufferFlag) {
                                  mClearBufferFlag = false;
                                  got = 0;
                   } catch (IOException iox) {
                        throw new PartialReadException(got, buf.length);
                   } finally {
                        buf = IOUtils.trimBuf(buf, got);
                        signalListeners(true);
              private void setClearBufferFlag(boolean status) {
                   mClearBufferFlag = status;
              public void clearBuffer() {
                   setClearBufferFlag(true);
              private void signalListeners(boolean over) {
                   signalListeners (over, 0);
              private void signalListeners(boolean over, int start) {
                   if (mListeners != null) {
                        Iterator i = mListeners.iterator();
                        InputStreamEvent ev = new InputStreamEvent(got, buf, start);
                        //System.out.println("got: " + got + " buf = " + new String(buf, 0, 20));
                        while (i.hasNext()) {
                             InputStreamListener fll = (InputStreamListener) i.next();
                             if (over) {
                                  fll.gotAll(ev);
                             } else {
                                  fll.gotMore(ev);
    InputStreamListener.java
    ====================
    package tjacobs.io;
         public interface InputStreamListener {
               * the new data retrieved is in the byte array from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
              public void gotMore(InputStreamEvent ev);
               * reading has finished. The entire contents read from the stream in
               * in the buffer
              public void gotAll(InputStreamEvent ev);
    InputStreamEvent
    ===============
    package tjacobs.io;
    * The InputStreamEvent fired from the InfoFetcher
    * the new data retrieved is from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
    public class InputStreamEvent {
         public int totalBytesRetrieved;
         public int start;
         public byte buffer[];
         public InputStreamEvent (int bytes, byte buf[]) {
              this(bytes, buf, 0);
         public InputStreamEvent (int bytes, byte buf[], int start) {
              totalBytesRetrieved = bytes;
              buffer = buf;
              this.start = start;
         public int getBytesRetrieved() {
              return totalBytesRetrieved;
         public int getStart() {
              return start;
         public byte[] getBytes() {
              return buffer;
    ParialReadException
    =================
    package tjacobs.io;
    public class PartialReadException extends RuntimeException {
         public PartialReadException(int got, int total) {
              super("Got " + got + " of " + total + " bytes");
    }

Maybe you are looking for

  • How can i transfer files and applications from an old windows 98SE OS?

    Recently, i was surprised with a brand spanking new 15.4" 2.2 GHZ intel core 2 macbook pro. before this awesome new notebook, i was using a very old, arthritic windows 98SE OS and everything in my whole computing life is stored on that old win98SE an

  • Legacy on GarageBand

    I am using the iMac (24-inch, Early 2009) 3.06 GHz Intel Core 2 Duo, 4 GB 1067 MHz DDR3, OS X Yosemite version 10.10.1 I recently reset my iMac because it was terribly slow.  Now that it is up and running again, it is still slow and my GarageBand doe

  • Making motion system fonts and icons bigger?

    Is there a way to make the text and icons bigger in the interface? Thanks! Darren

  • Extracting videos from iPod

    Quick question, If I managed to lose my videos from my PC which I use to connect my iPod to though iTunes, is there a tool available online that will enable me to manually extract the videos from the ipod?

  • I cant uninstall CC applications after install CC2014

    Hola My OS is 10.9.3 I installed some applications CC2014 and now I ca't uninstall the old versions (and new). Although I had already successfully uninstalled some applications in previous days. From not being able to uninstall, I've also seen applic