473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

LinkedQ reading in commands that I do not read in

16
I have a problem were My linkedQ. It reads in the command "dot operator"when I try to use commands. "to eventually manipulate it" I used debugs and my linkedQ IS working properly. How do I avoid reading in the . command?


Expand|Select|Wrap|Line Numbers
  1.  
  2. // $Id: jroff.java,v 1.2 2011-01-20 21:20:03-08 - - $
  3.  
  4. import java.io.*;
  5. import java.util.Scanner;
  6. import static java.lang.System.*;
  7.  
  8. class jroff{
  9.  
  10.  
  11.   static final String STDIN_NAME = "-";
  12.  
  13.   static void scanfile (String filename, Scanner infile) {
  14.        linkedqueue <String> wordq = new linkedqueue <String> ();
  15.        int cflag=0;
  16.        int amount=0;
  17.        int flag=0;
  18.        String mm="";
  19.        for (int linenr = 1; infile.hasNextLine(); ++linenr) {
  20.            String line = infile.nextLine();
  21.               if(line.trim().length()==0) {
  22.                   out.printf("the line is blank .sp1");
  23.                }
  24.            String[] words = line.split ("\\s+");
  25.  
  26. /*
  27. // I think this takes issue with me because of my adding the "." in my
  28. list, a problem I Still need to fix.
  29. if (words.length > 0 && words[0].startsWith (".") &&
  30. words[0].charAt(1)=='/' && words[0].charAt(2)=='"') {
  31. for(int i=0; i<3;i++) {
  32. wordq.remove();
  33. out.printf("testing things%n");
  34. }
  35. }
  36.  
  37.  
  38. */
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.                if (words.length > 0 && words[0].startsWith (".")) {
  47.                    flag=1;
  48.                    out.printf("you have initilaized a command of some sort");
  49.                    commands.cmd command = commands.cmd_map.get (words[0]);
  50.                        if (command == null) {
  51.                            auxlib.warn (filename, linenr, words[0],
  52.                            "invalid command");
  53.                            }
  54.                            else {
  55.                                command.exec (words);
  56.                             }
  57.                 }
  58.                // else {
  59.                      int counter=0;
  60.                      int width=50;
  61.                        for (String word: words) {
  62.            //for (String test: line.split ("\\s+")) {
  63.                            if (word.length () == 0){ continue;}
  64.                                wordq.insert (word);
  65.                                amount=amount+1;
  66.                                //wordq.toString();
  67.                           // }
  68.                            if(flag==1){
  69.                                         out.printf(" the amount prior
  70. is %d %n",amount);
  71.                                        out.printf("%n");
  72.                                        //amount=amount-1;
  73.                                for(int i=0;i<amount;i++) {
  74.                                    mm=wordq.remove ();
  75.                                      //wordq.toString();
  76.                                        if(counter!=0){
  77.                                            counter=counter+1+mm.length();
  78.                                        }
  79.                                        if(counter==0) {
  80.                                                counter=mm.length();
  81.                                        }
  82.                                        if(counter>width) {
  83.                                          out.printf("%n");
  84.                                          counter=mm.length();
  85.                                                   }
  86.                                     printparagraph(mm,width,counter);
  87.                                     mm="";
  88.                                 } amount=0;
  89.                           }
  90.  
  91.                        out.printf("the amount is %d %n",amount);
  92.                        flag=0;
  93.                        //out.printf("%n");
  94.  
  95.                        }
  96.                  }
  97.  
  98.          }
  99.  
Apr 25 '11 #1
0 1030

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Lance | last post by:
Hi All, I would like to read commands from a file and execute them in VB, something like reading str = "hello world" into VB and execute it. Any suggestions will be appreciated. Thanks, Lance
2
by: Jim Richards | last post by:
I have been told by a local PC club technician that 98SE cannot read NTFS drives in a network. Is this true? TIA, Jim.
1
by: cnu | last post by:
My program generates a log file for every event that happens in the program. So, I open the file and keep it open till the end. This is how I open the file for writing: <CODE> public...
9
by: Yaro | last post by:
Hello DB2/NT 8.1.3 Sorry for stupid questions. I am newbe in DB2. 1. How can I read *.sql script (with table and function definitions) into a database? Tool, command... 2. In Project Center...
40
by: googler | last post by:
I'm trying to read from an input text file and print it out. I can do this by reading each character, but I want to implement it in a more efficient way. So I thought my program should read one...
15
by: Madhanmohan S | last post by:
Hi All, I want to run a command line appplication from C#. When i start the application, it will go into specific mode. After that, i have to give commands to use the application. How Can This Be...
7
by: pb1uk | last post by:
Hello, I need to read in commands from a text file into an array and i just can't do it. I am trying to use the line filein>>patternarray; and it doesn't work! can anyone help me? Cheers
1
by: PerlNewbie308 | last post by:
Hi, I'm currently writing a perl script and it's my first time doing this. So I'm not sure why I can't seem to write to the same file that I am reading. I read somewhere that I cannot read and...
0
by: berky | last post by:
I have commented my code with what I think every line of my Q does. logically it should be working. Saddly I get one compiling error and when I debug it out, I find that I get a null exception...
1
by: waqasahmed996 | last post by:
Hi can i read a pdf file in PHP? if yes how can we do that. is there any installation is required? how can we check that required library is installed on server or not. I am very thankful to you if...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.