scanner

How to parse a tab-separated line of text in Ruby?

I find Ruby's each function a bit confusing. If I have a line of text, an each loop will give me every space-delimited word rather than each individual character. So what's the best way of retrieving sections of the string which are delimited by a tab character. At the moment I have: line.split.each do |word| ... end but that is not ...

Reading a barcode using a USB barcode scanner along with ignoring keyboard data input while scanner product id and vendor id are not known.

Is there a way to read from a USB barcode reader while ignoring the keyboard and not knowing the PID or VID of the USB scanner? I know that there is a way of differentiating between USB scanner input and keyboard input by using the VID and or PID of the USB scanner; this was done using code from http://nicholas.piasecki.name/blog/2009/02...

Have you ever effectively used lexer/parser in real world application?

Recently, I am started learning Antlr. And knew that lexer/parser together could be used in construction of programming languages. Other than DSL & programming languages, Have you ever directly or in-directly used lexer/parser tools (and knowledge) to solve real world problem? is it possible to solve the same problem by an average progr...

How to Alter Photographed Document to Look "Scanned"

How can I do this in Python/PIL? I.e., given the four points of an offset rectangle (a photographed document), make it look flat on as if it were scanned. Is there a simple algorithm for it? Also, are there any other manipulations I should do to make it look more "scan-like"? I want to make a simple version of this program for myself ...

Bison does not appear to recognize C string literals appropriately

Hi Folks, My problem is that I am trying to run a problem that I coded using a flex-bison scanner-parser. What my program is supposed to do is take user input (in my case, queries for a database system I'm designing), lex and parse, and then execute the corresponding actions. What actually happens is that my parser code is not correctly...

Writing a cleaner and more modular command-parser

I'm writing a debugger for a Z80-emulator we are writing in a school project, using Java. The debugger reads a command from the user, executes it, reads another command, etc. Commands can either be argument less, have optional arguments, or take an unlimited amount of arguments. Arguments are mostly integers, but occasionally they're s...

Is there an equivalent to the Scanner class in C# for strings?

In Java I can pass a Scanner a string and then I can do handy things like, scanner.hasNext(), or scanner.nextInt(), scanner.nextDouble(), etc. This allows some pretty clean code for parsing a string that contains rows of numbers. How is this done in C# land? If you had a string that say had: "0 0 1 22 39 0 0 1 2 33 33" In Java I wou...

Java's Scanner vs String.split() vs StringTokenizer; which should I use?

I am currently using split() to scan through a file where each line has number of strings delimited by '~'. I read somewhere that Scanner could do a better job with a long file, performance-wise, so I thought about checking it out. My question is: Would I have to create two instances of Scanner? That is, one to read a line and another ...

[Java] use of delimiter function from scanner for "abc-def"

Hi! I'm currently trying to filter a text-file which contains words that are separated with a "-". I want to count the words. scanner.useDelimiter(("[.,:;()?!\" \t\n\r]+")); The problem which occurs simply is: words that contain a "-" will get separated and counted for being two words. So just escaping with \- isn't the solution of c...

read a file using Scanner: Why am I getting an error when using Scanner for read files in java ?

This example demonstrates using Scanner to read a file line by line (it does not perform a write operation) I don't know why I get an error when I try to compile. Could somebody explain the reason to me?. I'm using jcreatorLE and JDK 1.6 to run my program: import java.io.*; import java.util.Scanner; public final class File_read { pu...

Reading text with Java Scanner next(Pattern pattern)

I am trying to use the Scanner class to read a line using the next(Pattern pattern) method to capture the text before the colon and then after the colon so that s1 = textbeforecolon and s2 = textaftercolon. The line looks like this: something:somethingelse ...

How do I set the DPI of a scan using TWAIN in C++

I am using TWAIN in C++ and I am trying to set the DPI manually so that a user is not displayed with the scan dialog but instead the page just scans with set defaults and is stored for them. I need to set the DPI manually but I can not seem to get it to work. I have tried setting the capability using the ICAP_XRESOLUTION and the ICAP_YRE...

Are there Virtual Twain Scanners? Sort like Daemon Tools virtual CD

Hello, I am testing a scanning application and currently I dont have any scanner to plug it in. Is there anyway to have a virtual scanner like Daemon Tools does with Virtual CD Drives? ...

Can I use Scanner class in text file for getting information??

this code is correct?? String note = "text.txt"; FileWriter file = new FileWriter(note); Scanner sc = new Scanner(System.in); System.out.println("Enter your name:"); String name = sc.next(); file.close(); How can I pass this file to the program as a command line argument??? ...

Using Scanner.next() to get text input

Hi, I am trying to get text input from the keyboard in Java 6. I am new to the language and whenever i run the following code, I get this error: package test1; import java.util.Scanner; public class Test { public static void main(String[] args) { boolean quit = false; while (!quit){ Scanner keyIn; String c = "x"; while (c != "y...

Scanning notification through WIA

I've registered to receive WIA notifications for all devices through RegisterEventCallbackInterface for WIA_EVENT_DEVICE_CONNECTED and WIA_EVENT_SCAN_IMAGE events. However I only receive notifications when scanner device is plugged in - I don't receive notification when I scan (for example with mspaint which uses WIA). Am I supposed to r...

DFA based regular expression matching - how to get all matches!

Hi! I have a given DFA that represent a regular expression. I want to match the DFA against an input stream and get all possible matches back, not only the lestmost-longest match. For example: regex: a*ba|baa input: aaaaabaaababbabbbaa result: aaaaaba aaba ba baa Sorry for my English! Thanks for your help! ...

Problem with matching token in a line, using Scanner in Java

Hello, I need to match certain things from lines of an input text. The lines look like this: to be/ Σ _ Σ [1pos, 1neg] {0=1, 2=1} I am using the Scanner class to read each line of the text, and I have written the following code. However, something is not working properly, because the patter "to" is not matched against the line, and...

java console menu

I'm writing a java console menu. however, my jre doesn't support "Scanner". What is the walk around to this problem? java.util.Scanner scanner = new Scanner (System.in); ...

php script to acquire an image from a Twain source (scanner)

i look a script that do this , that can acquire an image from scanner and upload it to server i work in LAMP environment . i know this company: http://www.chestysoft.com/ximage/twainupload.asp Does anyone know free script (activeX) ? Does anyone use a similar script ? ...