Area: Quik_Bas Msg: #349 Date: 02-05-93 11:47 (Public) From: Coridon Henshaw To: All Subject: Nodelist reader (FINALLY!
Hello All! I've finally finished the below code for reading a Fido standard nodelist. This could be easily modifyed to convert the nodelist to a ISAM datafile. ===Chop=== 'NAME: NODELIST.BAS 'FROM: Coridon Henshaw@1:250/820 'DESC: Nodelist reader DECLARE FUNCTION ExtractAddress$ (Zone%, Net%, Node%) DECLARE SUB PrintNodelistData (X%, Y%, Nodelist AS ANY) DECLARE FUNCTION BreakString% (OutArray() AS STRING, InString AS STRING) '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 'External function in quicklibarary for speed ' DEFINT A-Z TYPE AddrType Zone AS INTEGER Region AS INTEGER Net AS INTEGER Node AS INTEGER END TYPE TYPE NodelistType Addr AS AddrType 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 DIM NodelistBuffer(0 TO 30) AS STRING DIM Nodelist AS NodelistType OPEN "NODELIST.022" FOR INPUT AS #1 ' 'Change to match the current nodelist number ' CLS DO LINE INPUT #1, Buffer$ IF LEFT$(Buffer$, 1) <> ";" THEN Options = BreakString(NodelistBuffer(), Buffer$) SELECT CASE NodelistBuffer(0) CASE "Zone" Nodelist.Addr.Zone = VAL(NodelistBuffer(1)) CASE "Region" Nodelist.Addr.Region = VAL(NodelistBuffer(1)) CASE "Host" Nodelist.Addr.Net = VAL(NodelistBuffer(1)) CASE ELSE Nodelist.Addr.Node = VAL(NodelistBuffer(1)) END SELECT Nodelist.System = NodelistBuffer(2) Nodelist.Location = NodelistBuffer(3) Nodelist.Sysop = NodelistBuffer(4) Nodelist.Phone = NodelistBuffer(5) Nodelist.BPS = NodelistBuffer(6) IF NodelistBuffer(7) <> "" THEN NDF$ = NodelistBuffer(7) IF NodelistBuffer(8) <> "" THEN FOR X = 8 TO Options NDF$ = NDF$ + "," + NodelistBuffer(X) NEXT END IF END IF Nodelist.Flags = NDF$ PrintNodelistData 1, 1, Nodelist ERASE NodelistBuffer END IF LOOP UNTIL EOF(1) OR INKEY$ <> "" FUNCTION ExtractAddress$ (Zone, Net, Node) ExtractAddress$ = RTRIM$(LTRIM$(STR$(Zone))) + ":" + RTRIM$(LTRIM$(STR$(Net)))_ + "/" + RTRIM$(LTRIM$(STR$(Node))) END FUNCTION SUB PrintNodelistData (X, Y, Nodelist AS NodelistType) LOCATE X, Y PRINT " Address: "; ExtractAddress(Nodelist.Addr.Zone, Nodelist.Addr.Net, Nodelist.Addr.Node); " " PRINT " ĀRegion: "; RTRIM$(LTRIM$(STR$(Nodelist.Addr.Region))) PRINT "System name: "; Nodelist.System PRINT " Location: "; Nodelist.Location PRINT " Sysop: "; Nodelist.Sysop PRINT " Phone: "; Nodelist.Phone PRINT " BPS Rate: "; Nodelist.BPS PRINT " Flags: "; Nodelist.Flags END SUB ===Chop=== END Nodelist.bas ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++ ===Chop=== BEGIN Parser.bas DEFINT A-Z FUNCTION BreakString% (OutArray() AS STRING, InString AS STRING) ON LOCAL ERROR GOTO HandleError DIM Char AS STRING * 1 InString = RTRIM$(InString) OutArrayPointer = 0 InStrLength = LEN(InString) FOR Count& = 1 TO InStrLength Char = MID$(InString, Count&, 1) SELECT CASE Char CASE "," OutArrayPointer = OutArrayPointer + 1 CASE "_" OutArray(OutArrayPointer) = OutArray(OutArrayPointer)_ + " " CASE ELSE OutArray(OutArrayPointer) = OutArray(OutArrayPointer)_ + Char END SELECT NEXT BreakString = OutArrayPointer EXIT FUNCTION HandleError: BreakString = 0 RESUME ExitFunction ExitFunction: END FUNCTION ===Chop=== END Parser.bas Make the above file into a QLB (or LIB) and load (or LINK) with NODELIST.BAS. Hope someone finds this usefull. Coridon Henshaw \ Sirrus Software --- GEcho 1.00 * Origin: TCS Concordia - Mail Only - Toronto, Ontario (1:250/820)
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