Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 11 of 25

Attended Workstations (Catalog Nos. 2708-DH5B2L & -DH5B4L) (Series B) User Manual: 9 - What is BASIC?

Pages 85 to 92 of 186, from Attended Workstations (Catalog Nos. 2708-DH5B2L & -DH5B4L) (Series B) User Manual

The original document is the PDF (513 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Allen-Bradley 2708

Page 85

Chapter

A–B

9

What is BASIC? Introduction

The acronym “BASIC” stands for “Beginner’s All-purpose Symbolic Instruction Code”. It was designed as a programming language for novice programmers in the early 60’s. In the 90’s, BASIC still ranks as one of the most popular programming languages. BASIC is used as a workstation programming language for several reasons: 1. its ease of use 2. its wide-spread popularity 3. its structure and versatility

What is Visual BASIC ?

Almost no one is using the original ANSI standard BASIC any more. The language only allowed 26 variables, had no string capability, and was very simplistic. Visual BASIC is a product of Microsoft Corporation which expands greatly on the original language, and provides an integrated development environment containing a BASIC program editor, a BASIC compiler with a vast array of statements, and a debugging platform. The Visual BASIC program editor checks each line of the program for syntactical errors as they are entered. It has all the functions normally found in program editors and is designed to interact with the compiler and debugger. It facilitates the separation of functions and subroutines into easy-to-read pages, and has full search and replace facilities. The Visual BASIC program compiler can be invoked from inside the editor, or from the DOS command line. Once an error is found, the compiler returns control to the editor on the line with the mistake so that changes can be made to correct the problem. When the program is compiled successfully, it can be run either from inside the debugger, or from the DOS command line. If a run-time error is encountered, the screen returns to the editor at the line containing the error. In the event the program fails to do what was planned, the program debugger can be used to track down any logical problems. These tools are essential for programmers at any level. We highly recommend that you make use of Microsoft’s Visual BASIC to develop application programs for the workstations.

9–1

Page 86

Chapter 9 What is BASIC ?

What is A-B VBASIC?

A-B VBASIC is a subset of Microsoft’s Visual BASIC, consisting of those commands which are relevant in the workstation environment. A-B VBASIC includes a set of Special Devices which allows access to things like bar code scanners. Many commands which would be appropriate in a PC environment, but are not applicable on a workstation, such as color, graphics, and disk commands have been left out. A-B VBASIC provides the user with a near-industry-standard programming language which is powerful enough to handle any application, yet easy to learn. Additional reference resources for learning about Visual BASIC and A-B VBASIC are: Learning to Use Microsoft Visual BASIC – by Microsoft Programming in BASIC – by Microsoft Basic Language Reference – by Microsoft Note: These publications are provided with the Application Generator Software (Catalog No. 2708-NAG) and the BASIC Language Development Kit (Catalog No. 2708-NBD). Together, they provide all the information needed by a programmer with some BASIC experience. However, none of the books can be considered a tutorial on the BASIC language. Check your local library, the computer section of your local bookstore or a computer dealer near you for beginner BASIC books. Most programmers have programmed in BASIC or a similar language and will have little trouble converting to A-B VBASIC.

9–2

Page 87

Chapter

A–B

10

Developing and Running an A-B VBASIC Program The A-B VBASIC Development Procedure

Step #1 – Planning The 2708-DH5B2L and -DH5B4L workstations have approximately 79K bytes dedicated for program memory. Programs that are larger than about 20-30 pages of BASIC source code need to be broken up into several smaller CHAINed programs. It is much easier to plan for this in the design stage than to be forced into it in the coding stage. For smaller applications (applications that can be coded in 20-30 pages of source or less) there is no need to worry about the CHAIN statement. By far the majority of applications fall into this category. Step #2 – Coding with the Workstation Application Generator Software For many data collection programs, a software development tool called the Application Generator Software (Catalog No. 2708-NAG) may be all you need to implement your application. Application Generator Software is extremely useful in the development of applications, prototyping applications with an end-user, and creating demonstration programs quickly. Application Generator Software requires very little learning curve. It allows the program to be simulated on the PC, which helps in the testing and debugging of the program, and outputs a syntactically correct A-B VBASIC source program as a “.BAS” file, which can then be compiled as described later. Step #3 (Alternate) – Coding with Visual BASIC Editor If you do not use Application Generator Software, we recommend that you enter your A-B VBASIC programs using the Visual BASIC editor. This provides syntax checking, subroutine and function menus, and liberal help screens. Since A-B VBASIC is a subset of Visual BASIC, you can enter any A-B VBASIC commands with the editor. Note: When using the Visual BASIC programming environment, be sure to save your A-B VBASIC program file in ASCII text format rather than the compact format. (Use the SAVE AS option in the Visual BASIC editor.) Step #4 – Simulation Using Application Library A design goal for A-B VBASIC was to have the workstation behave like a PC when running the same code. Since the PC and workstation act the same, the ideal place to test the subroutines of your application is right on the PC itself in the Visual BASIC environment.

10–1

Page 88

Chapter 10 Developing and Running an A-B VBASIC Program

The A-B VBASIC Development Procedure (cont’d)

In order to emulate programs on a PC the A-B Application Library was developed (see Chapter 13). Many basic I/O routines for the various devices found on a workstation are available through this library. These include inputs from barcode scanners, timeouts, formatted and edited keypad read routines, data conversion routine, etc. One of the clear benefits of using the library is that you don’t have to “re-invent the wheel”. There are two main files in the Application Library: ENV.BAS and ENVPC.BAS. When testing your program on a PC, just include ENVPC.BAS into your program, and all your I/O will be directed at standard PC devices which will emulate the workstation. When it’s time to run the program on the real workstation, simply substitute ENV.BAS at compile time. Step #5 – Compiling the A-B VBASIC Program After the program has been written and tested on the PC using ENVPC or Application Generator Software, the program must be converted into a form that a workstation can understand. This is done with the A-B VBASIC cross compiler (LXB). LXB will flag any lines that do not fit the subset of allowed commands. It will also flag syntactical errors, but those will normally already have been taken care of by the Visual BASIC editor. The output of the LXB compiler is a “.LXE” file, suitable for downloading to a workstation. Step #6 – Downloading You can download the program with another software product called Network Manager Software (Catalog No. 2708-NNM). Network Manager Software is a data collection and network management program which can collect data, download programs and files, and perform network management functions. It is the preferred tool for commmunicating between a PC and a workstation network. It interprets network status records and provides repetitive command transmissions to multiple workstations. However, in the absence of Network Manager Software, any asynchronous terminal emulator that has a file transfer feature and honors XON/XOFF protocol should work. As soon as the download is complete, the program automatically starts running. At this point the program can be tested for proper functioning on the workstation itself. To summarize, the steps in developing an application for a workstation are as follows: 1. Lay out a structured design for application 2. Decide if application is small or large (is CHAINing necessary?) 3. Use developed tools wherever possible (BASIC Language Development Kit) 4. Code the application using the Visual BASIC editor or Application Generator Software 5. Test the program under simulation (include ENVPC.BAS) 6. Compile with LXB (include ENV.BAS) 7. Download the program 8. Test the program on the target workstation

10–2

Page 89

Chapter 10 Developing and Running an A-B VBASIC Program

Loading and Auto-Starting an A-B VBASIC Program

The .LXE “download” file produced the the A-B VBASIC cross-compiler must be transmitted, through the Master Workstation, to the target workstation. This transmission must honor whatever protocol has been chosen for Host-Master communication in the Setup menus on the workstation: XON/XOFF, Polled Mode, Request Response, or whatever other method is enabled. In particular, the following will NOT WORK: COPY PGM.LXE COM1 This WON’T WORK, since the standard DOS communication drivers do not implement XON/XOFF. Downloading a BASIC program in .LXE format will terminate any program in progress at the start of the downloading process. Successful completion of a download results in the initiation of the new program. However, a program that is in .PGM format (described in Chapter 11) can be downloaded into RAM without interrupting the currently running program. The .PGM format program can later be executed by calling it with a CHAIN statement.

Start-up Condition of an A-B VBASIC Program

This section summarizes the status of the workstation when a program starts. LCD: The front panel display may be thought of as being blank. The first character output will appear in the upper left corner of the display. The cursor is on. The words “BASIC START” are placed on the display by the operating system before the BASIC program is initiated. If this text is visible long enough to be noticed, the probable cause is a BASIC program which has not yet reached a PRINT statement. Random numbers: The random number seed is set to 1. RAM files: All files are closed but their contents, if any, remain unchanged. Variables: Are 0 or null string per Visual BASIC defaults. Host device: The Host device is closed and therefore any data collected by the workstation and queued is held until an OPEN “Host” command is encountered.

10–3

Page 90

Chapter 10 Developing and Running an A-B VBASIC Program

Loading and Auto-Starting an A-B VBASIC Program (cont’d)

Prefix digits 9 and 10 of the network record: are 01. (See Chapter 8 on responses to Network Directives.) Manual Intervention in an A-B VBASIC program: In a normal production use of a workstation, the application program remains running continuously. Consequently, only limited facilities are supported for manual intervention. Sending an > > A command to the terminal will abort any A-B VBASIC program in progress and generate the “operator abort” BASIC ERROR message. For more information on commands, refer to Chapter 8. The > > G command will restart a terminated A-B VBASIC program. It is ignored if the program is already running. Note: The program will restart at the beginning not at the point of termination.

Termination of an A-B VBASIC Program

The following are reasons for the absence of a running A-B VBASIC program: 1. The download of a .LXE file was never started, never completed, or resulted in an error. The load status display (number 7) should be consulted (refer to Chapter 4). 2. The program was started but terminated voluntarily by executing an EXIT, STOP, or SYSTEM statement, or by “reaching the bottom”. We suggest that if you allow a program to terminate itself, you leave a descriptive message on the application status display (number 9) before termination. (See the STAT device later in this manual.) 3. A running program is automatically terminated when any record of a download (.LXE) file is received. This results in the BASIC ERROR “New Program Load”, which means “Program aborted due to a new download”. 4. The program was aborted by the operator using > > A. 5. Power failure. 6. A runtime error occurred.

10–4

Page 91

Chapter 10 Developing and Running an A-B VBASIC Program

A-B VBASIC Run-Time Errors

All errors encountered by the A-B VBASIC pseudo-code interpreter are serious enough to result in the termination of the application program. Program termination results in the following: 1. A return to the display of workstation status information (10 operator-selectable status displays discussed in Chapter 4. 2. An error message is sent through the network to the Host which begins with the words “BASIC ERROR”. 3. The error message is also available on the BASIC run-time status display (number 8), and through the read-only menu. 4. The diagnostic command < E will return the error message on demand (refer to Chapter 8). 5. The error flag E is posted over the 8 on the summary status display (number 0). Format of a BASIC Error Message The format of a BASIC run-time error message is: text offset date time where “text” is an explanation of the error, and “offset” is the displacement from the start of the program’s pseudo code of the pseudo-instruction which was unable to complete. The corresponding BASIC statement can be found by correlating this value with the offset information provided in the program listing (.LST File) from LXB. The following chapter discusses how to get a listing file from LXB. “date time” is the date and time the error occurred in the same form returned by the DATE$ and TIME$ functions. Example: 0101000600BASIC ERROR: New Program Load 054B: 9102281345 Runtime error messages presented to the Host computer are preceded with the customary 10 digit prefix, digits 9 and 10 of which are 00, followed by BASIC ERROR (refer to Chapter 8).

10–5

Page 92

Chapter 10 Developing and Running an A-B VBASIC Program

Power Failure

Circuitry within a workstation is capable of detecting and reporting to the processor an imminent loss of power. When this occurs, all tasks are brought to a logical conclusion and the following message: POWERFAIL SHUTDOWN!

is sent to the LCD. Normally, this message will never be seen because a true power failure will blank the display. Its viability for any perceptible length of time is evidence of a power failure which was not quite long enough to completely turn off the workstation, or a workstation overly sensitive to power fluctuations. The restoration of power results in this environment for the A-B VBASIC program: 1. The program is restarted FROM THE BEGINNING. 2. All files (RAM FILES) in existence at power failure are intact, although closed. Any write operation (a single PUT, etc.) to a file of a length under 4K bytes which was in progress when the power failure occurred, either did or did not complete AS A UNIT. Stated differently, record fragments are not present, only whole records. 3. All others program parameters are reset as for any other program initiation: variables 0, etc. Programs wishing to distinguish between initial (cold) start-up and powerfail restart (warm), should open a file named, say, POWER. If the LOF function on POWER returns 0, assume a cold start and PUT something into the file. A non-zero file length implies a warm start.

10–6