Liberty BASIC Community Forum
« stylebits »

Welcome Guest. Please Login or Register.
Mar 29th, 2017, 04:17am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: stylebits  (Read 184 times)
Mystic
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 97
xx stylebits
« Thread started on: Jun 16th, 2016, 12:11pm »

Oops, thought I was entering in a search. smiley

Well, now that I have created this message, here's what I am doing.

I am working with a barcode scanner and I need my program to do something once it receives "Enter" from the keyboard.

Reason? When the barcode scanner scans the barcode it basically sends the equivalent of the keyboard "ENTER" key.

The plan is, when I scan a barcode it will go and search my database for that item. I don't want my users to have to hit enter I just want I to automagically do the search once the scan has been done.
« Last Edit: Jun 16th, 2016, 12:14pm by Mystic » User IP Logged

- Rick
Programming BASIC since the 80's starting with a TRS-80.
Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14909
xx Re: stylebits
« Reply #1 on: Jun 16th, 2016, 12:44pm »

The API SendInput might work. I don't understand exactly what you need.

Quote:
SendInput function
Synthesizes keystrokes, mouse motions, and button clicks.
« Last Edit: Jun 16th, 2016, 12:46pm by Alyce Watson » User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2251
xx Re: stylebits
« Reply #2 on: Jun 16th, 2016, 12:56pm »

There's a couple ways you can achieve this, I believe.

If you open your window as a dialog window(open 'title" for dialog), you can use STYLEBITS to add the BS_DEFPUSHBUTTON style to one of the buttons on the window. When the ENTER key is pressed, that button will be "clicked".

Another way is to have a timing loop in your program use the GetKeyState() API to check if the ENTER key is pressed.
User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14909
xx Re: stylebits
« Reply #3 on: Jun 16th, 2016, 12:58pm »

Are you looking for stylebits that will help? That is your subject. Color me confused.
User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14909
xx Re: stylebits
« Reply #4 on: Jun 16th, 2016, 1:01pm »

on Jun 16th, 2016, 12:56pm, Chris Iverson wrote:
There's a couple ways you can achieve this, I believe.

If you open your window as a dialog window(open 'title" for dialog), you can use STYLEBITS to add the BS_DEFPUSHBUTTON style to one of the buttons on the window. When the ENTER key is pressed, that button will be "clicked".

Another way is to have a timing loop in your program use the GetKeyState() API to check if the ENTER key is pressed.


He states that he doesn't want the user to need to press enter.

Perhaps the sequence of events in the program would clarify.
User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5216
xx Re: stylebits
« Reply #5 on: Jun 16th, 2016, 1:32pm »

The barcode scanner reads a barcode and when it gets a complete code it sends it to the application as a sequence of keystrokes followed by enter. So it just looks like a keyboard entry. There is an embedded check digit at the end of the sequence, just ahead of the enter character.

So not style bits, just how to receive and parse check a textbox entry initiated with ENTER.
« Last Edit: Jun 16th, 2016, 1:34pm by Rod » User IP Logged

Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2251
xx Re: stylebits
« Reply #6 on: Jun 16th, 2016, 1:34pm »

on Jun 16th, 2016, 1:01pm, Alyce Watson wrote:
He states that he doesn't want the user to need to press enter.

Perhaps the sequence of events in the program would clarify.


The user wouldn't have to. Most barcode scanners appear to be normal keyboards to the computer, and just "type" the numbers they scan, followed by sending an "enter" keycode.

If you set your program up to just respond to the ENTER key, it should respond to a barcode scanner that does this the same way.


Many computer-based magstripe readers(credit card readers) behave the same way. I remember seeing a chat log from someone that found a USB magstripe reader during a chat, and wondered if this was the case. He swiped a credit card, and accidentally typed the entire card number and details to the chatroom.
« Last Edit: Jun 16th, 2016, 1:37pm by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Mystic
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 97
xx Re: stylebits
« Reply #7 on: Jun 16th, 2016, 1:36pm »

The "Stylebits" title was because I thought I was searching for that term and it entered a message instead.

In short, I messed up. Could not change the title, so I just modified the blank post and asked my question. smiley

I was thinking stylebits might be the answer.

Here's the process I am hoping to achieve.

1. set focus to a textbox in a window.
2. scan a barcode (which is the equivalent of just entering info into the textbox and hitting enter).
3. After ENTER is pressed (or the barcode scanned in this case), the program searches the database for what was entered.

In other words, enter text in a textbox, and when you hit ENTER the program goes to a branch to do something. I don't want the user to have to click a button or anything after entering the information.

Hopefully that made better sense...
User IP Logged

- Rick
Programming BASIC since the 80's starting with a TRS-80.
Mystic
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 97
xx Re: stylebits
« Reply #8 on: Jun 16th, 2016, 1:40pm »

The light bulb just came on!

I can just use INPUT instead of a TEXTBOX. Duh!

Think I have it figured out now. If I can do the same thing with a TEXTBOX I'd like to know that too!

Here's my REALLY SIMPLISTIC scanner test so you can see what I am trying to do.

Code:
[top]
INPUT "Enter something "; something$
IF something$ = "C1687853" THEN
    PRINT "Found it!"
    END
END IF
PRINT "Try again"
GOTO [top]
 
« Last Edit: Jun 16th, 2016, 1:47pm by Mystic » User IP Logged

- Rick
Programming BASIC since the 80's starting with a TRS-80.
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2251
xx Re: stylebits
« Reply #9 on: Jun 16th, 2016, 2:17pm »

Try this. (The button is necessary, to respond to ENTER.)

Code:
nomainwin
textbox #m.tb, 10, 10, 100, 25
button #m.default, "Enter", [enter], UL, 110, 10, 50, 25
open "Enter test" for dialog as #m
#m, "trapclose [quit]"
wait

[quit]
close #m
end

[enter]
#m.tb, "!contents? var$"
If var$ = "C1687853" then notice "Found it!"
wait 
User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Mystic
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 97
xx Re: stylebits
« Reply #10 on: Jun 16th, 2016, 3:47pm »

THANK YOU Chris! Very helpful!

I tweaked it a bit to work exactly how I need it to function, and commented out the NOMAINWIN so I could see what was going on in the background while troubleshooting.

Just left the code like that so if someone else wanted to play with it and "see" what I did they could.

This now works "basically" how the main program will now operate.

When I get done it will scan an item, check if it's currently in the database. If it is, the checkin/checkout window will open with the item data in it.

If it can't find the item, the window for adding a new item to the database will open.

Thanks to all for the assist and being my sounding board.

Code:
'nomainwin
textbox #m.tb, 10, 10, 100, 25
button #m.default, "Enter", [enter], UL, 110, 10, 50, 25
open "Enter test" for dialog as #m
#m, "trapclose [quit]"
wait

[quit]
close #m
end

[enter]
#m.tb, "!contents? var$"
PRINT "Contents of var$ = " + var$
If var$ = "C1687853" then notice "Found it! " + var$
var$ = ""
PRINT #m.tb, ""
PRINT "Exit " + var$
PRINT #m.tb, "!SETFOCUS"
wait 
 
User IP Logged

- Rick
Programming BASIC since the 80's starting with a TRS-80.
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls