Device: keypad, Device: lcd display (cont’d) device: keypad – Rockwell Automation 2708-NBD VBASIC Language Development Kit User Manual

Page 24

Advertising
background image

Chapter 4

Special Devices in A-B VBASIC

4–3

Note: See the description of PRINT USING and WRITE for details on other
formatting options supported.

See also the READ.BAS collection of BASIC Language Development Kit
subroutines for useful LCD output subroutines, including automatic
formatting of display lines, automatic clearing of the display, and cursor
positioning.

CLS
Name$ = “Fred”
PRINT “Please Enter Now!”
PRINT “Thank You”; Name$; ‘ Keep cursor on second line.

CONST ScreenDev = 1
OPEN “LCD” FOR OUTPUT AS #ScreenDev ‘ Cannot be CLOSEd
LineWidth% = LOF (ScreenDev) \ 2

‘ Width of display.

PRINT #ScreenDev, “Please Enter Code:”;

‘ Cursor remains on line.

LINE INPUT, Code$

Reserved device name: KEYS
These statements always access the Keypad:

INPUT$ (without a file number)
LINE INPUT (without a file number)
INKEY$

When a Keypad line is being entered with LINE INPUT, only the enter and
backspace keys perform the expected termination and correction functions.

As an alternative, INPUT$ and LINE INPUT can be used to access this
device using OPEN “KEYS”.

The BASIC Language Development Kit (Catalog No. 2708-NBD) modules
READ.BAS and MENU.BAS contain several helpful subroutines for
obtaining input through the Keypad.

CONST KeyDev = 1

‘ Assign device a file number

OPEN “KEYS” FOR INPUT AS #KeyDev

‘ Open device.

DO WHILE a$ = ” ”: a$ = INKEY$: LOOP ‘ Wait for a key stroke.
LINE INPUT “Enter your name: ”; Name$ ‘ Must press enter.
b$ – INPUT$ (1)

‘ Another way to get a key stroke.

Device: LCD Display
(cont’d)

Device: Keypad

Advertising