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 5 of 26

IRL Programming Reference Manual, pages 41 to 50

Pages 41 to 50 of 260

The original document is the PDF (666 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 Intermec 9445, Intermec 9550, Intermec 9560 and Intermec 9512

Page 41

Learning to Program in IRL

2

P"Enter Badge" A5 The program directs the reader to display the message Enter Badge and to accept only an alphanumeric badge number that is five characters long. The badge number is stored in register $0.

T The T command instructs the reader to note the time the badge number was entered and append the time to register $0.

R The R command moves the contents of register $0 (badge number and the time it was entered) to file 0 and clears $0.

.START The Label (.) command marks a place in the program to jump to when using conditional or unconditional branching statements. Label statements always begin with a period (.). This label marks the beginning of the START procedure. A procedure is simply a group of statements that work together to perform a specific task. The label helps the procedure standout in the program and provides a destination to branch to. The START procedure collects a part number input and checks to see if the input begins with an N. If it does, you move on to collecting the quantity of that part number. If it does not, you get an error message and begin again.

P"\e[2J" This P command instructs the reader to clear its display. The characters following the backslash (\) represent the hexadecimal values for the unprintable ASCII characters that control clearing the display. The hexadecimal values of all characters are listed in Appendix A, “ASCII Charts.”

P"Enter Part #" A The P and A commands direct the reader to display the prompt Enter Part # and to accept an ASCII string of any length. The length of the input does not matter because the program will test if the leading character of the part number is an N. The part number is stored in register $0.

2-15

Page 42

IRL Programming Reference Manual

D$1=$0L1 This D command copies the first character in register $0 to $1. According to the application requirements, a valid part number begins with the letter N. The IRL program checks to see that the first character of every part number you enter is an N. When you use the D command with string registers, you can copy the left, right, or middle characters. You can also use this command to combine string variables. When you use the D command with numeric registers or floating point registers, you can add, subtract, multiply, or divide.

G$1="N".QTY The G (Goto) command compares the contents of $1 to “N”. If register $1 contains an N, the program branches to the QTY label. If $1 does not contain an N, the program executes the next command statement. G (Goto) commands are conditional or unconditional: •

A conditional Goto, like G$1="N".QTY, will branch to the QTY label if the condition in the statement is true. Otherwise, the statement after the Goto is executed.

•

An unconditional Goto, like G.QTY, will always branch without performing a test.

When you branch to a label, the program continues executing statements in the order they occur. In this manual, a group of statements that begins with a label is called a procedure. A procedure is a group of statements that work together to perform a specific task. This is simply a naming convention. From a programming point of view, there is nothing special about a procedure. It is simply a name this manual uses for a section of a program that begins with a label and is not a subroutine. For more information, see Chapter 3, “Programming Techniques.”

B10101 The B (Beep) command emits a series of beeps through the reader’s speaker. In this case, the beeps signal that the number is not valid. A valid part number begins with an N. The reader beeps once for each digit (1 or 0) included in the B command. This command produces five beeps. The digits indicate the tone of each beep: 0 (zero) low beep 1 (one) high beep

2-16

Page 43

Learning to Program in IRL

2

P"Not a Part #" W The reader displays the message Not a Part #. The W (Wait) command defines the amount of time the reader pauses before the program executes the next command statement. If the W is not followed by a number, the program pauses for 1 second. Otherwise, the program pauses for the number of seconds defined (for example, W9 pauses for 9 seconds).

D$0="" Here the D command clears the contents of register $0 by defining $0 to contain no characters (null). It is necessary to delete the incorrect data from register $0 before attempting another input. Otherwise, future entries are simply appended to the erroneous entry.

G.START This command is an unconditional G (Goto) command that directs the program back to the START label. The START procedure checks if the part number you entered begins with N. If the number begins with N, the program leaves the START procedure and goes to the QTY label. If the number does not start with N, the program displays an error message and then unconditionally loops back to the START label to redisplay the prompt Enter Part #.

.QTY By this time, you should be familiar with all of the remaining commands in this program segment and be able to analyze what the .QTY procedure does. Briefly, the .QTY label is a bookmark for the QTY procedure and identifies its location in the program. The procedure adds a comma to the contents of register $0, clears the screen, prompts the user for a quantity (in the form of a numeric string), and stores this data in register $0. The procedure then transfers the data in register $0 to file 0 (using the R command) and clears $0. The procedure then directs the program back to the START label to begin the cycle of collecting part numbers and their respective quantities. The E (End) statement instructs the reader to end execution of the current program and start over at the beginning.

2-17

Page 44

IRL Programming Reference Manual

Sample Program Three Program Three is the most sophisticated program in this tutorial. In addition to collecting part numbers and quantities, the program checks to see how full the memory in the reader is getting, sends a warning when the memory is almost full, and automatically uploads to a host when full. In Program Three, you learn how to use these commands: O Open file S

Call subroutine

H File position C Convert V Universal input K Keyboard input Z Execute reader command Y Receive data X Transmit data Q Quit subroutine You also learn how to perform these tasks:

2-18

•

Use routines and subroutines in a program

•

Open files and then send data to a specific file

•

Calculate how many records have been collected and check to see how full the memory in the reader is

•

Set baud rate and communications protocol

•

Upload a file to a host computer

Page 45

Learning to Program in IRL

2

Understanding Program Three Program Three contains the following statements. Enter this IRL program on your reader or in PC-IRL using whatever method you choose: :Program Three OA(10,50) .START D$0="" P"\e[2J" P"Enter part #" P"or F1 to XMIT" A S$0="F1".XMIT G$0="F1".START

: create file A : START procedure : clear input register : clear screen : prompt user

: get input : F1 to transmit data : go to START after : XMIT D$1=$0L1 : otherwise look for N G$1="N".QTY : if N in register $1, : then collect qty B101011 : beep P"Not a Part #" : prompt user W : wait 1 second P"\e[2J" : clear display G.START : end of START procedure .QTY : QTY procedure I"," : append a comma to $0 P"\e[2J" : clear display P"Enter Qty" : prompt user N : get qty & append to $0 RA : store data from $0 in file A H#9=A : copy next record location : in file A to reg #9 GA(#9)>"".QUIT : if this record is not empty, then the : record pointer is at last record : and file A is full. Go to .QUIT G#9>6.WARN : 3 or less rec left, warn user G.START : end QTY, goto START .WARN : WARN procedure D#8=10-#9 : count records left C$1=#8 : convert number to string in $1 D$1="Only “ +$1 : building warning msg D$1=$1 + “ records left" P"\e[2J" : clear display P$1 : display warning msg B01010 : beep W2 : wait 2 seconds G.START : end WARN procedure, goto START .QUIT : QUIT procedure (file is full) P"Must Xmit NOW" : prompt user to transmit file B11111111111 : beep

2-19

Page 46

IRL Programming Reference Manual

S.XMIT G.START .XMIT P"\e[2J" P"Ready to XMIT" P"Press F1" P"when ready" VKB Z"$+PA1IA3$-" XMP,A HA=0 Q E

: call the XMIT subroutine : end QUIT procedure, goto START : XMIT subroutine : clear display : prompt user : keyboard input : set reader protocol to 1200 baud, : point-to-point : transmit file A : clear the contents of file A : end XMIT subroutine : end of program

Program Notes Remember that Program Two introduced the IRL programming technique of using the Label (.) command to begin a procedure. In Program Three, there are three procedures (.START, .QTY, .WARN) and one subroutine (.QUIT). This program checks the input to determine which procedure to execute. The program only executes the .QTY, .WARN, and .QUIT procedures when the conditional Goto statements are true. Notice that Program Three uses lots of comments to annotate program statements. Thorough comments can help you analyze a program written by someone else or remind yourself what your own program does. Program Three also introduces subroutines. A subroutine affects the order that IRL executes statements. An S (Call Subroutine) command branches to a subroutine, executes the subroutine commands, and then returns. When the program calls a subroutine with the S (Call Subroutine) command, the program sets a pointer to the next statement after the S command. Then, the program branches to the subroutine and executes the statements in the subroutine. When the program executes a Q command in the subroutine, the program returns to the statement after the S command and continues executing statements in order. Subroutines are an important advanced programming concept. Use subroutines to reduce the need to write the same statements over and over again. Place sequences of statements that are executed more than once in a program into a subroutine and call the subroutine as often as needed. Both the G command and the S command can be conditional or unconditional.

2-20

Page 47

Learning to Program in IRL

2

:Program Three Use a comment at the beginning of a program to name or describe the program.

OA(10,50) The O (Open) command opens a file, named from A to Z. This command executes when the program is compiled and all data previously collected is lost. The letter following the O is the name of the file to which data is sent. In Programs One and Two, all input was sent to file 0 (the default file) because no other file was opened. In this case, file A is opened. The numbers in parentheses define the number of records the file can hold (first number) and the maximum length in bytes of those records (second number). The ten records are numbered 0 to 9. In this case, file A holds up to ten records, and each record can be a maximum of 50 bytes long. Normally, a data file contains more than ten records, but for the purposes of this tutorial, fewer records make it easier to fill the reader’s memory and execute all the routines in the program.

.START D$0="" P"\e[2J" P"Enter Part #" P"or F1 to XMIT" A This is the beginning of the START procedure. START begins by deleting the contents of register $0, clearing the display, and displaying the message Enter Part # or F1 to XMIT on two lines. The program is ready to receive an alphanumeric part number of any length.

S$0="F1".XMIT The S (Call Subroutine) command tells the program to call the .XMIT subroutine if the F1 key is pressed, execute that routine, and then return to execute the statement directly following this one.

G$0="F1".START If register $0 contains F1, the program jumps back to the START label. If not, the program moves to the next statement. These S and G commands work together. If the reader successfully transmits data (the user pressed F1 to XMIT), the program instructs the reader to begin collecting part numbers (G$0="F1".START). If the user did not press F1, and the data is not transmitted, the program executes the next statement (D$1=$0L1).

2-21

Page 48

IRL Programming Reference Manual

D$1=$0L1 G$1="N".QTY B101011 P"Not a Part #" W P"\e[2J" G.START This series of statements should be familiar to you from Program Two. In review, the D command transfers the left character of register $0 to register $1. Then the G command checks to see if the contents of register $1 is an N. If so, the program branches to the QTY label. If not, the reader displays an error message and the user gets another chance to enter a part number (the program branches to START again).

.QTY I"," P"\e[2J" P"Enter Qty" N RA This is the beginning of the QTY procedure. It clears the display, inserts a comma (,) after the part number already stored in register $0, collects the quantity for that part number, and stores the quantity in register $0 too. The R (Record) command transfers the contents of register $0 to the next available record in file A.

H#9=A The H (File Position) command returns the next available write location in file A and puts this number into register #9. When the file is full, it still returns the last write location. Therefore, simply check for a value other than null to indicate a file full condition.

GA(#9)<>"".QUIT G#9>6.WARN G.START These three G commands set up three different branches depending on the next record location in register #9. The file is full when the last record is not a null record. (The last record is #9 because the ten records in File A are numbered 0 to 9.) The program branches to the QUIT label. If the next record location is greater than 6, it branches to the WARN label. If neither condition is met, there is room in memory for more data and the program branches to the START label again.

2-22

Page 49

Learning to Program in IRL

2

.WARN This is the beginning of the WARN procedure. It calculates how many records are left and informs the user.

D#8=10-#9 This D command deducts the number of records in register #9 from 10 to determine how many more records can be collected. The result is transferred to register #8. Remember that 10 was the limit set for records in the O (Open) command at the beginning of the program.

C$1=#8 The C (Convert) command converts the numeric data in numeric register to a string and stores the string in a string register $1. The value in the numeric register does not change. In this case, the numeric data in #8 is converted to a string and stored in $1. Data is manipulated differently in the two types of registers. In numeric registers, you can perform true mathematical operations. For example, when you perform addition in numeric registers, you get the sum of the numbers added: 100 + 10 = 110. When you perform addition in string registers, the characters are combined: 100 + 10 = 10010.

D$1="Only “ + $1 D$1=$1 + “ records left" These two D commands together build an error message that is stored in register $1. The message reads “Only n records left,” where n is the result of 10 - #9.

P"\e[2J" P$1 B01010 W2 G.START These statements clear the display screen and show the error message that is stored in register $1 for 2 seconds. The reader beeps a warning in a series of high and low tones, and the program branches to the START label again.

2-23

Page 50

IRL Programming Reference Manual

.QUIT P"Must Xmit NOW" B11111111111 S.XMIT G.START The QUIT procedure displays the message Must Xmit NOW on the reader and emits a series of high tones to warn the user. Next, the program executes the XMIT subroutine, and then finally branches back to the START label.

.XMIT P"\e[2J" P"Ready to XMIT" P"Press F1" P"when ready" The XMIT label marks the beginning of the XMIT subroutine. The subroutine begins by clearing the reader display and displaying the message Ready to XMIT. Press F1 when ready.

VKB The V (Universal Input) command tell the reader which source it can receive data from. In this case, the K modifier means accept keyboard input, and the B modifier tells the reader to beep after receiving valid input. Basically, this statement instructs the reader to wait for a key to be pressed before continuing on to the next statement.

Z"$+PA1IA3$-" The Z (Execute Reader Command) command tells the reader to execute the reader command between the quotation marks. In this case, the symbols $+ and $- enter and exit configuration mode, and PA1IA3 defines the communications protocol as point-to-point and sets the baud rate at 1200.

XMP,A The X (Transmit Data) command tells the reader to transmit data through the modem (M) port and to use the set protocol (P) when transmitting. The A in the statement tells the reader to transmit the contents of file A.

2-24