BBS: Inland Empire Archive Date: 02-15-93 (16:44) Number: 355 From: QUINN TYLER JACKSON Refer#: NONE To: ALL Recvd: NO Subj: nodelist.bas Conf: (2) Quik_Bas
'QBS: Yes 'NAME: NODELIST.BAS 'DESC: Nodelist reader and compiler 'DIALECT: PDS 7.1 or VBDOS 1.0 'AUTHOR: Quinn Tyler Jackson 13 Feb 1993 ' (With great thanks to Coridon Henshaw's original NODELIST.BAS) ' (My version is 10 times faster than his was.) '$DYNAMIC DEFINT A-Z TYPE NodelistType Zone AS INTEGER Region AS INTEGER Net AS INTEGER Node AS INTEGER System AS STRING * 36 Location AS STRING * 36 Sysop AS STRING * 36 Phone AS STRING * 20 BPS AS STRING * 5 Flags AS STRING * 50 END TYPE CONST ENTRY_BUFFER = 256 CONST DATA_FIELDS = 8 DIM SHARED BufferPtr AS INTEGER CLS ParseNodelist "NODELIST.022", "NODELIST.DBF" REM $STATIC FUNCTION BreakString% (OutArray() AS STRING * 50, InString AS STRING) ON LOCAL ERROR GOTO HandleError Ptr = 1 DO Comma = INSTR(Ptr, InString, ",") OutArray(OutArrayPtr) = MID$(InString, Ptr, (Comma - Ptr)) Ptr = Comma + 1 OutArrayPtr = OutArrayPtr + 1 IF OutArrayPtr = 7 THEN OutArray(7) = MID$(InString, Ptr) EXIT DO END IF LOOP UNTIL Comma = 0 BreakString = OutArrayPtr EXIT FUNCTION HandleError: 'BreakString = 0 RESUME ExitFunction ExitFunction: END FUNCTION STATIC SUB FlushBuffers (FlushFileHandle, NodeList() AS NodelistType) FOR Ptr = 0 TO BufferPtr RecNum = RecNum + 1 PUT #FlushFileHandle, RecNum, NodeList(Ptr) NEXT Ptr REDIM NodeList(0 TO ENTRY_BUFFER) AS NodelistType BufferPtr = 0 END SUB SUB ParseNodelist (NodelistFile AS STRING, ParsedListFile AS STRING) StartTime! = TIMER IF DIR$(ParsedListFile) <> "" THEN KILL ParsedListFile END IF '$STATIC DIM NodelistBuffer(0 TO 7) AS STRING * 50 DIM NodeList(0 TO ENTRY_BUFFER) AS NodelistType '$DYNAMIC BufferPtr = 0 NodelistHandle = FREEFILE OPEN NodelistFile FOR INPUT AS NodelistHandle LEN = 1024 ParsedListHandle = FREEFILE OPEN ParsedListFile FOR RANDOM AS ParsedListHandle LEN = LEN(NodeList(0)) DO LINE INPUT #NodelistHandle, Buffer$ Options = BreakString(NodelistBuffer(), Buffer$) SELECT CASE LEFT$(Buffer$, 1) CASE "Z" TempZone = VAL(NodelistBuffer(1)) CASE "R" TempRegion = VAL(NodelistBuffer(1)) CASE "H" SELECT CASE LEFT$(Buffer$, 3) CASE "Hos" TempNet = VAL(NodelistBuffer(1)) CASE "Hub" TempNode = VAL(NodelistBuffer(1)) END SELECT CASE "," TempNode = VAL(NodelistBuffer(1)) CASE ELSE GOTO JumpPast END SELECT NodeList(BufferPtr).Zone = TempZone NodeList(BufferPtr).Region = TempRegion NodeList(BufferPtr).Net = TempNet NodeList(BufferPtr).Node = TempNode NodeList(BufferPtr).System = NodelistBuffer(2) NodeList(BufferPtr).Location = NodelistBuffer(3) NodeList(BufferPtr).Sysop = NodelistBuffer(4) NodeList(BufferPtr).Phone = NodelistBuffer(5) NodeList(BufferPtr).BPS = NodelistBuffer(6) NodeList(BufferPtr).Flags = NodelistBuffer(7) REDIM NodelistBuffer(0 TO 7) AS STRING * 50 BufferPtr = BufferPtr + 1 IF BufferPtr = ENTRY_BUFFER THEN FlushBuffers ParsedListHandle, NodeList() END IF JumpPast: LOOP UNTIL EOF(NodelistHandle) FlushBuffers ParsedListHandle, NodeList() PRINT INT(TIMER - StartTime! + .5); "seconds." END SUB * SLMR 2.1a * --- Maximus 2.01wb * Origin: VKUG/VPCC QuickBasic Echo - Richmond, BC (1:153/151)
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