Transferring Text Files Between the IPC & HP-71: GVG / last revision 26 October 1986 + Those who want to transfer data from an HP-71 to an Integral PC (or the reverse) will be pleased to know that is now possible - through two BASIC programs written in collaboration between the Integral PC support team and the Hand-Held Computer support team, here in Corvallis. These programs will transfer any ASCII text file between the Integral and the HP-71. Text files transferred from the HP-71 to the Integral can be used by almost all of the UNIX utilities available for the IPC. HP-71 programs can be written on the Integral and transferred to the the HP-71. (Numeric data files on the HP-71 must be converted to ASCII text files before they are transferred to the IPC. Programs for performing this function are available on request from the Hand-Held Computer Support Team at 503-752-2004.) This article provides you with these two BASIC programs and instructs you in their use. + To perform the file transfers, you will need the following "ingredients": HP-71 HP-71 HP-IL interface HP-IL cables Integral PC IPC HP-IL interface IPC Tech BASIC The Integral's HP-IL card must be in one of the internal I/O slots; if you are using a bus expander, you will have to modify the program. + The Integral program is simple to use. First, type it into the interpreter (or write it using a text editor and then use the BASIC "GET" command to bring it into the interpreter). The Integral should have the HP-IL interface installed and be connected to an active HP-71. When you enter "RUN" into BASIC, the program will clear the screen and ask you for the name of the folder containing the BASIC HP-IL driver. Put the BASIC Utilities disc into the floppy drive, wait for the drive's light to go out, and then enter "hptb_u" into BASIC. (You could also put the "hpil.b." and "os_nam.5.0.0" files on a disc or directory of your choice and specify the appropriate directory name.) Next, the program will ask you which IPC directory you want to perform transfers with. (This is really just a convenience. You could just as well answer "/" and then specify full file pathnames for transfers.) Finally, the program will enter a command loop and ask you if you want to perform one of the following four operations: - Input a file from the HP-71. - Output a file to the HP-71. - Change the source / destination directory. - Exit the program. + For file input, you should go to the HP-71, run the HP-71's file-transfer program, and set it up to perform an output; when it asks you what file you want to transfer from the HP-71, ignore the prompt, and go back to the Integral and command it to perform an input. The IPC will ask for the name of the INTEGRAL file you want to load the HP-71 file INTO; when you give the program the file name, it will wait for the transfer. (Note that the Integral will NOT stop you from over-writing an existing file!) Now - go back to the HP-71 and give it the name of the HP-71 file you want to send to the IPC. The file will be transferred, and both the HP-71 and the Integral will list it during the transfer. After the transfer, both the Integral and the HP-71 will prompt for the next command. + For file output, command the Integral to perform an output; when the program asks for the name of the Integral file you want to transfer, ignore the prompt, and go the HP-71 and command it to perform an input. The HP-71 will ask for the name of the HP-71 file you want to load the Integral file into; give it the file name, and the HP-71 will wait for the transfer. (Note that the HP-71 will challenge you if you try to over-write an existing file.) Now go back to the Integral and give it the file name of the Integral file you want to transfer. The file will be transferred, and both the HP-71 and the Integral will list the file as it is transferred. After the transfer, both the Integral and the HP-71 will prompt for the next command. Note that the Integral NEVER asks for the name of an HP-71 file and the HP-71 NEVER asks for the name of an Integral file. Note also that if there is a transfer failure, you will probably have to start from the beginning again - due to time restrictions we did not incorporate many recovery features into the programs. + If you command the Integral to change the source / destination directory, it will prompt you for the new directory name. Again, this is just a convenience; you can read or store any file using its full pathname. If you exit the program, it will print a farewell message and clear the screen. + The HP-71 program is simpler - it does not require installing a driver and has three commands (not four): input, output, and exit. Simply enter the program and operate it as indicated on the previous pages. The Integral program is listed below, and the HP-71 program follows it. 10 ! ------------------------------------------------------------------------- 20 ! 30 ! A Program to Transfer 40 ! ASCII Files Between the IPC and HP-71. 50 ! 60 ! ------------------------------------------------------------------------- 70 ! 80 ! Declare variables. 90 ! 100 DIM string_buffer$[120] 110 ! 120 ! Initialize the HP-IL interface. 130 ! 140 CLEAR 150 ASSIGN 9 TO "*" ! Close any current interface. 160 ! 170 Ask_For_Driver: 180 DISP "What folder contains the hpil driver"; 190 INPUT string_buffer$ 200 IF string_buffer$="" THEN Ask_For_Driver 210 ! 220 MASS STORAGE IS string_buffer$ 230 DISP 240 DISP "Now loading driver." 250 DISP 260 ! 270 ON ERROR GOTO Try_Other_Port 280 ASSIGN 9 TO "hpil.a" 290 DISP "Loaded driver hpil.a." 300 GOTO Set_Up 310 ! 320 Try_Other_Port: 330 ON ERROR GOTO No_HPIL_Card 340 ASSIGN 9 TO "hpil.b" 350 DISP "Loaded driver hpil.b." 360 GOTO Set_Up 370 ! 380 No_HPIL_Card: 390 OFF ERROR 400 DISP 410 DISP "Can't initialize the HP-IL interface." 420 DISP 430 GOTO Exit_Program 440 ! 450 ! Set up target HP-UX directory. 460 ! 470 Set_Up: 480 OFF ERROR 490 DISP 491 ! 492 Get_Folder: 500 DISP "IPC source / destination folder"; 510 INPUT string_buffer$ 515 IF string_buffer$="" THEN Get_Folder 520 MASS STORAGE IS string_buffer$ 530 CLEAR 540 ! 550 ! Main command interpreter loop. 560 ! 570 Command_Loop: 580 DISP 590 DISP "Commands:" 600 DISP 610 DISP " I - Input a file from the HP-71." 620 DISP " O - Output a file to the HP-71." 630 DISP " C - Change IPC source / destination folder." 640 DISP " X - Exit the program." 650 DISP 660 ! 670 DISP "Command"; ! Get command. 680 INPUT string_buffer$ 690 CLEAR 700 string_buffer$=UPC$(string_buffer$) 710 ! 720 IF string_buffer$<>"I" THEN Test_For_Output_File 730 GOSUB Input_File 740 GOTO Command_Loop 750 ! 760 Test_For_Output_File: 770 IF string_buffer$<>"O" THEN Test_For_Change_Directory 780 GOSUB Output_File 790 GOTO Command_Loop 800 ! 810 Test_For_Change_Directory: 820 IF string_buffer$<>"C" THEN Test_For_Bad_Command 830 ! 840 Ask_For_Folder: 850 DISP "New folder name"; 860 INPUT string_buffer$ 870 IF string_buffer$="" THEN Ask_For_Folder 880 MASS STORAGE IS string_buffer$ 890 GOTO Command_Loop 900 ! 910 Test_For_Bad_Command: 920 IF string_buffer$="X" THEN Exit_Program 930 DISP "I don't recognize that command." 940 GOTO Command_Loop 950 ! 960 Exit_Program: 970 ASSIGN 9 TO "*" ! Close the HP-IL driver. 980 DISP "Happy trails ..." ! Leave the program. 990 WAIT 3000 1000 CLEAR 1010 END 1020 ! 1030 ! ----------------------------------------------------------------------- 1040 ! 1050 ! Input file from HP-71. 1060 ! 1070 ! ----------------------------------------------------------------------- 1080 ! 1090 Input_File: 1100 DISP "IPC destination file"; 1110 INPUT string_buffer$ ! Get IPC filename. 1120 IF string_buffer$="" THEN Input_File ! No filename, try again. 1130 ASSIGN 11 TO string_buffer$ ! Open the file. 1140 ! 1150 DISP 1160 DISP "Inputting ";string_buffer$;"..." 1170 DISP 1180 ! 1190 Get_Line: 1200 ENTER 901 ; string_buffer$ ! Read a line from interface. 1210 DISP string_buffer$ ! Display each line. 1220 IF string_buffer$="EOF" THEN End_Input ! End of file, punch out. 1230 OUTPUT 11 ; string_buffer$; ! Store in file. 1240 GOTO Get_Line ! Get next line. 1250 ! 1260 End_Input: 1270 ASSIGN 11 TO "*" ! Close file ... 1280 DISP ! ... and return. 1290 DISP "Input complete!" 1300 RETURN 1310 ! 1320 ! ----------------------------------------------------------------------- 1330 ! 1340 ! Output file to HP-71. 1350 ! 1360 ! ----------------------------------------------------------------------- 1370 ! 1380 Output_File: 1390 DISP "IPC source file"; 1400 INPUT string_buffer$ ! Get IPC filename. 1410 IF string_buffer$="" THEN Output_File ! No filename, try again. 1420 ASSIGN 11 TO string_buffer$ ! Open the file. 1430 ! 1440 DISP 1450 DISP "Outputting ";string_buffer$;"..." 1460 DISP 1470 ! 1480 ON ERROR GOTO Empty_File ! Check for empty file. 1490 ENTER 11 ; string_buffer$ ! Get a line from the file. 1500 OFF ERROR 1510 GOTO Send_Line ! Not empty, go on. 1520 ! 1530 Empty_File: 1540 DISP "No data in IPC source file." ! Empty, give error message ... 1550 ASSIGN 11 TO "*" 1560 RETURN ! ... and return. 1570 ! 1580 ! Send data to HP-71 1590 ! 1600 Send_Line: 1610 IF string_buffer$="" THEN string_buffer$=CHR$(13) 1620 OUTPUT 901 USING "K" ; string_buffer$ ! Send string to HP-71. 1630 DISP string_buffer$ ! Display it. 1640 ON ERROR GOTO End_Output ! Exit loop when file empty. 1650 ENTER 11 ; string_buffer$ ! Get string from file. 1660 OFF ERROR 1670 GOTO Send_Line ! Go back, send 2nd string. 1680 ! 1690 End_Output: 1700 OFF ERROR 1710 OFF TIMEOUT 9 1720 OUTPUT 901 USING "K" ; "EOF" ! Send end-of-file marker. 1730 DISP "EOF" ! What the heck, display it. 1740 ASSIGN 11 TO "*" ! Close the file. 1750 DISP 1760 DISP "Output complete!" ! All done ... 1770 RETURN ! ... go home. 10 ! ----------------------------------------------------------------------- 20 ! 30 ! A Program to Transfer ASCII Files 40 ! Between the HP-71 and the IPC. 5/15/86 50 ! 60 ! ----------------------------------------------------------------------- 70 ! 80 ! Initialize and declare variables. 90 ! 100 DESTROY A$,F$,K$,R$ 110 DIM A$[96] 120 ! 130 ! Initalize HP-IL , the HP-71 is displaying the info 140 ! being transferred, delay 0,0 is set to speed this process. 150 ! 160 RESTORE IO @ CONTROL OFF @ CFLAG -23 @ DELAY 0,0 170 ! 180 ! Determine type of transfer, branch to appropriate routine. 190 ! 200 'MAIN': DISP 'Input,Output,eXit' 210 'GETKEY': K$=UPRC$(KEY$) @ IF K$="" THEN 'GETKEY' 220 ON POS('IOX',K$)+1 GOTO 'main','INPUT','OUTPUT','EXIT' 230 ! 240 ! ******** INPUT FILE TO IPC ******** 250 ! 260 'INPUT': INPUT 'From IPC/ File: ';F$ 270 IF F$="" THEN BEEP @ GOTO 'INPUT' 280 ON ERROR GOTO 'IERR' 290 ! 300 ! Try to create file; an error will occur if file exists. 310 ! 320 CREATE TEXT F$ @ GOTO 'ICONT' 330 ! 340 ! If the file exists, ask the user what to do. 350 ! 360 'IERR': OFF ERROR @ IF ERRN#59 THEN DISP 'ERR=';ERRN @ END 370 IF ERRN=59 THEN DISP 'It exists, PURGE it?'; 380 INPUT '','n';R$ 390 IF UPRC$(R$)='Y' THEN PURGE F$ @ CREATE TEXT F$ @ GOTO 'ICONT' ELSE 'INPUT' 400 ! 410 ! Open channel to specified file. 420 ! 430 'ICONT': OFF ERROR @ ASSIGN #1 TO F$ 440 DISP 'waiting for IPC....' 450 ! 460 ! Read information from IPC (HP-IL Loop) until 'EOF' is read. 470 ! 480 'IREAD': ENTER :LOOP ;A$ 490 IF A$='EOF' THEN GOTO 'ICMPLT' 500 ! 510 ! Display information, write to file. 520 ! 530 DISP A$ @ PRINT #1;A$ 540 GOTO 'IREAD' 550 ! 560 ! 'EOF' reached, close file. 570 ! 580 'ICMPLT': ASSIGN #1 TO * 590 DISP 'Transfer complete!' @ WAIT 2 @ GOTO 'MAIN' 600 ! 610 ! ******** OUTPUT FILE TO IPC ******** 620 ! 630 'OUTPUT': INPUT 'Out to IPC/ file: ';F$ 640 ON ERROR GOTO 'NOFIND' 650 ! 660 ! If specified file can't be found, branch to error routine. 670 ! 680 CAT F$ @ GOTO 'CONTOUT' 690 ! 700 ! Error recovery for bad filename 710 ! 720 'NOFIND': OFF ERROR @ DISP "Can't find ";F$ @ WAIT 2 @ GOTO 'OUTPUT' 730 ! 740 ! No errors, open file. 750 ! 760 'CONTOUT': OFF ERROR @ ASSIGN #1 TO F$ 770 ON ERROR GOTO 'EOF' 780 ! 790 ! Trap error while reading from HP-71 text file, output info. 800 ! 810 'OREAD': READ #1;A$ @ OUTPUT :LOOP ;A$ @ DISP A$ @ GOTO 'OREAD' 820 ! 830 ! Check error; if it wasn't an EOF error, then report what it was. 840 ! If it was an EOF error, send the string 'EOF' to the IPC. 850 ! 860 'EOF': OFF ERROR @ IF ERRN=54 THEN OUTPUT :LOOP ;'EOF' ELSE DISP 'ERR='; ERRN @ END 870 DISP 'Transfer complete!' @ WAIT 2 @ GOTO 'MAIN' 880 ! 890 ! ******** EXIT FROM PROGRAM ******** 900 ! 910 'EXIT': ASSIGN #1 TO * 920 DISP 'Until we meet again..' @ WAIT 3 @ PUT '#38' @ END