BBS: Inland Empire Archive Date: 07-25-92 (14:54) Number: 107 From: MAX VAUGHAN Refer#: NONE To: CURTIS STRATMAN Recvd: NO Subj: *.Qwk Packets Conf: (2) Quik_Bas
Here is a small (very) reader I threw together to read the messages in the MESSAGES.DAT file in a QWK packet. This should help you get started with your project. Anyone is welcome to use this as they see fit. If somebody can show me a faster way to get the text to print to the screen I would be very grateful. BTW I have Crescents QuickPak Pro and will try some of the string routines in there to speed things up a bit. This is very crude but for a quick and dirty reader it works ok. --------------CUT HERE------------------------------ DEFINT A-Z REM REM *** QWKREAD V 0.01 (C)1992 Max Vaughan *** 'ignore this CLS TYPE InfoBlock 'Defines info available in message MsgStatus AS STRING * 1 'header block for the type array MsgNum AS STRING * 7 Date AS STRING * 8 Time AS STRING * 5 MsgTo AS STRING * 25 MsgFrom AS STRING * 25 MsgSubject AS STRING * 25 MsgPass AS STRING * 12 MsgRef AS STRING * 8 MsgBlocks AS STRING * 6 MsgActive AS STRING * 1 MsgConf AS INTEGER MsgTag AS STRING * 1 END TYPE DIM MInfo AS InfoBlock DIM MText AS STRING * 128 FilePoint! = 129 'First 128byte block is not a message header or 'block of text so adjust for that FileName$ = "MESSAGES.DAT" OPEN FileName$ FOR BINARY AS #1 Length! = LOF(1) 'Get length of file DisplayMsg: CLS GET #1, FilePoint!, MInfo 'Load in message header block into MInfo array PRINT "MsgNum:"; MInfo.MsgNum; " Date:"; MInfo.Date; " Time:"; MInfo.Time PRINT "To: "; MInfo.MsgTo; " From: "; MInfo.MsgFrom PRINT "Subject-> "; MInfo.MsgSubject; " Conf:"; MInfo.MsgConf PRINT STRING$(79, "=") TextBlocks% = VAL(MInfo.MsgBlocks) 'Get number of 128byte text blocks. GOSUB GetText GetKey: PRINT STRING$(79, "=") PRINT " PRESS N = Next Message or X = EXIT" DO A$ = INKEY$ LOOP WHILE A$ = "" A$ = UCASE$(A$) SELECT CASE A$ CASE IS = "N" FilePoint! = FilePoint! + (TextBlocks% * 128) IF FilePoint! > (Length! - (TextBlocks% * 128)) THEN BEEP PRINT " End of messages........" END END IF GOTO DisplayMsg CASE IS = "X" END CASE ELSE GOTO GetKey END SELECT END GetText: LineCount% = 0 A$ = "" FOR X% = 1 TO TextBlocks% 'Set up to read each Text block GET #1, , MText$ 'Load first 128byte block of text into MText array FOR S% = 1 TO 128 'This allows us to look at each MB$ = MID$(MText$, S%, 1) 'of the bytes in the 128byte block 'and take action on it accordingly SELECT CASE MB$ CASE IS = CHR$(0) 'ignore any nulls CASE IS = CHR$(227) 'Check for QWK messages CR/LF (pi) PRINT A$ 'and print line of text if there is CR/LF A$ = "" 'Reset for the next line to print LineCount% = LineCount% + 1 IF LineCount% = 20 THEN 'Keep text from scrolling LineCount% = 0 'until it's been read. PRINT " (Press any key for more....)" DO WHILE INKEY$ = "": LOOP END IF CASE ELSE A$ = A$ + MB$ 'Assemble each line of text to print END SELECT NEXT S% NEXT X% RETURN END --------CUT HERE----------------------- Another fine example of the KISS method aka Keep It Simple Stupid * SLMR 2.1a * Captain Kirk: We come in peace. Shoot to kill. --- WM v2.03/91-0012 * Origin: Com-Dat BBS Hillsboro, OR. HST (503) 681-0543 (1:105/314)
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