BBS: Inland Empire Archive Date: 02-07-93 (17:37) Number: 353 From: ZACK JONES Refer#: NONE To: ALL Recvd: NO Subj: Code Conf: (2) Quik_Bas
Howdy All! Here's some nifty code I snagged from BASIC7 - Credit goes to Marty Duplissey - since it's his code: Ä FidoNet Echo: BASIC7 (PDS Programming) (1:387/641) ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ BASIC7 Ä Msg : 98 of 100 + 100 From : MARTY DUPLISSEY 1:398/1 06 Feb 93 21:06:44 To : All 07 Feb 93 17:26:38 Subj : Call interrupt stuff ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Ä Blabbering as if I knew what I was talking about! Ok Guys I'm sure you know all about Call interrupt. I just discovered how to use this nifty part of Qbx. And I wanted to share some of my code with you Guys. I know you've already seen it a hundred times but just in case some wreched soul hasn'nt figured it out yet (like myself yesterday) here it is. This is just a small example program to Get the Dos version and Free and total disk space. ------------------------------CUT--------------------------- ------------------- DEFINT A-Z DECLARE SUB Getspace (disk%, freediskspace&, totaldiskspace&) DECLARE FUNCTION Getver! () '$INCLUDE: 'qbx.bi' DIM SHARED inregs AS regtype DIM SHARED outregs AS regtype a = 0 DO UNTIL a = 1 CLS INPUT "ENTER A DISK DRIVE. A, B ect. ", a$ IF LEN(a$) = 0 THEN EXIT DO a$ = UCASE$(LEFT$(a$, 1)) disk% = ASC(a$) - 64 Getspace disk%, freediskspace&, totaldiskspace& free$ = STR$(freediskspace&) total$ = STR$(totaldiskspace&) ver$ = STR$(Getver!) PRINT "Total disk space on Drive " + a$ + ":" + " is" PRINT total$ + " Bytes" PRINT "The free space is" PRINT free$ + " Bytes" PRINT "You are using DOS Version" + ver$ DO WHILE INKEY$ = "": LOOP LOOP SUB Getspace (disk%, freediskspace&, totaldiskspace&) inregs.ax = &H3600 'interrupt 36 of dos interrupt 21 inregs.dx = disk% 'disk number A=1, B=2 etc. 0 = default CALL Interrupt(&H21, inregs, outregs) IF outregs.ax <> &HFFFF THEN 'if invalid disk number sectors& = outregs.ax 'sectors IF outregs.bx >= 0 THEN 'free clusters freeclusters& = outregs.bx ELSE freeclusters& = outregs.bx + 65536 END IF bytes& = outregs.cx 'bytes per cluster IF outregs.dx >= 0 THEN 'total clusters totalclusters& = outregs.dx ELSE totalclusters& = outregs.dx + 65536 END IF freediskspace& = sectors& * freeclusters& * bytes& totaldiskspace& = sectors& * bytes& * totalclusters& ELSE totaldiskspace& = 0 freediskspace& = 0 END IF END SUB FUNCTION Getver! inregs.ax = &H3000 'interrupt 30 of DOS interrupt 21 CALL Interrupt(&H21, inregs, outregs) major% = outregs.ax AND 255 'Get major version number minor! = outregs.ax / 256 'minor version number IF minor! <> 0 THEN minor! = FIX(minor!) / 100 'Get the decimal 'place right Getver! = major% + minor! END FUNCTION Take Care, Zack Jones --- GoldED 2.41.B1207+1536 * Origin: Zack's Shack San Antonio TX (210) 653-2115 (1:387/641)
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