help file transfer, open com 
Author Message
 help file transfer, open com

Hi, I'm new to the world of qb programming.  First, I'm using an old version,
1.1 to exact.  (I know, I know.)
Here is what I'm attempting to do.  I want to automate the process of sending
a file to a remote host.  I have my data file "test.dat"  I want to send it
over my modem on com2.  What I'm looking for is how to initialize the modem,
tell qb to get the file, send it, and quit.  Verification of file transfer
would be nice but I may be asking for to much.
Am I better off upgrading to qb 4.5?  Don't get me started on vb, yet.
Any advice on this matter would be great and thanks in advance.
--
Ethan Ray
http://www.*-*-*.com/
"The Constitution is never a technicality"


Mon, 07 Sep 1998 03:00:00 GMT  
 help file transfer, open com

Quote:

>Hi, I'm new to the world of qb programming.  First, I'm using an old version,
>1.1 to exact.  (I know, I know.)
>Here is what I'm attempting to do.  I want to automate the process of sending
>a file to a remote host.  I have my data file "test.dat"  I want to send it
>over my modem on com2.  What I'm looking for is how to initialize the modem,
>tell qb to get the file, send it, and quit.  Verification of file transfer
>would be nice but I may be asking for to much.
>Am I better off upgrading to qb 4.5?  Don't get me started on vb, yet.
>Any advice on this matter would be great and thanks in advance.
>--
>Ethan Ray
>http://www.msu.edu/user/rayethan
>"The Constitution is never a technicality"

Hello Ethan,

Definitely, upgrade to at least 4.5. The OPEN statement is very nice.

        OPEN "Com2:" FOR OUTPUT AS #1
        PRINT #1, "This is only a test"
        CLOSE #1

File verification takes a little more work. You need to open the com
port for RANDOM so that you can send some verification back, but you
get the idea.

Programmer



Wed, 09 Sep 1998 03:00:00 GMT  
 help file transfer, open com
G'Day All

Quote:

>Subject: help file transfer, open com
>Date: 21 Mar 1996 00:33:53 GMT
>Hi, I'm new to the world of qb programming.  First, I'm using an old version,
>1.1 to exact.  (I know, I know.)

Actually QBASIC 1.1 is *later* than QuickBasic 4.5, QBASIC 1.1(free with DOS
5.0 and above) is a cut down version of QB4.5 (the earliest comercial release
of QuickBasic was V2.0). QBASIC 1.1 has many of the features of QB4.5

Quote:
>Here is what I'm attempting to do.  I want to automate the process of sending
>a file to a remote host.  I have my data file "test.dat"  I want to send it
>over my modem on com2.  What I'm looking for is how to initialize the modem,
>tell qb to get the file, send it, and quit.  Verification of file transfer
>would be nice but I may be asking for to much.
>Am I better off upgrading to qb 4.5?  

No, communications file handling is exactly the same. QB4.5 just has better
help files.
Quote:
>Don't get me started on vb, yet.
>Any advice on this matter would be great and thanks in advance.

I append an edited copy of the TERMINAL.BAS distributed with QB4.5. I have
added routines from Micheal Parker that will open COM1-4 up to 115 K Baud
Works fine in QBASIC 1.1
'===========begin MY_TERM.BAS======================
DEFINT A-Z

DECLARE SUB Filter (InString$)
DECLARE SUB OPENCOM (InString$)

COLOR 7, 1                      ' Set screen color.
CLS

Quit$ = CHR$(0) + CHR$(16)      ' Value returned by INKEY$
                                ' when ALT+q is pressed.

' Set up prompt on bottom line of screen and turn cursor on:
LOCATE 24, 1, 1
PRINT STRING$(80, "_");
LOCATE 25, 1
PRINT TAB(30); "Press ALT+q to quit";

VIEW PRINT 1 TO 23              ' Print between lines 1 & 23.

' Open communications (4800 baud, no parity, 8-bit data,
' 1 stop bit, 256-byte input buffer):
'Normal Basic open COM
'OPEN "COM2:4800,N,8,1,CS,DS,CD4000" FOR RANDOM AS #1 LEN = 256
'============================================================
'OPENCOM sub for high buad rates and access to coms 1-4
CALL OPENCOM("COM2:4800,N,8,1,CS,DS,CD4000 AS 1")

DO                              ' Main communications loop.

   KeyInput$ = INKEY$           ' Check the keyboard.

   IF KeyInput$ = Quit$ THEN    ' Exit the loop if the user
      EXIT DO                   ' pressed ALT+q.

   ELSEIF KeyInput$ <> "" THEN  ' Otherwise, if the user has
      PRINT KeyInput$;
      PRINT #1, KeyInput$;      ' pressed a key, send the
   END IF                       ' character typed to the modem.

   ' Check the modem. If characters are waiting (EOF(1) is
   ' true), get them and print them to the screen:
   IF NOT EOF(1) THEN

      ' LOC(1) gives the number of characters waiting:
      ModemInput$ = INPUT$(LOC(1), #1)

      Filter ModemInput$        ' Filter out line feeds and
      PRINT ModemInput$;        ' backspaces, then print.
   END IF
LOOP

CLOSE                           ' End communications.
CLS
END

'
' ========================= FILTER ==========================
'     Filters characters in an input string.
' ============================================================
'
SUB Filter (InString$) STATIC

   ' Look for backspace characters and recode them to
   ' CHR$(29) (the LEFT cursor key):
   DO
      BackSpace = INSTR(InString$, CHR$(8))
      IF BackSpace THEN
         MID$(InString$, BackSpace) = CHR$(29)
      END IF
   LOOP WHILE BackSpace

   ' Look for line-feed characters and remove any found:
   DO
      LineFeed = INSTR(InString$, CHR$(10))
      IF LineFeed THEN
         InString$ = LEFT$(InString$, LineFeed - 1) + MID$(InString$, LineFeed + 1)
      END IF
   LOOP WHILE LineFeed

END SUB

DEFSNG A-Z
' Quick Basic Routine OpenCom
' This routine will accept the entire OPEN command parameters
' that is in QB 4.5 , the only exception is the baud rate and
' COM port.  Baud rate is optional, if specified, this module
' will set the specifed rate up to 115,200.  If the baud rate
' is specifed at 0, the specifed port will be polled  for the
' current baud rate and the baud rate will be set at the rate
' that is present, if any.  NOTE:  the baud rate parameter on
' the command line IS  NOT optional,  if you want this module
' to set the baud rate,  put an extra comma  into the command
' line to replace the baud rate.  The COM Port will accept up
' to COM 4 now.
'
' OPENCOM "COMX:{option list1 [baudrate,parity,databit]},{option list2}
' AS FileNum"
' examples:
' OPENCOM "COM1:38400 as 1"
' OPENCOM "COM4:,op500 as 1"
' OPENCOM "COM2:2400,n,8,1,op500 as 4"
' OPENCOM "COM3:,,, OP500 as 2"
' These routines were written by Michael Parker.
'
SUB OPENCOM (Sting$)
Sting$ = LTRIM$(RTRIM$(Sting$))
Port$ = UCASE$(LEFT$(Sting$, 5))
Sting$ = RIGHT$(Sting$, LEN(Sting$) - 5)
FOR x = 1 TO LEN(Sting$)
     H$ = MID$(Sting$, x, 1)
     IF UCASE$(H$) = "A" THEN
          H$ = H$ + MID$(Sting$, x + 1, 1)
          IF UCASE$(H$) = "AS" THEN
                FileNum = VAL(MID$(Sting$, x + 2, LEN(Sting$)))
                EXIT FOR
          END IF
     END IF
     InputString$ = InputString$ + H$
NEXT x
FOR x = 1 TO LEN(InputString$)
     IF MID$(InputString$, x, 1) <> "," THEN
          BaudRate$ = BaudRate$ + MID$(InputString$, x, 1)
     ELSE
          InputString$ = MID$(InputString$, x + 1, LEN(InputString$))
          EXIT FOR
     END IF
NEXT x
IF LTRIM$(BaudRate$) = "" THEN
     BaudRate& = 0
END IF
SELECT CASE Port$
     CASE "COM1:"
          BaseAddr% = &H3F8
          Port1$ = "COM1:"
     CASE "COM2:"
          BaseAddr% = &H2F8
          Port1$ = "COM2:"
     CASE "COM3:"
          BaseAddr% = &H2F8
          Port1$ = "COM1:"
     CASE "COM4:"
          BaseAddr% = &H3F8
          Port1$ = "COM2:"
     CASE ELSE
          PRINT "Illegal COM Port"
END SELECT

IF BaudRate$ = "" THEN
     OUT BaseAddr% + 3, INP(BaseAddr% + 3) OR &H80
     LSB% = INP(BaseAddr%)
     MSB% = INP(BaseAddr% + 1)
     OUT BaseAddr% + 3, INP(BaseAddr% + 3) AND &H7F
     Divisor& = MSB% * &H100 + LSB%
     IF Divisor& = 0 THEN
          BaudRate& = 0
     ELSE
          BaudRate& = 115200 / Divisor&
     END IF
ELSE
     BaudRate& = VAL(BaudRate$)
END IF
IF LEFT$(InputString$, 1) <> "," THEN
     InputString$ = "," + InputString$
END IF
OPEN Port1$ + "4800" + InputString$ FOR RANDOM AS FileNum
IF Port$ = "COM3:" THEN
     POKE &H400, &HE8
ELSEIF Port$ = "COM4:" THEN
     POKE &H402, &HE8
END IF
IF BaudRate& <> 0 THEN
     Divisors# = 115200 / BaudRate&
END IF
LCR = BaseAddr% + 3
Temp = INP(LCR)
OUT LCR, Temp OR 128
OUT BaseAddr% + 1, INT(Divisors# / 256)
OUT BaseAddr%, Divisors#
OUT LCR, Temp AND 127

END SUB

'============end MY_TERM.BAS========
Cheers! Ian

---------------------------------------------

Prince Henry's Institue of Medical Research
PO Box 5152, Clayton 3168, Australia.
Phone +61 3 550 4286 FAX +61 3 550 6125



Fri, 11 Sep 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Open File for File Transfer

2. File transfer over a com port.

3. File Transfer and COM/DCOM

4. Opening .msg files in Outlook via COM

5. OPEN COM problems, please help !!!!!!!!

6. Open Com help!!!

7. How to transfer a file greater than 64Kb w/ internet transfer ctrl

8. HOWTO: Securely transfer a file using the Internet Transfer Control

9. Internet Transfer Control and ASCII transfer Help?

10. Internet Transfer Control and ASCII transfer Help?

11. Internet Transfer Control and ASCII transfer Help?

12. Opening a File Open window for file selection in VBA

 

 
Powered by phpBB® Forum Software