COMM PORT 3...

 BBS: Inland Empire Archive
Date: 04-17-92 (09:22)             Number: 52
From: MATT HART                    Refer#: NONE
  To: JANUSZ SUCHOROLSKI            Recvd: NO  
Subj: COMM PORT 3...                 Conf: (2) Quik_Bas
 JS>        How can you recognise that a particular PC has COM1, COM2, COM3
 JS> or COM4 and which port is used with a modem attached ? I am going to try

 JS> But then again it must have been done 1000 of time before, and I'm sure
 JS> you have a well behaving code handy, right ? Thank you for placing it if

Thanks for the vote of confidence, but I haven't worked with communications
much, and not at all in the past few years.  However, the
COMM port address' returned by PEEKing the BIOS locations
will reveal if they exist.  A return value of zero will
indicate that the given port doesn't exist.

DEFINT A-Z
DECLARE FUNCTION CommExist(Port)

FOR i = 1 TO 4
     IF CommExist(i) THEN
          PRINT "COMM Port";i;"exists"
     ELSE
          PRINT "COMM Port";i;"does NOT exist"
     ENDIF
NEXT
END
FUNCTION CommExist(Port)
     Addr = &H400+(Port-1)*2
     DEF SEG = 0
     Addr1 = PEEK(Addr)
     Addr2 = PEEK(Addr+1)
     DEF SEG
     IF Addr1 > 0 OR Addr2 > 0 THEN
          CommExist = -1
     ELSE
          CommExist = 0
     ENDIF
END FUNCTION
---
 * Origin: Midnight Micro!  V.32/REL  (918)451-3306 (1:170/600)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET