BBS: Inland Empire Archive Date: 04-09-92 (08:58) Number: 111 From: MATT HART Refer#: NONE To: JON SPRINGER Recvd: NO Subj: Comm port 3... Conf: (2) Quik_Bas
JS> Argh! Does anybody know how to access Comm port 3 for use JS> with the modem from Quickbasic? I get some dumb error telling me You have to fool QB. DEF SEG = 0 ' Set segment to PEEK ' First, save COM1's address Com1.1 = PEEK(&H400) : Com1.2 = PEEK(&H401) ' Now, get COM3's address Com3.1 = PEEK(&H404) : Com3.2 = PEEK(&H405) ' Now, set COM1's address to COM3's POKE &H400,Com3.1 : POKE &H401,Com3.2 ' Now, set COM3's address to COM1's POKE &H404,Com1.1 : POKE &H405,Com1.2 DEF SEG This swaps the address' for COM1 and COM3. Now, open and access COM1 from QB, and you will actually be accessing COM3. Swap them back to access COM1 again. When finished, CLOSE the COM1 buffer once for COM3, swap the address', and CLOSE again for COM1 (if both were open). JS> and I was wondering if there is a problem using Global variables JS> among modules, because I suspect the program will eat up 128k and You can still CHAIN between programs. Compile using the BRUN module and you can preserve variables across programs with COMMON SHARED statements. Otherwise, you can pass variables as parameters to SUB procedures, or you can share them with either COMMON SHARED or a block common (COMMON SHARED /blockname/). The memory eaten up by variables depends on their type. I guess I should first explain memory segmentation in QB. DGroup : 64K of system memory reserved for variable length strings, simple variables (non array numerics), TYPE definitions, GOSUB and procedure stack, pointers to array numerics, static arrays, COMMON SHARED pointers. Code Memory : The memory taken up by the EXE code itself. Far memory : All the rest of system memory. Used for fixed length string arrays, numeric arrays, TYPE arrays. So a 128K program will have these 3 distinct memory sections. 64K of dgroup should be preserved where it is possible, but it can also be specifically utilized for speed (mainly by using STATIC arrays and variables). The memory preserved across a chain will be the dgroup and far memory specified by COMMON SHARED statements. Block commons are shared between linked modules. All Code memory will be released, and then re-used by the EXE code of the next program. --- * Origin: Midnight Micro! V.32/REL (918)451-3306 (1:170/600)
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