The following application code sample performs as a SuperB Software ISAM file server. A client application uses this server by opening a connection to port 4239 of a computer running this server application and issuing file OPEN, CLOSE, and READ requests.
00100 Option Base 1
00200 ! Copyright (C) 2001 SuperB Software, Inc., All Rights Reserved
00200.010 ! TCPSERV.BAS - Version 1.001
00200.020 ! 15 October 2001, Robert J. Armantrout
00250 OPTION BASE 1
00300 Dim LastEvent$*80, X$*255
00300.010 Dim OpenSequence$*1, OpenIomode$*1, OpenControl$*255
00300.020 Dim CloseControl$*255
00300.030 Dim ReadControl$*255
00300.040 Dim UsingForm$*255
00300.050 Dim DataBuffer$(17)*255
00300.060 Dim CWSID$*2, CUSERNAME$*32, C_USERNAME$(15)*32, C_WSID$(15)*2
01000 ! Set TCPIP event traps for connect (0x01), close (0x02) and packet in (0x04)
01000.010 Machine$("TCPIP.EventTraps=7")
01010 ! Set TCPIP trap vector
01010.010 On _TCPIP Goto TCPIP_TRAP
01020 ! Initialize screen display idle process
01020.010 Connections = 0
01020.020 LastEvent$ = ""
01020.030 FilesOpen = 0
01020.040 Print Newpage;
01020.050 Print Fields 1,27,28:"SuperB TCP/IP Server Sample"
01020.060 Print Fields 3,1,80:"Connections: " & str$(Connections)
01030 ! Open a server port with 20 connections using files 201 to 220
01030.010 Open #201:"TCPIP,LocalPort=4239,Connections=4,Recl=16384,MaxPacket=16384",Internal,Outin
01040 ! Idle Loop
01040.010 TCPIP_LOOP:
01040.020 Machine$("IDLE")
01040.030 Machine$("Delay=25")
01040.040 Machine$("IDLE")
01040.050 If Kstat$ >< Chr$(27) Then TCPIP_LOOP
01040.060 ! ESC key pressed. Close connections, close files, and exit
01040.070 For I = 1 to 254
01040.080 If File$(I) >< "" Then Close #I:
01040.090 Next I
01040.100 Stop
02000 ! TCPIP Event Service Routine
02000.010 TCPIP_TRAP:
! Save the return line number for use on service routine exit
02000.020 Tcpip_Return$ = Machine$("Error-Put")
02000.030 ! Get the event identifier to see what's up
02000.040 LastEvent$ = Machine$("TCPIP.Event")
02000.050 ! Dispatch to process event
02000.060 If LastEvent$(1:6) = "Packet" Then TCPIP_READ_PACKET
02000.070 If LastEvent$(1:7) = "Connect" Then TCPIP_NEW_CONNECTION
02000.080 If LastEvent$(1:5) = "Close" Then TCPIP_CLOSE_CONNECTION
02000.090 ! So what is it? Can't get here!
02000.100 Print Fields 10,1,80:"Unknown Event: " & LastEvent$
02000.110 Input Fields 11,1,1:X$
02000.120 TCPIP_TRAP_EXIT:
02000.130 ! Exit the service routine resuming program flow
02000.140 ! unless another TCPIP event is waiting for processing.
02000.150 Machine$("TCPIP.EventExit=" & Tcpip_Return$)
02100 ! TCPIP Connect Event Service Routine
02100.010 TCPIP_NEW_CONNECTION:
02100.020 Connections += 1
02100.030 Print Fields 5,1,80:LastEvent$
02100.040 Print Fields 3,1,80:"Connections: " & str$(Connections)
02100.050 Goto TCPIP_TRAP_EXIT
02200 ! TCPIP Close Event Service Routine
02200.010 TCPIP_CLOSE_CONNECTION:
02200.020 Connections -= 1
02200.030 Print Fields 5,1,80:LastEvent$
02200.040 Print Fields 3,1,80:"Connections: " & str$(Connections)
02200.050 FileNumber = Val(LastEvent$(9:255))
02200.060 C_WSID$(FileNumber - 200) = ""
02200.070 C_USERNAME$(FileNumber - 200) = ""
02200.080 _Void FN_Connection_Status(FileNumber)
02200.090 Goto TCPIP_TRAP_EXIT
02300 ! TCPIP Packet Event Service Routine
02300.010 TCPIP_READ_PACKET:
02300.020 ! First, get the data packet header information
02300.030 FileNumber = Val(LastEvent$(9:255))
02300.040 Read #FileNumber,Using "V 8":Operation$
02300.050 Print Fields 5,1,80:LastEvent$
02300.060 Print Fields 6,1,80:Operation$
02300.070 ! Dispatch to process request
02300.080 If Operation$ = "OPEN" Then TCPIP_PACKET_OPEN
02300.090 If Operation$ = "CLOSE" Then TCPIP_PACKET_CLOSE
02300.100 If Operation$ = "READ" Then TCPIP_PACKET_READ
02300.110 If Operation$ = "READREC" Then TCPIP_PACKET_READREC
02300.120 If Operation$ = "READ=" Then TCPIP_PACKET_READEQ
02300.130 If Operation$ = "READ>=" Then TCPIP_PACKET_READGE
02300.140 If Operation$ = "READ<=" Then TCPIP_PACKET_READLE
02300.145 If Operation$ = "ID" Then TCPIP_PACKET_ID
02300.146 If Operation$ = "RECNUM" Then TCPIP_PACKET_RECNUM
02300.150 !
02300.160 ! The dispatch to other control codes may be implemented here
02300.170 !
02300.200 ! Return error code and no data bytes to indicate unknown request
02300.250 _Void FNREPLY(FileNumber, 1, 0)
02300.255 Goto TCPIP_TRAP_EXIT
02400 ! Open a file
02400.010 TCPIP_PACKET_OPEN:
02400.020 ! Acquire open parameters
02400.030 Reread #FileNumber,Using "POS 9,C 1,C 1,C "&str$(rln(FileNumber) - 10):OpenSequence$, OpenIomode$, OpenControl$
02400.040 OpenSequence$ = _ucase$(OpenSequence$)
02400.050 OpenIomode$ = _ucase$(OpenIomode$)
02400.060 ! Get a file number
02400.070 IOFN = FN_GetOpenFileNumber
02400.080 If IOFN < 0 Then
02400.090 _Void FNREPLY(FileNumber, 2, 0)
02400.100 Goto TCPIP_TRAP_EXIT
02400.110 End if
02400.120 ! Perform the open functions
02400.130 If OpenSequence$&OpenIomode$ = "SI" Then
02400.140 Open #IOFN:OpenControl$,Internal,Input,Sequential IOERR TCPIP_PACKET_OPEN_ERROR
02400.150 Else If OpenSequence$&OpenIomode$ = "RI" Then
02400.160 Open #IOFN:OpenControl$,Internal,Input,Relative IOERR TCPIP_PACKET_OPEN_ERROR
02400.170 Else If OpenSequence$&OpenIomode$ = "KI" Then
02400.180 Open #IOFN:OpenControl$,Internal,Input,Keyed IOERR TCPIP_PACKET_OPEN_ERROR
02400.190 Else If OpenSequence$&OpenIomode$ = "SO" Then
02400.200 Open #IOFN:OpenControl$,Internal,Output,Sequential IOERR TCPIP_PACKET_OPEN_ERROR
02400.210 Else If OpenSequence$&OpenIomode$ = "RO" Then
02400.220 Open #IOFN:OpenControl$,Internal,Output,Relative IOERR TCPIP_PACKET_OPEN_ERROR
02400.230 Else If OpenSequence$&OpenIomode$ = "KO" Then
02400.240 Open #IOFN:OpenControl$,Internal,Output,Keyed IOERR TCPIP_PACKET_OPEN_ERROR
02400.250 Else If OpenSequence$&OpenIomode$ = "SB" Then
02401 Open #IOFN:OpenControl$,Internal,Outin,Sequential IOERR TCPIP_PACKET_OPEN_ERROR
02401.010 Else If OpenSequence$&OpenIomode$ = "RB" Then
02401.020 Open #IOFN:OpenControl$,Internal,Outin,Relative IOERR TCPIP_PACKET_OPEN_ERROR
02401.030 Else If OpenSequence$&OpenIomode$ = "KB" Then
02401.040 Open #IOFN:OpenControl$,Internal,Outin,Keyed IOERR TCPIP_PACKET_OPEN_ERROR
02401.050 Else
02401.060 ! Unknown open request type
02401.070 _void FNREPLY(FileNumber, 3, 0)
02401.080 Goto TCPIP_TRAP_EXIT
02401.090 End if
02401.100 ! Prepare the result string
02401.110 Mat DataBuffer$ = DataBuffer$(1)
02401.120 DataBuffer$(1) = lpad$(str$(IOFN), 3)
02401.130 ! Send the answer packet
02401.140 _void FNREPLY(FileNumber, 0, Len(DataBuffer$(1)))
02401.150 Goto TCPIP_TRAP_EXIT
02402 TCPIP_PACKET_OPEN_ERROR:
02402.010 ! Report error 4 with error code number
02402.020 Mat DataBuffer$ = DataBuffer$(1)
02402.030 DataBuffer$(1) = str$(ERR)
02402.040 ! Send the answer packet
02402.050 _void FNREPLY(FileNumber, 4, Len(DataBuffer$(1)))
02402.060 Goto TCPIP_TRAP_EXIT
02403 Def FN_GetOpenFileNumber
02403.010 F_IOFN = 1
02403.020 While F_IOFN <= 200
02403.030 If File(F_IOFN) = -1 Then exit while
02403.040 F_IOFN += 1
02403.050 End While
02403.060 If F_IOFN > 200 Then FN_GetOpenFileNumber = -1 else FN_GetOpenFileNumber = F_IOFN
02403.070 Fnend
02500 TCPIP_PACKET_CLOSE:
02500.010 ! Acquire close file number
02500.020 Reread #IOFN,Using "C "&str$(rln(FileNumber) - 8):CloseControl$
02500.030 On Conv Goto INVALID_FILE_NUMBER
02500.040 IOFN = Val(CloseControl$)
02500.050 If IOFN < 1 or IOFN > 254 Then INVALID_FILE_NUMBER
02500.060 On Conv System
02500.070 ! Perform the close
02500.080 On Error goto TCPIP_PACKET_CLOSE_ERROR
02500.090 Close #IOFN:
02500.100 On Error System
02500.110 ! Report success
02500.120 _void FNREPLY(FileNumber, 0, 0)
02500.130 Goto TCPIP_TRAP_EXIT
02501 INVALID_FILE_NUMBER:
02501.010 ! Report error 5 invalid file number
02501.020 _void FNREPLY(FileNumber, 5, 0)
02501.030 Goto TCPIP_TRAP_EXIT
02502 TCPIP_PACKET_CLOSE_ERROR:
02502.010 On Error System
02502.020 ! Report error 6 with error code number
02502.030 Mat DataBuffer$ = DataBuffer$(1)
02502.040 DataBuffer$(1) = str$(ERR)
02502.050 ! Send the answer packet
02502.060 _void FNREPLY(FileNumber, 6, Len(DataBuffer$(1)))
02502.070 Goto TCPIP_TRAP_EXIT
02600 TCPIP_PACKET_READ:
02600.010 ! Get read file number
02600.020 IOFN = FN_GetReadFileNumber
02600.030 If IOFN < 1 or IOFN > 254 or File(IOFN) >< 0 then INVALID_FILE_NUMBER
02600.040 ! Perform the read
02600.050 On Error Goto TCPIP_PACKET_READ_ERROR
02600.060 Read #IOFN:
02600.070 TCPIP_PACKET_READ_RETURN_DATA:
02600.080 On Error System
02600.090 ! Read the data from current context record into DataBuffer$
02600.100 Segments = int((rln(IOFN) + 254) / 255) - 1
02600.120 Extra = rln(IOFN) - Segments * 255
02600.130 Mat DataBuffer$ = DataBuffer$(Segments + 1)
02600.140 UsingForm$ = "Segments*C 255,C Extra"
02600.150 Reread #IOFN,Using UsingForm$:Mat DataBuffer$
02600.160 ! Send record data back through TCP/IP file
02600.170 _void FNREPLY(FileNumber, 0, rln(IOFN))
02600.180 Goto TCPIP_TRAP_EXIT
02601 Def FN_GetReadFileNumber
02601.010 ! Parse out the file number
02601.020 Reread #FileNumber,Using "Pos 9,N 3":IOFN Conv F_GetReadFileNumberInvalid
02601.030 Goto F_GetReadFileNumberDone
02601.040 F_GetReadFileNumberInvalid:
02601.050 IOFN = -1
02601.060 F_GetReadFileNumberDone:
02601.070 FN_GetReadFileNumber = IOFN
02601.080 Fnend
02700 TCPIP_PACKET_READREC:
02700.010 ! Get read file number
02700.020 IOFN = FN_GetReadFileNumber
02700.030 If IOFN < 1 or IOFN > 254 or File(IOFN) >< 0 then INVALID_FILE_NUMBER
02700.040 ! Parse the record number
02700.050 Reread #FileNumber,Using "Pos 12,C " & str$(rln(FileNumber) - 11):ReadControl$
02700.060 On Conv Goto READREC_INVALID_RECORD_NUMBER
02700.070 Recnum = Val(ReadControl$)
02700.080 If Recnum < 1 Then READREC_INVALID_RECORD_NUMBER
02700.090 On Conv System
02700.100 ! Perform the read
02700.110 On Error Goto TCPIP_PACKET_READ_ERROR
02700.120 Read #IOFN,REC=Recnum:
02700.130 Goto TCPIP_PACKET_READ_RETURN_DATA
02701 READREC_INVALID_RECORD_NUMBER:
02701.010 _void FNREPLY(FileNumber, 9, 0)
02701.020 Goto TCPIP_TRAP_EXIT
02800 TCPIP_PACKET_READEQ:
02800.010 ! Get read file number
02800.020 IOFN = FN_GetReadFileNumber
02800.030 If IOFN < 1 or IOFN > 254 or File(IOFN) >< 0 then INVALID_FILE_NUMBER
02800.040 ! Parse the record key
02800.050 Reread #FileNumber,Using "Pos 12,C " & str$(rln(FileNumber) - 11):ReadControl$
02800.060 If len(ReadControl$) > KLN(IOFN) Then TCPIP_PACKET_READEQ_KEY_ERROR
02800.070 ! Perform the read
02800.080 On Error Goto TCPIP_PACKET_READ_ERROR
02800.090 Read #IOFN,Search=ReadControl$:
02800.100 Goto TCPIP_PACKET_READ_RETURN_DATA
02801 TCPIP_PACKET_READEQ_KEY_ERROR:
02801.010 _void FNREPLY(FileNumber, 7, 0)
02801.020 Goto TCPIP_TRAP_EXIT
02802 TCPIP_PACKET_READ_ERROR:
02802.010 ! Report error 8 with error code number
02802.020 Mat DataBuffer$ = DataBuffer$(1)
02802.030 DataBuffer$(1) = str$(ERR)
02802.040 ! Send the answer packet
02802.050 _void FNREPLY(FileNumber, 8, Len(DataBuffer$(1)))
02802.060 Goto TCPIP_TRAP_EXIT
02900 TCPIP_PACKET_READGE:
02900.010 ! Get read file number
02900.020 IOFN = FN_GetReadFileNumber
02900.030 If IOFN < 1 or IOFN > 254 or File(IOFN) >< 0 then INVALID_FILE_NUMBER
02900.040 ! Parse the record key
02900.050 Reread #FileNumber,Using "Pos 12,C " & str$(rln(FileNumber) - 11):ReadControl$
02900.060 If len(ReadControl$) > KLN(IOFN) Then TCPIP_PACKET_READEQ_KEY_ERROR
02900.070 ! Perform the read
02900.080 On Error Goto TCPIP_PACKET_READ_ERROR
02900.090 Read #IOFN,Search>=ReadControl$:
02900.100 Goto TCPIP_PACKET_READ_RETURN_DATA
03000 TCPIP_PACKET_READLE:
03000.010 ! Get read file number
03000.020 IOFN = FN_GetReadFileNumber
03000.030 If IOFN < 1 or IOFN > 254 or File(IOFN) >< 0 then INVALID_FILE_NUMBER
03000.040 ! Parse the record key
03000.050 Reread #FileNumber,Using "Pos 12,C " & str$(rln(FileNumber) - 11):ReadControl$
03000.060 If len(ReadControl$) > KLN(IOFN) Then TCPIP_PACKET_READEQ_KEY_ERROR
03000.070 ! Perform the read
03000.080 On Error Goto TCPIP_PACKET_READ_ERROR
03000.090 Read #IOFN,Search<=ReadControl$:
03000.100 Goto TCPIP_PACKET_READ_RETURN_DATA
03100 TCPIP_PACKET_ID:
03100.010 Reread #FileNumber,using "POS 9,C 2,C 32":CWSID$, CUSERNAME$
03100.020 C_WSID$(FileNumber - 200) = CWSID$
03100.030 C_USERNAME$(FileNumber - 200) = CUSERNAME$
03100.040 _Void FN_Connection_Status(FileNumber)
03100.050 ! Report success
03100.060 _void FNREPLY(FileNumber, 0, 0)
03100.070 Goto TCPIP_TRAP_EXIT
03200 TCPIP_PACKET_RECNUM:
03200.010 ! Get read file number
03200.020 IOFN = FN_GetReadFileNumber
03200.030 If IOFN < 1 or IOFN > 254 or File(IOFN) >< 0 then INVALID_FILE_NUMBER
03200.040 DataBuffer$(1) = Str$(REC(FileNumber))
03200.050 _void FNREPLY(FileNumber, 0, Len(DataBuffer$(1)))
03200.060 Goto TCPIP_TRAP_EXIT
05000 Def FNREPLY (TcpIpFileNumber, ErrorCodeNumber, ReturnByteCount)
05000.010 ! Set the TCP/IP file packet length to send
05000.020 Machine$("RLN(TcpIpFileNumber)=" & str$(ReturnByteCount + 3))
05000.030 ! Figure out how to convert the output array
05000.040 Segments = int((ReturnByteCount + 254) / 255) - 1
05000.050 Extra = ReturnByteCount - 255 * Segments
05000.060 UsingForm$ = "N 3,Segments*C 255,C Extra"
05000.070 ! Write the data packet
05000.080 If ReturnByteCount > 0 Then
05000.090 Write #TcpIpFileNumber,Using UsingForm$:ErrorCodeNumber, Mat DataBuffer$
05000.100 Else
05000.110 Write #TcpIpFileNumber,Using "N 3":ErrorCodeNumber
05000.120 End If
05000.130 Fnend
05100 Def FN_Connection_Status(DisplayFileNumber)
05100.010 Print Fields DisplayFileNumber-190, 1, 80: Lpad$(Str$(DisplayFileNumber), 3) & " " & C_WSID$(DisplayFileNumber - 200) & " " & C_USERNAME$(DisplayFileNumber - 200)
05100.255 Fnend
The following application code provides a sample client that accesses the "Sample Server Application" provided above.
00100 Option Base 1
00200 ! Copyright (C) 2001 SuperB Software, Inc., All Rights Reserved
00200.010 ! TCPCLNT.BAS - Version 1.000
00200.020 ! 15 October 2001, Robert J. Armantrout
00300 Dim Server$*64, X$*255
00300.010 Dim DataFile$*64, FileMode$*1
00300.020 Dim TwoSpec$(2)*64
00300.030 Dim DataBuffer$(17)*255
00300.040 Dim Request$*255
01000 OpenConnection:
01000.010 Print Newpage;
01000.020 Print Fields 1,27,28:"SuperB TCP/IP Client Sample"
01000.030 Print Fields 3,1,18:"Connect to server:"
01000.040 Input Fields "3,20,V 60,U":Server$
01000.050 If Cmdkey = 9 then Stop
01000.060 Open #1:"TCPIP, RemoteHost=" & Server$ & ", RemotePort=4239, Recl=16384",Internal,Outin Ioerr ConnectionError
01000.070 x$ = "Connected to " & Server$ & ", Port 4239"
01000.080 x$ = Rpad$(Rpt$(" ", int((80 - len(x$)) / 2)) & x$, 80)
01000.090 Print Fields 3,1,80:x$
01000.100 ! Send my ID information
01000.110 Write #1,using "C 8,C 2,C 32":"ID", Wsid$, Machine$("USER")
01000.120 Print Fields 14,1,80:"Sending ID information"
01000.130 Gosub GetDataBuffer
01000.140 ErrorCode = Val(DataBuffer$(1)(1:3))
01000.150 If ErrorCode >< 0 Then ConnectionError else GetFileName
01001 ConnectionError:
01001.010 Print Fields 14,1,80:"Unable to open connection to: " & Server$
01001.020 Print Fields 15,1,80:"[Press <Enter> to resume]"
01001.030 Input Fields 15,26,1:x$
01001.040 Print Fields 15,1,80:""
01001.050 Print Fields 14,1,80:""
01001.060 Goto OpenConnection
01100 GetFileName:
01100.010 Print Fields 5,1,9:"Open File"
01100.020 TwoSpec$(1) = "5,11,C 60,U"
01100.030 Print Fields 6,1,45:"Open Mode (Sequential, Relative, or Keyed): S"
01100.040 TwoSpec$(2) = "6,45,C 1,U,AE"
01100.050 Input Fields Mat TwoSpec$:DataFile$, FileMode$
01100.060 If Cmdkey = 9 Then Stop
01100.070 FileMode$ = _ucase$(FileMode$)
01100.080 If Pos("SRK", FileMode$, 1) >= 1 then OpenFile
01100.090 Print Fields 14,1,80:"Invalid Open Mode - Use S, R, or K"
01100.100 Print Fields 15,1,80:"[Press <Enter> to resume]"
01100.110 Input Fields 15,26,1:x$
01100.120 Print Fields 15,1,80:""
01100.130 Print Fields 14,1,80:""
01100.140 Goto GetFileName
01200 OpenFile:
01200.010 TwoSpec$(1) = Srep$(TwoSpec$(1), 1, ",U", "")
01200.020 TwoSpec$(2) = Srep$(TwoSpec$(2), 1, ",U", "")
01200.030 Print Fields Mat TwoSpec$:DataFile$, FileMode$
01200.040 ! Try to open a file at the server
01200.050 Request$ = "OPEN " & FileMode$ & "I" & DataFile$
01200.060 Machine$("RLN(1)=" & str$(len(Request$)))
01200.070 Write #1,Using "C " & str$(len(Request$)):Request$
01200.080 Print Fields 14,1,80:"Sending OPEN request"
01200.090 Gosub GetDataBuffer
01200.100 ErrorCode = Val(DataBuffer$(1)(1:3))
01200.110 FileNumber$ = DataBuffer$(1)(4:255)
01200.120 If ErrorCode = 0 Then GetRequests
01200.140 Print Fields 14,1,80:"Server error " & str$(ErrorCode) & " on OPEN Request"
01200.150 Print Fields 15,1,80:"[Press <Enter> to resume]"
01200.160 Input Fields 15,26,1:x$
01200.170 Print Fields 15,1,80:""
01200.180 Print Fields 14,1,80:""
01200.190 Goto GetFileName
01201 GetDataBuffer:
01201.010 While Val(Machine$("TCPIP(1).PacketCount")) = 0
01201.020 Machine$("IDLE")
01201.030 Machine$("Delay=10")
01201.040 Machine$("IDLE")
01201.050 End While
01201.060 Read #1:
01201.070 Segments = int((Rln(1) + 254) / 255) - 1
01201.080 Extra = Rln(1) - 255*Segments
01201.090 Mat DataBuffer$ = DataBuffer$(Segments + 1)
01201.100 Reread #1,using "Segments*C 255,C Extra":Mat DataBuffer$
01201.110 Print Fields 14,1,80:"Reply Received"
01201.120 Return
01300 GetRequests:
01300.010 Print Fields 8,1,48:"Read Type (seq=1, rel=2, key=3, key>=4, key<=5):"
01300.020 TwoSpec$(1) = "8,50,C 1"
01300.030 Print Fields 9,1,21:"Key or record number:"
01300.040 TwoSpec$(2) = "9,23,V 18,AE"
01300.050 Input Fields Mat TwoSpec$:ReadType$, ReadInfo$
01300.060 If Cmdkey = 9 Then Stop
01300.070 Gosub PrepareReadRequest
01300.080 If Request$ = "" Then BadRequestError
01300.090 Machine$("RLN(1)=" & str$(len(Request$)))
01300.100 Write #1,Using "C " & str$(len(Request$)):Request$
01300.110 Print Fields 14,1,80:"Sending " & rtrm$(Request$(1:8)) & " request"
01300.120 Gosub GetDataBuffer
01300.130 ErrorCode = Val(DataBuffer$(1)(1:3))
01300.140 If ErrorCode >< 0 Then ServerReadError
01300.150 Gosub DisplayData
01300.160 Goto GetRequests
01301 BadRequestError:
01301.010 Print Fields 14,1,80:"Invalid Request. Please enter 1 through 5."
01301.020 Print Fields 15,1,80:"[Press <Enter> to resume]"
01301.030 Input Fields 15,26,1:x$
01301.040 Print Fields 15,1,80:""
01301.050 Print Fields 14,1,80:""
01301.060 Goto OpenConnection
01302 ServerReadError:
01302.010 Print Fields 14,1,80:"Error code returned from server: " & str$(ErrorCode)
01302.020 Print Fields 15,1,80:"[Press <Enter> to resume]"
01302.030 Input Fields 15,26,1:x$
01302.040 Print Fields 15,1,80:""
01302.050 Print Fields 14,1,80:""
01302.060 Goto OpenConnection
01400 PrepareReadRequest:
01400.010 If ReadType$ = "1" Then
01400.020 Request$ = "READ " & FileNumber$
01400.030 Else If ReadType$ = "2" Then
01400.040 Request$ = "READREC " & FileNumber$ & ReadInfo$
01400.050 Else If ReadType$ = "3" Then
01400.060 Request$ = "READ= " & FileNumber$ & ReadInfo$
01400.070 Else If ReadType$ = "4" Then
01400.080 Request$ = "READ>= " & FileNumber$ & ReadInfo$
01400.090 Else If ReadType$ = "5" Then
01400.100 Request$ = "READ<= " & FileNumber$ & ReadInfo$
01400.110 Else
01400.120 Request$ = ""
01400.130 End if
01400.140 Return
01401 DisplayData:
01401.010 For i = 1 to 5
01401.020 x$ = FnFormat$(DataBuffer$(1)(16*i - 15 : 16*i))
01401.030 Print Fields i+18,1,80:x$
01401.040 Next i
01401.050 Return
01402 Def FnFormat$*80(Argument$*16)
01402.010 F_Format$ = ""
01402.020 For F_Format_I = 1 to 16
01402.030 F_Format$ = F_Format$ & FnHex$(Argument$(F_Format_i:F_Format_i))
01402.040 If F_Format_I = 8 Then F_Format$ = F_Format$ & "-" Else F_Format$ = F_Format$ & " "
01402.050 Next F_Format_i
01402.060 F_Format$ = F_Format$ & " "
01402.070 For F_Format_I = 1 to 16
01402.080 F_Format$ = F_Format$ & FnPrintable$(Argument$(F_Format_i:F_Format_i))
01402.090 If F_Format_I = 8 Then F_Format$ = F_Format$ & "-"
01402.100 Next F_Format_i
01402.110 FnFormat$ = F_Format$
01402.120 Fnend
01402.130 Dim F_Format$*80
01403 Def FnHex$*2(ByteValue$*1)
01403.010 If ByteValue$ = "" Then
01403.020 FnHex$ = " "
01403.030 Else
01403.040 F_Hex_1 = int(ord(ByteValue$) / 16) + 1
01403.050 F_Hex_2 = ord(ByteValue$) - 16*F_Hex_1 + 17
01403.060 FnHex$ = ("0123456789ABCDEF")(F_Hex_1:F_Hex_1) & ("0123456789ABCDEF")(F_Hex_2:F_Hex_2)
01403.070 End If
01403.080 Fnend
01404 Def FnPrintable$*1(ByteValue$*1)
01404.010 If ByteValue$ = "" Then
01404.020 FnPrintable$ = " "
01404.030 Else If ord(ByteValue$) >= ord(" ") and ord(ByteValue$) <= ord("~") Then
01404.040 FnPrintable$ = ByteValue$
01404.050 Else
01404.060 FnPrintable$ = "."
01404.070 End If
01404.080 Fnend