Area: Quik_Bas Msg: #254 Date: 02-17-93 22:42 (Public) From: Coridon Henshaw To: All Subject: .MSG Messagebase API code
Hello All! Here's part of the full messagebase API that I promised. Untested, use at own risk! ===Chop=== 'NAME: MSGAPI.BAS 'FROM: Coridon Henshaw@1:250/802 'DESC: .MSG base API code 'Copyright 1993 by Coridon Henshaw ' 'This code may be used in any program costing under $30. This code may also be 'used in freeware programs. 'This code MAY NOT be used in any crippleware program '$INCLUDE: 'FIDO.BI' DECLARE FUNCTION MSGDeleteMessage% (BaseNumber%, Number%) DECLARE FUNCTION MSGPutMessage% (BaseNumber%, MsgHdr AS ANY, Text$) DECLARE FUNCTION MSGGetHdr% (BaseNumber%, Number%, MsgHdr AS ANY) DECLARE FUNCTION MSGPutHdr% (BaseNumber%, Number%, MsgHdr AS ANY) DECLARE FUNCTION MSGCreateIndex% (BaseNumber%) DECLARE FUNCTION MSGInit% (Path$, BaseNumber%) DECLARE FUNCTION MSGDeInit% (BaseNumber%) DECLARE FUNCTION MSGGetMessage% (BaseNumber%, Number%, MsgHdr AS ANY, Text$) CONST True = -1, False = NOT True, MaxBases = 1 DEFINT A-Z TYPE MsgType BasePaths(0 TO MaxBases) AS STRING * 65 MaxMsgs(0 TO MaxBases) AS INTEGER Init(0 TO MaxBases) AS INTEGER END TYPE DIM MsgHdr AS MSGHeaderType DIM SHARED Msg AS MsgType '$DYNAMIC DIM SHARED Msgs(16384, 0 TO MaxBases) AS INTEGER REM $STATIC FUNCTION MSGDeInit (BaseNumber%) FOR X& = 1 TO Msg.MaxMsgs(BaseNumber%) Msgs(X&, BaseNumber%) = 0 NEXT Msg.Init(BaseNumber%) = False Msg.MaxMsgs(BaseNumber%) = 0 Msg.BasePaths(BaseNumber%) = "" DeInitBase% = True END FUNCTION FUNCTION MSGDeleteMessage (BaseNumber, Number%) IF Msg.Init(BaseNumber) = True THEN Filename$ = RTRIM$(Msg.BasePaths(BaseNumber)) + RTRIM$(LTRIM$(STR$(Msgs(Number%, BaseNumber)))) + ".MSG" KILL Filename$ FOR X& = 1 TO 99999999 IF DIR$(RTRIM$(LTRIM$(STR$(X&))) + ".MSG") = _ RTRIM$(LTRIM$(STR$(X&))) + ".MSG" THEN Msgs(Pointer&, BaseNumber) = X& Pointer& = Pointer& + 1 END IF NEXT END IF END FUNCTION FUNCTION MSGGetHdr (BaseNumber%, Number%, MsgHdr AS MSGHeaderType) 'IMPORT: BaseNumber% ' Number% 'EXPORT: MsgHdr IF BaseNumber% >= 0 AND BaseNumber% <= MaxBases THEN IF Msg.Init(BaseNumber%) = True THEN IF Number% <= Msg.MaxMsgs(BaseNumber%) THEN Handle = FREEFILE OPEN RTRIM$(Msg.BasePaths(BaseNumber)) + _ RTRIM$(LTRIM$(STR$(Msgs(Number%, BaseNumber%)))) + ".MSG" FOR BINARY AS Handle GET #Handle, , MsgHdr CLOSE Handle MSGGetHdr = True END IF END IF END IF END FUNCTION FUNCTION MSGGetMessage (BaseNumber%, Number%, MsgHdr AS MSGHeaderType, Text$) 'IMPORT: BaseNumber% ' Number% 'EXPORT: MsgHdr ' Text$ IF BaseNumber% >= 0 AND BaseNumber% <= MaxBases THEN IF Msg.Init(BaseNumber%) = True THEN IF Number% <= Msg.MaxMsgs(BaseNumber%) THEN Handle = FREEFILE OPEN RTRIM$(Msg.BasePaths(BaseNumber)) + _ RTRIM$(LTRIM$(STR$(Msgs(Number%, BaseNumber%)))) + ".MSG" FOR BINARY AS Handle GET #Handle, , MsgHdr Buffer$ = STRING$(LOF(Handle) - LOC(Handle), 1) GET #Handle, , Buffer$ Text$ = Buffer$ CLOSE Handle MSGGetMessage = True END IF END IF END IF END FUNCTION FUNCTION MSGInit (Path$, BaseNumber) IF RIGHT$(Path$, 1) <> "\" THEN Path$ = Path$ + "\" FOR X& = 1 TO 99999999 IF DIR$(RTRIM$(LTRIM$(STR$(X&))) + ".MSG") = RTRIM$(LTRIM$(STR$(X&)))_ + ".MSG" THEN Msgs(Pointer&, BaseNumber) = X& Pointer& = Pointer& + 1 END IF NEXT Msg.Init(BaseNumber) = True Msg.MaxMsgs(BaseNumber) = Pointer& Msg.BasePaths(BaseNumber) = Path$ END FUNCTION FUNCTION MSGPutHdr (BaseNumber%, Number%, MsgHdr AS MSGHeaderType) 'IMPORT: BaseNumber% ' Number% ' MsgHdr IF BaseNumber% >= 0 AND BaseNumber% <= MaxBases THEN IF Msg.Init(BaseNumber%) = True THEN IF Number% <= Msg.MaxMsgs(BaseNumber%) THEN Handle = FREEFILE OPEN RTRIM$(Msg.BasePaths(BaseNumber)) + _ RTRIM$(LTRIM$(STR$(Msgs(Number%, BaseNumber%)))) + ".MSG" FOR BINARY AS Handle PUT #Handle, 1, MsgHdr CLOSE Handle MSGPutHdr = True END IF END IF END IF END FUNCTION FUNCTION MSGPutMessage (BaseNumber%, MsgHdr AS MSGHeaderType, Text$) 'IMPORT: BaseNumber% ' MsgHdr ' Text$ IF BaseNumber% >= 0 AND BaseNumber% <= MaxBases THEN IF Msg.Init(BaseNumber%) = True THEN Number& = 1 FOR X& = 0 TO Msg.MaxMsgs(BaseNumber%) IF Msgs(X&, BaseNumber%) > Number& THEN Number& = _ Msgs(X&, BaseNumber%) NEXT Handle = FREEFILE Filename$ = RTRIM$(Msg.BasePaths(BaseNumber)) + _ RTRIM$(LTRIM$(STR$(Msgs(Number&, BaseNumber)))) + ".MSG" OPEN Filename$ FOR BINARY AS Handle PUT #Handle, , MsgHdr GET #Handle, , Text$ CLOSE Handle Msg.MaxMsgs(BaseNumber%) = Msg.MaxMsgs(BaseNumber%) + 1 Msgs(Msg.MaxMsgs(BaseNumber%), BaseNumber%) = Number& MSGPutMessage = True END IF END IF -end-
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