Automated file transfers
There was some recent traffic on the 3000 Internet mailing list where people were asking about how to programmatically deal with file transfers through terminal emulators such as MiniSoft/92 and Reflection. About eight years ago I had the same need. I wanted to be able to see whether it was a Windows or DOS PC running MiniSoft or Reflection. At the time MiniSoft didnt do the Mac, but Reflection did, so I would auto-sense that as well. The final step was to make sure that if someone tried to do this on a dumb terminal by mistake, that the terminal didnt lock up, so I put some code in there to handle that as well.
start with the auto-sensing portion of the code. We have some things
to set up first. I tried to keep Figure 1 below concise, so you can
decide how to prompt for the PC file name and the HP file name.
Ive prompted for the PC file name, then stripped all segments
that arent the file name using UNSTRING, then put it into a
consistent 3000 group to control it further.
01 STDIN PIC S9(4) COMP VALUE 0. 01 TIMEOUT PIC S9(4) COMP VALUE 7. 01 TERM-ID PIC X(09) VALUE SPACES. 01 FILE-TYPE PIC X VALUE SPACES.* First FOPEN the terminal so that we can enable FCONTROL for a * timeout in later calls. CALL INTRINSIC "FOPEN" USING \\, %45 GIVING STDIN. CALL INTRINSIC "FCONTROL" USING STDIN, 4, TIMEOUT. * Issue the escape sequence to request the terminal ID from the * termulator. %33 is the octal value for the escape key. DISPLAY %33 '*s12347^'. ACCEPT TERM-ID FREE ON INPUT ERROR DISPLAY 'You are not using a PC' STOP RUN. * Here is where we tell if it's a MAC or not, we do this * specifically because the binary file transfer on a mac is * different than for the PC. IF(TERM-ID(1:1) = 'M') AND (TERM-ID(1:4) <> 'MS92') MOVE 'WRQ' TO TERM-ID DISPLAY '(A)scii, (B)inary or (M)acBinary? ' NO ADVANCING ELSE DISPLAY '(A)scii or (B)inary? ' NO ADVANCING. ACCEPT FILE-TYPE. IF TERM-ID(1:3) = 'WRQ' PERFORM C1000-REFLECT THRU C1000-EXIT. IF TERM-ID = 'MS92 BEST' PERFORM C2000-MS92 THRU C2000-EXIT. STOP RUN.
The trick after this point is to be able to start up the emulator file transfer program. There are sample applications that come with the various emulators that will describe how to do this. I recommend that you follow them exactly. In the case of MiniSoft, the sample shows how to do it using the CREATEPROCESS and ACTIVATE intrinsics. Ive tried doing it my own way, and it just didnt work. In the case of Reflection they show how to do it with the CREATE intrinsic.
What actually happens is that one of the escape sequences you issue will return the fully qualified name of the file transfer program that is configured in the emulator. If this file doesnt exist, then the whole process will fail, so it does rely on having everything set up to work. Once the program name is returned, you have to spawn it as a child process, hence the calls to CREATE and CREATEPROCESS. Essentially you pass the scripting language directive to the emulator via an escape sequence and away you go. Its a bit on the confusing side when you first start out, but it really does work pretty darn well.
Im still planning on
making that trip to Sendmail/iX and showing off some utilities, but
it looks as if its going to take more planning. Stay tuned
until next month.
Copyright The 3000 NewsWire. All rights reserved.