# Barcode scanner app

**URL:** <https://www.ruby-forum.com/t/barcode-scanner-app/115088>\
**Category:** Ruby\
**Created:** [September 20, 2007, 2:42pm UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088 "2007-09-20T14:42:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pieterjongsma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@pieterjongsma](https://www.ruby-forum.com/u/pieterjongsma)\
**Post date:** [September 20, 2007, 2:42pm UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088/1 "2007-09-20T14:42:10Z")

</div>

Hi,

I need to program an application for my school. It needs to scan a  
barcode on a pass, compare it to a database and then display a color  
(fullscreen) signalling if the student is or isn’t allowed at a party.

Now I’m looking for a toolkit of some sort to wait for a signal from the  
barcode scanner (which works just like a keyboard) and then display a  
fullscreen signalcolor. Any ideas?

Thanks in advance,  
pieter.

---

<div class="post-metadata">

**Author:** ![pieterjongsma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@pieterjongsma](https://www.ruby-forum.com/u/pieterjongsma)\
**Post date:** [September 20, 2007, 3:20pm UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088/2 "2007-09-20T15:20:19Z")

</div>

On Thu, Sep 20, 2007 at 09:42:11PM +0900, Pieter J. wrote:

> I need to program an application for my school. It needs to scan a  
> barcode on a pass, compare it to a database and then display a color  
> (fullscreen) signalling if the student is or isn’t allowed at a party.
> 
> Now I’m looking for a toolkit of some sort to wait for a signal from the  
> barcode scanner (which works just like a keyboard) and then display a  
> fullscreen signalcolor. Any ideas?

I’m a dork, so I’d probably use GLUT/OpenGL. It’s overkill, but it’s  
damned  
easy to get a fullscreen color and to accept keyboard input.

> Thanks in advance,  
> pieter.  
> –Greg

---

<div class="post-metadata">

**Author:** ![pieterjongsma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@pieterjongsma](https://www.ruby-forum.com/u/pieterjongsma)\
**Post date:** [September 20, 2007, 3:45pm UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088/3 "2007-09-20T15:45:27Z")

</div>

> I need to program an application for my school. It needs to scan a  
> barcode on a pass, compare it to a database and then display a color  
> (fullscreen) signalling if the student is or isn’t allowed at a party.

> Now I’m looking for a toolkit of some sort to wait for a signal from the  
> barcode scanner (which works just like a keyboard) and then display a  
> fullscreen signalcolor. Any ideas?

If it works just like a keyboard, you should be able to get the input  
with gets(). If your scanner dies or something happens, you then have  
a fallback mechanism as well.

Depending on how fancy the display solution should be, you could  
display yes/no in colored ascii (easiest solution), write some html  
that’s loaded in a browser that keeps refreshing, or use a GUI toolkit  
(tcl/tk, gtk, qt, etc.) to display the result. If you use a GUI, you’d  
probably want to replace the gets() call with a text field that has an  
on\_change() or equivalent trigger.

Sounds like a fun project, good luck!

Wes

---

<div class="post-metadata">

**Author:** ![pieterjongsma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@pieterjongsma](https://www.ruby-forum.com/u/pieterjongsma)\
**Post date:** [September 20, 2007, 4:44pm UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088/4 "2007-09-20T16:44:42Z")

</div>

On Thu, 20 Sep 2007, Pieter J. wrote:

> Now I’m looking for a toolkit of some sort to wait for a signal from the  
> barcode scanner (which works just like a keyboard) and then display a  
> fullscreen signalcolor. Any ideas?

I suggest you take a look at the ncurses library.

– Matt  
It’s not what I know that counts.  
It’s what I can remember in time to use.

---

<div class="post-metadata">

**Author:** ![pieterjongsma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@pieterjongsma](https://www.ruby-forum.com/u/pieterjongsma)\
**Post date:** [September 20, 2007, 8:41pm UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088/5 "2007-09-20T20:41:22Z")

</div>

Pieter J. wrote:

> Thanks in advance,  
> pieter.  
> if it acts like keyboard, try ruby/SDL it’s simplest solution to get  
> graphics in application.

---

<div class="post-metadata">

**Author:** ![pieterjongsma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@pieterjongsma](https://www.ruby-forum.com/u/pieterjongsma)\
**Post date:** [September 21, 2007, 6:32am UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088/6 "2007-09-21T06:32:39Z")

</div>

On Sep 20, 2007, at 1:40 PM, Marcin R. wrote:

> > Thanks in advance,  
> > pieter.  
> > if it acts like keyboard, try ruby/SDL it’s simplest solution to  
> > get graphics in application.

You could use Gosu easily, the game library for the graphics, very  
very easy. Some kb/gamepad input is already defined, but you could  
easily ‘include’ anything needed for the scanner.  
Thing to note, game libraries are not just useful for games! They  
make simple GUIs easy to build!  
If the scanner has a driver with API you should be able to pass its  
info to any app as you please.

Another alternative would be to do something like a local machine  
Rails app. There’s easy database integration and a web-browser based  
GUI.

---

<div class="post-metadata">

**Author:** ![pieterjongsma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@pieterjongsma](https://www.ruby-forum.com/u/pieterjongsma)\
**Post date:** [September 21, 2007, 7:25am UTC](https://www.ruby-forum.com/t/barcode-scanner-app/115088/7 "2007-09-21T07:25:23Z")

</div>

John J. wrote:

> Another alternative would be to do something like a local machine  
> Rails app. There’s easy database integration and a web-browser based  
> GUI.

I have been thinking about that. But the program needs to be portable,  
by which I mean it needs to run on any computer without having to  
install things like rails.  
I also have a server at my disposal, on which I could run it, but that  
server is really slow…

I was actually wondering if there was anything like PyGame for ruby, and  
I guess ‘Gosu’ is it.

Thanks for the tip!
