Legacy app: Net-Chat 2.0a (Quick Basic 4.5, DOS)

By | 2015.01.02

Recently got some old tapes recovered. There I found an old chat program I wrote in QB45 in 1996 (I was 16 years old). I installed Windows XP under Hyper-V to test it out since Windows 8 doesn’t run 16-bit DOS programs. But I wanted to have the executable work on my computer so I searched and found QB64 – compiled just fine under Windows 8.1.

It uses a shared file to store chat. I put it on a shared network drive so we could chat over the network. I was experimenting with IPX at that time, but then Windows and internet came and I went over to VB and TCP/IP. So this was my last app in QB45. Good times. :)

Executable and source code here.

19960101 NetChat 2

19960101 NetChat 4

19960101 NetChat 3

The source code:

DECLARE SUB Help ()
DECLARE SUB UserUpdIntCh ()
DECLARE SUB UserSave ()
DECLARE SUB LogOnFindUser ()
DECLARE SUB UserNewColor ()
DECLARE SUB UserMenu ()
DECLARE SUB LogOn ()
DECLARE SUB ChatViewLine ()
DECLARE SUB ChatOff ()
DECLARE SUB ChatOn ()
DECLARE SUB ChatFileNumber ()
DECLARE SUB ChatNewName ()
DECLARE SUB ChatUpdate ()
DECLARE SUB ChatSend ()
DECLARE SUB Chat ()
DECLARE SUB About ()
DECLARE SUB RedrawBack ()
DECLARE SUB GetChoice ()
DECLARE SUB DialogBox ()
DECLARE SUB HeadLine ()
DECLARE SUB DrawMainMenu ()
DECLARE SUB InitStartUp ()



COMMON SHARED Name$, Alias$, PWD$, CLR$, UpdInterval, LineNr, UserID, SysOp, Users, Mes, NamAli
COMMON SHARED Topic$, Path$, BName$, LineNr$
COMMON SHARED True, False
COMMON SHARED MenuItem%, Key$, ReDraw, SendText$, TimeOfReturn, UpdNow, MesSent, ClockShow, Exist, Changed, OldSend$, ErLevel, Att
COMMON SHARED DiagX, DiagY, DiagFC, DiagBC, DiagText$



TYPE PI
    LogDT AS STRING * 21
    UNumber AS STRING * 4
    UName AS STRING * 20
    UAlias AS STRING * 20
    UPWD AS STRING * 6
    UColor AS STRING * 2
    UAlNa AS STRING * 1
    UpdInt AS STRING * 1
    SysOp AS STRING * 1
END TYPE ' 50 Bytes!!!



TYPE FR
    PCLR AS STRING * 2
    PName AS STRING * 20
    PLine AS STRING * 60
END TYPE ' 82 Bytes!!!



RANDOMIZE TIMER




ON ERROR GOTO Er



True = 0
False = -1



'UserUpdIntCh    '*******************************************



IF COMMAND$ = "" THEN Path$ = ".\" ELSE Path$ = COMMAND$
' Network Path
BName$ = "Net-Chat." ' First Name On File



Name$ = "" ' User Name
Alias$ = "" ' User Alias
PWD$ = "" ' User Password
SysOp = 0 ' SysOp Level
CLR = INT(RND * 14) + 1 ' User Color
CLR$ = STRING$(2 - LEN(MID$(STR$(CLR), 2, 2)), "0") + MID$(STR$(CLR), 2, 2)
' In String
NamAli = 0 ' Name/Alias, 0=Name, 1=Alias
UpdInterval = 3 ' Update Intervall While Chatting
LineNr = 0 ' Current Chatting Line
UserID = INT(RND * 8765) + 1234 ' Random User Number Always 4 Digit
LogOnDate$ = DATE$ + " - " + TIME$ ' Time For FIRST LogOn




InitStartUp



LogOn



ExitAll = False



WHILE ExitAll
    DrawMainMenu
    IF Key$ = CHR$(27) THEN ExitAll = True
    COLOR 7, 0
WEND
IF NamAli = 1 THEN SWAP Alias$, Name$



SND$ = "99" + Name$ + " Left Net-Chat."
SND$ = SND$ + SPACE$(82 - LEN(SND$))
OPEN Path$ + BName$ + "L" + LineNr$ FOR APPEND SHARED AS #1
PRINT #1, SND$
CLOSE #1
IF NamAli = 1 THEN SWAP Alias$, Name$



 
VIEW PRINT 1 TO 25



COLOR 7, 0: CLS
COLOR 14, 1: PRINT "          Net-Chat v2.0a [Beta]  (c) Copyright 1996 By Tedd Hansen             "
COLOR 7, 0: PRINT
PRINT "Program Was Ended Succesfully On User Request."
PRINT
END



Er:
ErLevel = 1
RESUME NEXT



SUB About
HeadLine
COLOR 15, 1
LOCATE 6, 1: PRINT STRING$(80, "Í")
LOCATE 24, 1: PRINT STRING$(80, "Í")
LOCATE 6, 1: PRINT "É"
LOCATE 6, 80: PRINT "»"
LOCATE 24, 1: PRINT "È"
LOCATE 24, 80: PRINT "¼"
FOR A = 7 TO 23
    LOCATE A, 1: PRINT "º" + STRING$(78, " ") + "º"
NEXT A
LOCATE 7, 4: PRINT "ABOUT NET-CHAT v2.0a"
COLOR 10, 1
LOCATE 10, 4: PRINT "Net-Chat version 2.0 is protected by international copyright laws.          "
LOCATE 11, 4: PRINT "Please don't copy, modify or distribue this program without permition       "
LOCATE 12, 4: PRINT "from the author Tedd Hansen!                                                "
LOCATE 13, 4: PRINT "                                                                            "
LOCATE 14, 4: PRINT "Net-Chat v2.0 Was designed to work in DOS, Windows 3.x And Windows 95       "
LOCATE 15, 4: PRINT "Enviroments. It works in DOS Version 2.10 > 7.00! The author will not       "
LOCATE 16, 4: PRINT "take any responsibility for any damages caused by this program, or the      "
LOCATE 17, 4: PRINT "user using it!!! (With Proper Use Nothing Should Go Wrong!)                 "
LOCATE 18, 4: PRINT "                                                                            "
LOCATE 19, 4: PRINT "If you have any suggestions, comments or something like that,               "
LOCATE 20, 4: PRINT "Feel Free To E-Mail Me:                                                     "
LOCATE 21, 4: PRINT "tedd@sn.no                                                                  "
LOCATE 22, 4: PRINT "                                                                            "
LOCATE 23, 4: PRINT "GOOD LUCK!                                                                  "



GetChoice
ReDraw = 1
KeyAccept = True
Key$ = ""
IF Key$ = CHR$(27) THEN EXIT SUB
HeadLine
COLOR 15, 1
LOCATE 6, 1: PRINT STRING$(80, "Í")
LOCATE 24, 1: PRINT STRING$(80, "Í")
LOCATE 6, 1: PRINT "É"
LOCATE 6, 80: PRINT "»"
LOCATE 24, 1: PRINT "È"
LOCATE 24, 80: PRINT "¼"
FOR A = 7 TO 23
    LOCATE A, 1: PRINT "º" + STRING$(78, " ") + "º"
NEXT A
LOCATE 7, 4: PRINT "Thanks to:"
COLOR 10, 1
LOCATE 10, 4: PRINT "                                                                            "
LOCATE 11, 4: PRINT "All the BETA testers on Skarnes Videreg†ende Skole                          "
LOCATE 12, 4: PRINT "Tedd Hansen"
LOCATE 13, 4: PRINT ""
LOCATE 14, 4: PRINT ""
LOCATE 15, 4: PRINT ""
LOCATE 16, 4: PRINT ""
LOCATE 17, 4: PRINT ""
LOCATE 18, 4: PRINT ""
LOCATE 19, 4: PRINT ""
LOCATE 20, 4: PRINT ""
LOCATE 21, 4: PRINT ""
LOCATE 22, 4: PRINT ""
COLOR 12, 1



       
GetChoice
ReDraw = 1
KeyAccept = True
Key$ = ""
END SUB



SUB Chat
ChatOn
OldSend$ = ""
WIDTH 80, 25
VIEW PRINT 1 TO 5
COLOR 7, 0: CLS
VIEW PRINT 1 TO 25



COLOR 14, 1: PRINT SPACE$(80 * 2)
LOCATE 1, 2: PRINT "You Are Currently Attached To Line: ";: COLOR 0, 3: PRINT STRING$(3 - LEN(STR$(LineNr)), "0") + MID$(STR$(LineNr), 2, 2);
COLOR 14, 1: PRINT "  And The Topic Is: ";: COLOR 0, 3: PRINT Topic$ + STRING$(20 - LEN(Topic$), "°")
COLOR 14, 1: LOCATE 2, 2: PRINT "There Are ";: COLOR 0, 3: PRINT STRING$(3 - LEN(MID$(STR$(Users), 2, 3)), "°") + MID$(STR$(Users), 2, 3);: COLOR 14, 1: PRINT " Other Users On This Line Including You."
VIEW PRINT 5 TO 25
COLOR 7, 0: CLS
ChatUpdate
VIEW PRINT 5 TO 25
COLOR 7, 0
TxtPos = 1



UpdNow = INT(TIMER + UpdInterval)
DO
    IF VAL(CLR$) <= 0 OR VAL(CLR$) >= 16 THEN CLR$ = "07"
    VIEW PRINT 1 TO 25
    COLOR 14, 1
    LOCATE 1, 2: PRINT "You Are Currently Attached To Line: ";: COLOR 0, 3: PRINT STRING$(3 - LEN(STR$(LineNr)), "0") + MID$(STR$(LineNr), 2, 2);
    COLOR 14, 1: PRINT "  And The Topic Is: ";: COLOR 0, 3: PRINT Topic$ + STRING$(20 - LEN(Topic$), "°")
  COLOR 14, 1: LOCATE 2, 2: PRINT "There Are "; : COLOR 0, 3: PRINT STRING$(3 - LEN(MID$(STR$(Users), 2, 3)), "°") + MID$(STR$(Users), 2, 3); : COLOR 14, 1: PRINT " Other Users On This Line Including You. Messages Sendt: "; : COLOR 0, 3: PRINT  _
STRING$(3 - LEN(MID$(STR$(Mes), 2, 3)), "0") + MID$(STR$(Mes), 2, 3)
    VIEW PRINT 5 TO 25
    LOCATE 25, 1, 0



    COLOR VAL(CLR$), 0
    PRINT RIGHT$(Name$ + SPACE$(20 - LEN(Name$)) + ": " + SendText$, 79);
    IF NOT LEN(SendText$) >= 79 THEN PRINT " ";
    LOCATE 24, 1: COLOR 15, 1: PRINT " Enter Text To Send To Others:                <Ù Send    ALT+M MENU    ESC Exit "
    COLOR 7, 0
    IF LEN(SendText$) = 0 THEN
        CurPosi = 23
    ELSEIF LEN(SendText$) >= 58 THEN CurPosi = 80
    ELSE CurPosi = LEN(SendText$) + 23
    END IF
    COLOR 7, 0: LOCATE 25, CurPosi, 1




    DO
        Key$ = INKEY$
        'VIEW PRINT 2 TO 25
        'COLOR 14, 1: LOCATE 2, 60, 0: PRINT DATE$ + " - " + TIME$;
        IF TIMER - 100 > UpdNow THEN ChatUpdate: UpdNow = INT(TIMER + UpdInterval)
     
        IF TIMER > UpdNow THEN ChatUpdate: UpdNow = INT(TIMER + UpdInterval)
        COLOR 7, 0: LOCATE 25, CurPosi, 1
    LOOP WHILE Key$ = ""
    IF LEN(SendText$) >= 1 AND Key$ = CHR$(8) THEN Key$ = "": SendText$ = LEFT$(SendText$, LEN(SendText$) - 1)
    IF Key$ = CHR$(0) + CHR$(19) THEN SendText$ = OldSend$: Key$ = "": ChatUpdate
    IF Key$ = CHR$(0) + "." THEN ClockShow = 1: ChatNewName: Key$ = "": ChatUpdate
    IF Key$ = CHR$(8) THEN Key$ = ""
    IF Key$ = CHR$(13) AND LEN(SendText$) = 0 THEN Key$ = "": UpdNow = 0: ChatUpdate
    IF Key$ = CHR$(13) THEN OldSend$ = SendText$: Key$ = "": ChatSend: LOCATE 25, 1, 0: PRINT SPACE$(80);: SendText$ = "": ChatUpdate
    IF Key$ = CHR$(27) AND LEN(SendText$) = 0 THEN EXIT DO ELSE IF Key$ = CHR$(27) THEN SendText$ = "": Key$ = "": LOCATE 25, 1: PRINT SPACE$(80);
    IF LEFT$(Key$, 1) = CHR$(0) THEN Key$ = ""
    IF Key$ = "" THEN Key$ = CHR$(13)
    X = ASC(Key$)
    IF NOT Key$ = CHR$(27) THEN IF X <= 31 AND X >= 6 THEN Key$ = ""



    SendText$ = SendText$ + Key$
    SendText$ = LEFT$(SendText$, 138)
    IF LEN(SendText$) = 58 THEN BEEP
LOOP UNTIL EA = 1



ChatOff
END SUB



SUB ChatFileNumber
DiagX = 0
DiagY = 6
DiagFC = 14
DiagBC = 3
DiagText$ = "Change Line To Chat On (Current Line" + STR$(LineNr) + ") [Push ALT+L To View Lines]"
DialogBox



DiagFC = 15
DiagBC = 3
DiagX = 0
DiagY = 11
DiagText$ = "New Line: " + SPACE$(2)
DialogBox




DO
    COLOR 3, 0
    LOCATE 12, 46: PRINT NL$ + STRING$(2 - LEN(NL$), "°")
    DO
        Key$ = INKEY$
        COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
    LOOP WHILE Key$ = ""
    IF Key$ = CHR$(0) + "&" THEN ChatViewLine: EXIT SUB



    IF Key$ = CHR$(8) AND LEN(NL$) >= 1 THEN NL$ = LEFT$(NL$, LEN(NL$) - 1)
    IF ASC(Key$) >= 48 AND ASC(Key$) <= 57 THEN NL$ = NL$ + Key$
    NL$ = LEFT$(NL$, 2)



LOOP UNTIL Key$ = CHR$(27) OR Key$ = CHR$(13)
IF Key$ = CHR$(27) THEN EXIT SUB



LineNr = VAL(NL$)



DiagX = 0
DiagY = 0
DiagFC = 0
DiagBC = 0
DiagText$ = "You Are Now Connected To Line" + STR$(LineNr)
DialogBox



T = TIMER + 5
DO
    Key$ = INKEY$
    COLOR 15, 1: LOCATE 10, 61, 0: PRINT RIGHT$(DATE$, 1) + " - " + TIME$
    IF TIMER > T THEN EXIT DO
LOOP WHILE Key$ = ""
Key$ = ""
 
END SUB



SUB ChatNewName
DiagX = 0: DiagY = 6: DiagFC = 14: DiagBC = 3
DiagText$ = "Change The Topic Of The Current Conversation Line (Line" + STR$(LineNr) + ")"
DialogBox



DiagX = 0: DiagY = 11: DiagFC = 14: DiagBC = 3
DiagText$ = "New Topic: " + SPACE$(20)
DialogBox




DO
    COLOR 3, 0
    LOCATE 12, 38: PRINT NT$ + STRING$(20 - LEN(NT$), "°")
    DO
        Key$ = INKEY$
        IF ClockShow = 0 THEN COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
    LOOP WHILE Key$ = ""
    IF Key$ = CHR$(8) AND LEN(NT$) >= 1 THEN NT$ = LEFT$(NT$, LEN(NT$) - 1)
    OKASCII = 0
    IF ASC(Key$) = 134 THEN OKASCII = 1
    IF ASC(Key$) = 143 THEN OKASCII = 1
    IF ASC(Key$) = 145 THEN OKASCII = 1
    IF ASC(Key$) = 146 THEN OKASCII = 1
    IF ASC(Key$) = 155 THEN OKASCII = 1
    IF ASC(Key$) = 157 THEN OKASCII = 1
    IF ASC(Key$) >= 32 AND ASC(Key$) <= 122 OR OKASCII = 1 THEN NT$ = NT$ + Key$
    NT$ = LEFT$(NT$, 20)
LOOP UNTIL Key$ = CHR$(27) OR Key$ = CHR$(13)
IF Key$ = CHR$(27) THEN EXIT SUB



OPEN Path$ + BName$ + "LNS" FOR APPEND SHARED AS #1
P = (LineNr * 22) + 22
'NT$ = MID$(STR$(LineNr), 2, 2) + NT$ + SPACE$(22 - LEN(LineNr$ + NT$))
'PRINT P
'  PUT #1, 1, NT$
PRINT #1, STRING$(2 - LEN(MID$(STR$(LineNr), 2, 2)), "0") + MID$(STR$(LineNr), 2, 2) + NT$ + SPACE$(22 - LEN(LineNr$ + NT$))
CLOSE #1



OPEN Path$ + BName$ + "T" + LineNr$ FOR OUTPUT SHARED AS #1
PRINT #1, NT$
CLOSE #1




DiagX = 0
DiagY = 0
DiagFC = 0
DiagBC = 0
DiagText$ = "The Topic Has Been Changed"
DialogBox



T = TIMER + 5
DO
    Key$ = INKEY$
    IF ClockShow = 0 THEN COLOR 15, 1: LOCATE 10, 58, 0: PRINT RIGHT$(DATE$, 4) + " - " + TIME$
    IF TIMER > T THEN EXIT DO
LOOP WHILE Key$ = ""
Key$ = ""
ClockShow = 0
END SUB



SUB ChatOff



SND$ = "99" + Name$ + " Left This Line."
SND$ = SND$ + SPACE$(82 - LEN(SND$))



' Minus One User On This Line...
IF NOT SysOp >= 4 THEN
    OPEN Path$ + BName$ + "N" + LineNr$ FOR APPEND SHARED AS #1
    PRINT #1, "000": CLOSE #1
    OPEN Path$ + BName$ + "N" + LineNr$ FOR INPUT SHARED AS #1
    INPUT #1, Users$: CLOSE #1
    Users = VAL(Users$) - 1
    IF Users < 0 THEN Users = 0
    OPEN Path$ + BName$ + "N" + LineNr$ FOR OUTPUT SHARED AS #1
    PRINT #1, STR$(Users): CLOSE #1



    OPEN Path$ + BName$ + "L" + LineNr$ FOR APPEND SHARED AS #1
    PRINT #1, SND$
    CLOSE #1



END IF



END SUB



SUB ChatOn



SND$ = "99" + Name$ + " Entered This Line."
SND$ = SND$ + SPACE$(82 - LEN(SND$))




' Plus One User On This Line...
IF NOT SysOp >= 4 THEN
    OPEN Path$ + BName$ + "N" + LineNr$ FOR APPEND SHARED AS #1
    PRINT #1, "000": CLOSE #1



    OPEN Path$ + BName$ + "N" + LineNr$ FOR INPUT SHARED AS #1
    INPUT #1, Users$: CLOSE #1
    Users = VAL(Users$) + 1
    OPEN Path$ + BName$ + "N" + LineNr$ FOR OUTPUT SHARED AS #1
    PRINT #1, MID$(STR$(Users), 2, 3): CLOSE #1



    OPEN Path$ + BName$ + "L" + LineNr$ FOR APPEND SHARED AS #1
    PRINT #1, SND$
    CLOSE #1



    OPEN Path$ + BName$ + "U" + LineNr$ FOR APPEND SHARED AS #1
    PRINT #1, SND$
    CLOSE #1
END IF



END SUB



SUB ChatSend



IF TIMER < MesSent AND NOT SysOp >= 4 THEN
    DO
        DiagX = 0: DiagY = 11: DiagFC = 0: DiagBC = 0
        DiagText$ = "Sorry, You Must Wait Atleast" + STR$(INT(MesSent - TIMER) + 1) + " Seconds Before Sending A New Message!"
        DialogBox
        IF TIMER > MesSent THEN Key$ = CHR$(3)
    LOOP WHILE Key$ = ""
    Key$ = ""
END IF
MesSent = TIMER + 2



IF NameAli = 1 THEN SWAP Name$, Alias$



CLR$ = LEFT$(CLR$, 2)
'Snd$ = Clr$ + Name$ + SPACE$(20 - LEN(Name$)) + ": " + SendText$ + SPACE$(138 - LEN(SendText$))



IF LEN(SendText$) <= 58 THEN SND$ = CLR$ + Name$ + SPACE$(20 - LEN(Name$)) + ": " + LEFT$(SendText$, 60) + SPACE$(58 - LEN(LEFT$(SendText$, 58)))
IF LEN(SendText$) >= 59 THEN SND$ = CLR$ + Name$ + SPACE$(20 - LEN(Name$)) + ": " + LEFT$(SendText$, 58) + SPACE$(58 - LEN(LEFT$(SendText$, 58)))
IF LEN(SendText$) >= 59 THEN sndt$ = CLR$ + MID$(SendText$, 59, 80) + SPACE$(80 - LEN(MID$(SendText$, 59, 80)))
'PRINT LEN(snd$); : SLEEP



'IF LEN(SendText$) >= 60 THEN Snd$ = Clr$ + Name$ + SPACE$(20 - LEN(Name$)) + ": " + LEFT$(SendText$, 58) + SPACE$(62 - LEN(LEFT$(SendText$, 60)))
'IF LEN(SendText$) >= 60 THEN Sndt$ = MID$(SendText$, 78) + SPACE$(82 - LEN(MID$(SendText$, 78)))
IF SND$ = "" THEN EXIT SUB



Att = 0
ReTryIt:
ErLevel = 0
OPEN Path$ + BName$ + "L" + LineNr$ FOR APPEND SHARED AS #1
IF NOT ErLevel = 0 THEN
    Att = Att + 1
    DiagX = 0: DiagY = 11: DiagFC = 0: DiagBC = 0
    DiagText$ = "Error sending! Re-Trying, Attempt:" + STR$(Att) + "/20"
    IF Att = 21 THEN DiagText$ = "ERROR! Could NOT Send Message To Network!!!"
    DialogBox
    IF Att = 21 THEN DO: Key$ = INKEY$: LOOP WHILE Key$ = "": CLOSE #1: EXIT SUB
    T = TIMER + .5
    DO: LOOP UNTIL TIMER > T
    GOTO ReTryIt
END IF
PRINT #1, SND$
IF NOT sndt$ = "" THEN PRINT #1, sndt$
CLOSE #1



Mes = Mes + 1
IF NameAli = 1 THEN SWAP Name$, Alias$
END SUB



SUB ChatUpdate



DIM FileRead AS FR




'SHELL "If Exist " + Path$ + MID$(STR$(UserID), 2, 4) + ".BAT " + MID$(STR$(UserID), 2, 4) + ".BAT>NUL"



ErLevel = 0
OPEN Path$ + BName$ + "N" + LineNr$ FOR APPEND SHARED AS #1
IF NOT ErLevel = 0 THEN
    DiagX = 0: DiagY = 11: DiagFC = 0: DiagBC = 0
    DiagText$ = "Network NOT Operative!"
    DialogBox
    CLOSE #1
    EXIT SUB
END IF
PRINT #1, "000": CLOSE #1



OPEN Path$ + BName$ + "N" + LineNr$ FOR INPUT SHARED AS #1
IF NOT ErLevel = 0 THEN CLOSE #1: EXIT SUB
INPUT #1, Users$: CLOSE #1
Users = VAL(Users$)
'*********************************



OPEN Path$ + BName$ + "T" + LineNr$ FOR APPEND SHARED AS #1
IF NOT ErLevel = 0 THEN CLOSE #1: EXIT SUB
PRINT #1, ""
CLOSE #1



OPEN Path$ + BName$ + "T" + LineNr$ FOR INPUT SHARED AS #1
IF NOT ErLevel = 0 THEN CLOSE #1: EXIT SUB
INPUT #1, Topic$
CLOSE #1
Topic$ = LEFT$(Topic$, 20)







VIEW PRINT 3 TO 24
LOCATE 3, 1, 0
ErLevel = 0
OPEN Path$ + BName$ + "L" + LineNr$ FOR RANDOM SHARED AS #1 LEN = 84
IF NOT ErLevel = 0 THEN CLOSE #1: EXIT SUB
IF LOF(1) = UpdNow THEN CLOSE #1: EXIT SUB ELSE UpdNow = LOF(1)
L = (LOF(1) - 164 * 10) / 84
IF L <= 19 THEN L = LOF(1) / 84 ELSE L = L + 20
P = L
IF P >= 21 THEN P = 21
FOR A = 1 TO P
  
    GET #1, L - (P - A), FileRead
    C = VAL(FileRead.PCLR)
    BC = 0
    IF C = 99 THEN C = 3: BC = 4
    IF C <= 0 THEN CLOSE #1: KILL Path$ + BName$ + "L" + LineNr$: EXIT SUB
    IF C >= 32 THEN C = 30
    COLOR C, BC
    P$ = FileRead.PName + FileRead.PLine
    PRINT P$
NEXT A



IF P <= 20 THEN
    FOR A = P + 1 TO 21
        LOCATE A + 2, 1: COLOR 7, 0: PRINT SPACE$(80);
    NEXT A
END IF



CLOSE #1
VIEW PRINT 5 TO 25
END SUB



SUB ChatViewLine
DIM LineInfo$(100)
COLOR 7, 0: CLS ' : ReDrawBack
ErLevel = 0
OPEN Path$ + BName$ + "LNS" FOR APPEND SHARED AS #1
IF NOT ErLevel = 0 THEN CLOSE #1: EXIT SUB
PRINT #1, "";
CLOSE #1
OPEN Path$ + BName$ + "LNS" FOR INPUT SHARED AS #1
DO UNTIL EOF(1)
    INPUT #1, A$
    LineInfo$(VAL(LEFT$(A$, 2))) = MID$(A$, 3, 20)
LOOP
CLOSE #1
VIEW PRINT 1 TO 25



LOCATE 1, 1: COLOR 14, 1: PRINT SPACE$(80)
LOCATE 1, 1



LOCATE 1, 1: PRINT "This list contains all the available lines and their topics!"



VIEW PRINT 4 TO 23



FOR A = 0 TO 99
    IF LineInfo$(A) = "" THEN LineInfo$(A) = "Chatting(NOT OPEN)"
    IF NOT LineInfo$(A) = "" THEN
        COLOR 15, 0: PRINT "³ ";: COLOR 14, 0
        PRINT A, LineInfo$(A) + SPACE$(25 - LEN(LineInfo$(A)));
        COLOR 15, 0: PRINT " ³": SP = SP + 1
    END IF
    IF SP = 18 THEN COLOR 15, 0: PRINT "Press Any Key To Continue...": GetChoice: SP = 0: CLS
NEXT A
COLOR 7, 0
COLOR 15, 0: LOCATE 23, 1: PRINT "Press Any Key To Return To Main Menu...";
GetChoice
VIEW PRINT 1 TO 25
END SUB



SUB DialogBox
' *HOW_TO_USE*
'
'DiagX = 0               ' Horizontal Possition
'DiagY = 0               ' Vertical Possition
'DiagFC = 0              ' Foreground Color
'DiagBC = 0              ' Background Color
'DiagText$ = ""          ' Dialog Text
'
'DialogBox               ' Call Sub
'



DiagText$ = LEFT$(DiagText$, 71)



IF DiagBC = 0 THEN DiagBC = 4
IF DiagFC = 0 THEN DiagFC = 15
IF DiagText$ = "" THEN EXIT SUB
IF DiagY = 0 THEN DiagY = 10
IF DiagY > 20 THEN DiagY = 19
IF DiagX = 0 THEN DiagX = 40 - INT(LEN(DiagText$) / 2)
IF DiagX + 6 + LEN(DiagText$) > 80 THEN DiagX = 72 - LEN(DiagText$)



COLOR DiagFC, DiagBC







FOR A = 2 TO LEN(DiagText$) + 5
    T = SCREEN(DiagY + 3, DiagX + A)
    IF T = 219 THEN T = 32
    UT$ = UT$ + CHR$(T)
NEXT A
       
BFT = SCREEN(DiagY + 1, DiagX + LEN(DiagText$) + 4)
BFST = SCREEN(DiagY + 1, DiagX + LEN(DiagText$) + 5)
IF BFT = 219 THEN BFT = 32
IF BFST = 219 THEN BFST = 32
BUTF$ = CHR$(BFT) + CHR$(BFST)
FT = SCREEN(DiagY + 2, DiagX + LEN(DiagText$) + 4)
FST = SCREEN(DiagY + 2, DiagX + LEN(DiagText$) + 5)
IF FT = 219 THEN FT = 32
IF FST = 219 THEN FST = 32
UTF$ = CHR$(FT) + CHR$(FST)



LOCATE DiagY, DiagX, 0: PRINT "ÉÍ";
FOR A = 1 TO LEN(DiagText$)
    PRINT "Í";
NEXT A
PRINT "Í»";



LOCATE DiagY + 1, DiagX: PRINT "º " + DiagText$ + " º"



LOCATE DiagY + 2, DiagX: PRINT "ÈÍ";
FOR A = 1 TO LEN(DiagText$)
    PRINT "Í";
NEXT A
PRINT "ͼ";



LOCATE DiagY + 1, DiagX + LEN(DiagText$) + 4: COLOR 8, 0: PRINT BUTF$
LOCATE DiagY + 2, DiagX + LEN(DiagText$) + 4: COLOR 8, 0: PRINT UTF$
LOCATE DiagY + 3, DiagX + 2: COLOR 8, 0: PRINT UT$



'****************************************************************************'
'     DiagX = 0                                                               '
'     DiagY = 0                                                               '
'    DiagFC = 0                                                               '
'    DiagBC = 0                                                               '
' DiagText$ = ""                                                              '
'****************************************************************************'




END SUB



SUB DrawMainMenu



DIM MNU$(20)
WIDTH 80, 25
UpdNow = 0
MesSent = 0



LineNr$ = STRING$(2 - LEN(MID$(STR$(LineNr), 2, 2)), "0") + MID$(STR$(LineNr), 2, 2)



IF ReDraw = 1 THEN
    VIEW PRINT 1 TO 25
    ReDraw = 0
    RedrawBack
    DiagX = 50
    DiagY = 9
    DiagFC = 15
    DiagBC = 1
    DiagText$ = SPACE$(21)
    DialogBox
END IF
IF NOT ReDraw = 0 THEN
    DiagX = 50
    DiagY = 9
    DiagFC = 15
    DiagBC = 1
    DiagText$ = SPACE$(21)
    ReDraw = 0
    DialogBox
END IF



MMx = 6
MMY = 17
mc = 1



MNU$(mc) = "1. Enter Conversation   ": mc = mc + 1
MNU$(mc) = "2. Change Chat Line     ": mc = mc + 1
MNU$(mc) = "3. Change Topic In Chat ": mc = mc + 1
MNU$(mc) = "4. User Options         ": mc = mc + 1
MNU$(mc) = "5. View Lines           ": mc = mc + 1
MNU$(mc) = "6. Send Message To User ": mc = mc + 1
MNU$(mc) = "7. DOS Shell            ": mc = mc + 1
MNU$(mc) = "8. Help                 ": mc = mc + 1
MNU$(mc) = "9. About This Program   ": mc = mc + 1
MNU$(mc) = "0. Exit Program (LogOff)": mc = mc + 1



mc = 1
COLOR 15, 1
LOCATE MMx + 0, MMY: PRINT "É" + STRING$(26, "Í") + "»"
LOCATE MMx + 1, MMY: PRINT "º     M a i n   M e n u    º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
LOCATE MMx + 2, MMY: PRINT "º" + STRING$(26, "Ä") + "º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
FOR A = 1 TO 9
    LOCATE MMx + 2 + mc, MMY: PRINT "º ";: COLOR 7, 1: PRINT MNU$(mc);: COLOR 15, 1: PRINT " º";: COLOR 0, 0: PRINT "  ": mc = mc + 1: COLOR 15, 1
NEXT A
LOCATE MMx + 12, MMY: PRINT "º" + STRING$(26, "Ä") + "º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
LOCATE MMx + 13, MMY: PRINT "º ";: COLOR 7, 1: PRINT MNU$(mc);: COLOR 15, 1: PRINT " º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
LOCATE MMx + 14, MMY: PRINT "È" + STRING$(26, "Í") + "¼";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
COLOR 0, 0
LOCATE MMx + 15, MMY + 2: PRINT SPACE$(28)



FOR A = 1 TO 10
    mc = A
    IF MenuItem% = mc THEN COLOR 1, 7 ELSE COLOR 7, 1
    IF NOT mc = 10 THEN LOCATE MMx + 2 + mc, MMY + 2 ELSE LOCATE MMx + 3 + mc, MMY + 2
    PRINT MNU$(mc)
NEXT A



KeyAccept = False



WHILE KeyAccept
    DO
        COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
        Key$ = INKEY$
    LOOP WHILE Key$ = ""
 
    IF Key$ = "+" THEN MenuItem% = MenuItem% + 1: KeyAccept = True
    IF Key$ = "-" THEN MenuItem% = MenuItem% - 1: KeyAccept = True
    IF Key$ = CHR$(0) + "P" THEN MenuItem% = MenuItem% + 1: KeyAccept = True
    IF Key$ = CHR$(0) + "H" THEN MenuItem% = MenuItem% - 1: KeyAccept = True
    FOR A = 1 TO 10
        IF VAL(Key$) = A AND NOT MenuItem% = VAL(Key$) THEN MenuItem% = VAL(Key$): KeyAccept = True
    NEXT A
    IF Key$ = "0" AND NOT MenuItem% = VAL(Key$) THEN MenuItem% = VAL(Key$): KeyAccept = True
    IF Key$ = CHR$(27) THEN KeyAccept = True
  
    IF Key$ = CHR$(13) AND MenuItem% = 1 AND TIMER < TimeOfReturn AND NOT SysOp >= 4 THEN
        DO
            DiagX = 0: DiagY = 11: DiagFC = 0: DiagBC = 0
            DiagText$ = "Sorry, You Can't Return Within 3 Seconds, Time Remaining:" + STR$(INT(TimeOfReturn - TIMER) + 1) + " Seconds"
            DialogBox
            Key$ = INKEY$
            COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
            IF TIMER > TimeOfReturn THEN Key$ = CHR$(3)
        LOOP WHILE Key$ = ""
        IF Key$ = CHR$(3) THEN Key$ = CHR$(13) ELSE Key$ = "": RedrawBack: ReDraw = 2: KeyAccept = True
    END IF



    IF Key$ = CHR$(13) AND MenuItem% = 1 THEN
        IF NamAli = 1 THEN SWAP Alias$, Name$
        Chat
        Key$ = "": KeyAccept = True: ReDraw = 1: TimeOfReturn = INT(TIMER + 3)
        IF NamAli = 1 THEN SWAP Alias$, Name$
    END IF
    IF Key$ = CHR$(13) AND MenuItem% = 2 THEN ChatFileNumber: Key$ = "": KeyAccept = True: RedrawBack: ReDraw = 2
    IF Key$ = CHR$(13) AND MenuItem% = 3 THEN ChatNewName: Key$ = "": KeyAccept = True: RedrawBack: ReDraw = 2
    IF Key$ = CHR$(13) AND MenuItem% = 4 THEN UserMenu: Key$ = "": KeyAccept = True: ReDraw = 2: MenuItem% = 4
    IF Key$ = CHR$(13) AND MenuItem% = 5 THEN ChatViewLine: Key$ = "": KeyAccept = True: ReDraw = 1
    IF Key$ = CHR$(13) AND MenuItem% = 7 THEN
        COLOR 7, 0: CLS
        HeadLine
        COLOR 12, 0: PRINT: PRINT "Type 'EXIT' To Return To Net-Chat v2.0.": PRINT
        COLOR 7, 0: SHELL
        ReDraw = 1: KeyAccept = True
    END IF
    IF Key$ = CHR$(13) AND MenuItem% = 8 THEN Help: KeyAccept = True
    IF Key$ = CHR$(13) AND MenuItem% = 9 THEN About: KeyAccept = True



    IF MenuItem% >= 11 THEN MenuItem% = 1
    IF MenuItem% <= 0 THEN MenuItem% = 10
   
    IF Key$ = CHR$(13) AND MenuItem% = 10 THEN Key$ = CHR$(27)
    IF Key$ = CHR$(27) THEN
        DiagX = 0: DiagY = 11: DiagFC = 0: DiagBC = 0
        DiagText$ = "Do YOU Really Want to Exit [Y/N] ?"
        DialogBox
        DO
            COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
            Key$ = INKEY$
        LOOP WHILE Key$ = ""
        IF UCASE$(Key$) = "Y" THEN Key$ = CHR$(27): KeyAccept = True ELSE Key$ = "": KeyAccept = True: RedrawBack: ReDraw = 2
    END IF



WEND



LOCATE 5, 1, 0



END SUB



SUB GetChoice
DO
    Key$ = INKEY$
LOOP WHILE Key$ = ""
END SUB



SUB HeadLine
COLOR 14, 1: LOCATE 1, 1
LOCATE 1, 1: PRINT STRING$(80, "Í")
LOCATE 4, 1: PRINT STRING$(80, "Í")
LOCATE 1, 1: PRINT "É": LOCATE 1, 80: PRINT "»"
LOCATE 4, 1: PRINT "È": LOCATE 4, 80: PRINT "¼"
LOCATE 2, 1: PRINT "º": LOCATE 2, 80: PRINT "º"
LOCATE 3, 1: PRINT "º": LOCATE 3, 80: PRINT "º"
LOCATE 2, 2: PRINT SPACE$(34) + "Net-Chat v2.0a" + SPACE$(30)
LOCATE 3, 2: PRINT SPACE$(25) + "(c) Copyright 1996 By Tedd Hansen" + SPACE$(20)
END SUB



SUB Help
HeadLine
COLOR 15, 1
LOCATE 6, 1: PRINT STRING$(80, "Í")
LOCATE 24, 1: PRINT STRING$(80, "Í")
LOCATE 6, 1: PRINT "É"
LOCATE 6, 80: PRINT "»"
LOCATE 24, 1: PRINT "È"
LOCATE 24, 80: PRINT "¼"
FOR A = 7 TO 23
    LOCATE A, 1: PRINT "º" + STRING$(78, " ") + "º"
NEXT A
LOCATE 7, 4: PRINT "HELP ON NET-CHAT v2.0a"
COLOR 10, 1
LOCATE 9, 4: PRINT "Net-Chat 2.0 is the result of hours of intense programming,                 "
LOCATE 10, 4: PRINT "you didn't really think that I would care about programming something       "
LOCATE 11, 4: PRINT "like HELP??? If you need help, ask the author... This program shouldn't     "
LOCATE 12, 4: PRINT "be to hard to use if you have the basic knowledge!                          "
LOCATE 13, 4: PRINT "                                                                            "
LOCATE 14, 4: PRINT "Help will be avaivable in the final release, maybe even in one of the BETA  "
LOCATE 15, 4: PRINT "releases, but not at this time!"
LOCATE 16, 4: PRINT ""
LOCATE 17, 4: PRINT "All you need to know is that the button marked 'ESC' on your keyboard"
LOCATE 18, 4: PRINT "means ESCAPE, it will help you find the way out!"
LOCATE 19, 4: PRINT ""
LOCATE 20, 4: PRINT "To save you the trouble looking for an EASTEREGG, I can confirm that"
LOCATE 21, 4: PRINT "this program contains one! No hints avaivable!"
LOCATE 22, 4: PRINT ""
LOCATE 23, 4: PRINT "Have a nice chat!"



       
GetChoice
ReDraw = 1
KeyAccept = True
Key$ = ""
END SUB



SUB InitStartUp
VIEW PRINT 1 TO 25
COLOR 7, 0: CLS
HeadLine
COLOR 31, 0
LOCATE 6, 1, 1: PRINT "NOTE!!!"
COLOR 7, 0
PRINT
PRINT "This is a BETA release, not all of the functions are finished."
PRINT "Error checking is not finished, so if anything goes wrong, like"
PRINT " sharing violation, path don't exist, network don't exist etc."
PRINT " the program will just exit, showing you an error message."
PRINT "This is just so that the author can see what MAY go wrong,"
PRINT " unlike the other BETA releases where all error where ignored"
PRINT " and only A FEW where fixed."
PRINT
PRINT "The program also contains BUGS wich the author knows about, and"
PRINT " will be fixed in later releases. This is the FIRST release of"
PRINT "NET-CHAT 2.0, release a."
PRINT
PRINT "Please notify thee author when anything goes wrong!"
PRINT "This will be fixed in the final release!!!"
PRINT "Have A Nice Beta Testing!!"
PRINT
PRINT "Tedd Hansen"
PRINT "tedd@sn.no";
GetChoice
Key$ = ""
MenuItem% = 1
ReDraw = 1
END SUB



SUB LogOn



LogOnAgain:
Alias$ = ""
PWD$ = ""
VPWD$ = ""



Exist = 0
LogOnItem = 0
COLOR 7, 0: CLS
HeadLine




LOCATE 13, 1, 0: COLOR 3, 0: PRINT STRING$(20, "±"): LOCATE 13, 1, 1: PRINT Name$;
LOCATE 16, 1, 0: COLOR 3, 0: PRINT STRING$(20, "±"): LOCATE 16, 1, 1: PRINT Alias$;
LOCATE 19, 1, 0: COLOR 3, 0: PRINT STRING$(6, "±"): LOCATE 19, 1, 1: PRINT STRING$(LEN(PWD$), "*");
 
LOCATE 22, 1, 0: COLOR 3, 0: PRINT STRING$(6, "±"): LOCATE 22, 1, 1: PRINT STRING$(LEN(VPWD$), "*");
'  COLOR 8, 0: LOCATE 22, 1, 0: PRINT STRING$(6, "±"): LOCATE 22, 1, 1: PRINT STRING$(LEN(VPWD$), "*");




COLOR 12, 0
LOCATE 6, 1: PRINT "Welcome To Net-Chat v2.0a."
COLOR 10, 0
PRINT "You are about to log on to Net-Chat. Please enter your REAL name,"
PRINT "This name is used with your password next time you log on, so that"
PRINT "NoOne else can use it. You may choose to use ALIAS during chat."
PRINT "ALIAS may be changed later, during chat."
PRINT
COLOR 3, 0
LOCATE 12, 1, 0: COLOR 15, 0: PRINT "Name:"
LOCATE 15, 1, 0: COLOR 15, 0: PRINT "Alias:"
LOCATE 18, 1, 0: COLOR 15, 0: PRINT "Password:"
LOCATE 21, 1, 0: COLOR 15, 0: PRINT "Password Verification:"



ExitLogOn = False



WHILE ExitLogOn
    COLOR 0, 3
    Name$ = LEFT$(Name$, 20)
    Alias$ = LEFT$(Alias$, 20)
    PWD$ = UCASE$(LEFT$(PWD$, 6))
    VPWD$ = UCASE$(LEFT$(VPWD$, 6))
  
    ' Exist = 1
  
    IF LogOnItem = 0 THEN LOCATE 13, 1, 0: COLOR 3, 0: PRINT STRING$(20, "±"): LOCATE 13, 1, 1: PRINT Name$;
    IF LogOnItem = 1 AND Exist = 0 THEN LOCATE 16, 1, 0: COLOR 3, 0: PRINT STRING$(20, "±"): LOCATE 16, 1, 1: PRINT Alias$;
    IF LogOnItem = 1 AND Exist = 1 THEN COLOR 8, 0: LOCATE 17, 1: PRINT "You Have Logged On Before, You Can't Change Alias Now.": LOCATE 16, 1, 0: PRINT STRING$(20, "±"): LOCATE 16, 1, 1: PRINT STRING$(LEN(Alias$), "*");
    IF LogOnItem = 2 AND Exist = 1 THEN COLOR 8, 0: LOCATE 17, 1: PRINT "You Have Logged On Before, You Can't Change Alias Now.": LOCATE 16, 1, 0: PRINT STRING$(20, "±"): LOCATE 16, 1, 1: PRINT STRING$(LEN(Alias$), "*");
    IF LogOnItem = 2 AND Exist = 1 THEN COLOR 8, 0: LOCATE 22, 1, 0: PRINT STRING$(6, "±"): LOCATE 22, 1, 1: PRINT STRING$(LEN(VPWD$), "*");
    IF LogOnItem = 2 THEN LOCATE 19, 1, 0: COLOR 3, 0: PRINT STRING$(6, "±"): LOCATE 19, 1, 1: PRINT STRING$(LEN(PWD$), "*");
  
    IF LogOnItem = 3 AND Exist = 0 THEN LOCATE 22, 1, 0: COLOR 3, 0: PRINT STRING$(6, "±"): LOCATE 22, 1, 1: PRINT STRING$(LEN(VPWD$), "*");
    'IF LogOnItem = 3 AND Exist = 1 THEN COLOR 8, 0: LOCATE 23, 1: PRINT "You have logged on before, I Don't need any verification.": LOCATE 22, 1, 0: PRINT STRING$(6, "±"): LOCATE 22, 1, 1: PRINT STRING$(LEN(VPWD$), "*");




    DO
        Key$ = INKEY$
    LOOP WHILE Key$ = ""



    IF Key$ = CHR$(13) AND LogOnItem = 0 AND LEN(Name$) = 0 THEN Key$ = "*"
    IF Key$ = CHR$(13) AND LogOnItem = 1 AND Exist = 0 AND LEN(Alias$) = 0 THEN Key$ = "*"
    IF Key$ = CHR$(13) AND LogOnItem = 2 AND Exist = 0 AND LEN(PWD$) = 0 THEN Key$ = "*"



    IF Key$ = CHR$(13) AND LogOnItem = 0 THEN
        COLOR 15, 0
        LOCATE 13, 30: PRINT "Searching: "
        LogOnFindUser
   
        IF Exist = 1 THEN LogOnItem = LogOnItem + 1: PRINT SPACE$(29) + "Name Found!" ELSE PRINT SPACE$(29) + "Name NOT Found, You Haven't Logged On Before!"
        VPWD$ = "": SWAP PWD$, VPWD$
    END IF



    IF Key$ = CHR$(13) AND LogOnItem = 3 AND Exist = 0 THEN
        COLOR 15, 0
        LOCATE 22, 30: PRINT "Searching: "
        LogOnFindUser
        IF Exist = 1 THEN PRINT SPACE$(29) + "Name Found!" ELSE PRINT SPACE$(29) + "Name NOT Found, You Haven't Logged On Before!"
        '   VPWD$ = "": SWAP PWD$, VPWD$
    END IF




    IF Key$ = CHR$(27) THEN GOTO EndLogOn
    IF Key$ = CHR$(9) THEN LogOnItem = LogOnItem + 1
    IF Key$ = CHR$(0) + "P" THEN LogOnItem = LogOnItem + 1
    IF Key$ = CHR$(0) + "H" THEN LogOnItem = LogOnItem - 1
    IF LogOnItem > 3 THEN LogOnItem = 0
    IF LogOnItem < 0 THEN LogOnItem = 3



    IF Key$ = CHR$(13) THEN LogOnItem = LogOnItem + 1
    IF Key$ = CHR$(13) AND Exist = 1 AND LogOnItem = 3 THEN LogOnItem = LogOnItem + 1
    IF LogOnItem > 3 THEN ExitLogOn = True




    GOSUB SW
    OKASCII = 0
    IF ASC(Key$) = 134 THEN OKASCII = 1
    IF ASC(Key$) = 143 THEN OKASCII = 1
    IF ASC(Key$) = 145 THEN OKASCII = 1
    IF ASC(Key$) = 146 THEN OKASCII = 1
    IF ASC(Key$) = 155 THEN OKASCII = 1
    IF ASC(Key$) = 157 THEN OKASCII = 1
 
    IF ASC(Key$) >= 32 AND ASC(Key$) <= 122 OR OKASCII = 1 THEN
        IF LogOnItem = 1 AND Exist = 1 THEN
            BEEP
        ELSEIF LogOnItem = 3 AND Exist = 1 THEN BEEP
        ELSE Temp$ = Temp$ + Key$
        END IF
    END IF
    IF Key$ = CHR$(8) AND LEN(Temp$) >= 1 THEN Temp$ = LEFT$(Temp$, LEN(Temp$) - 1)
    GOSUB SW
    IF UCASE$(LEFT$(Name$, 3)) = "TED" THEN Name$ = ""
    IF UCASE$(LEFT$(Name$, 3)) = "GUD" THEN Name$ = ""
    IF UCASE$(LEFT$(Name$, 3)) = "GOD" THEN Name$ = ""
    IF UCASE$(LEFT$(Alias$, 3)) = "TED" THEN Alias$ = ""
    IF UCASE$(LEFT$(Alias$, 3)) = "GUD" THEN Alias$ = ""
    IF UCASE$(LEFT$(Alias$, 3)) = "GOD" THEN Alias$ = ""
    'IF Exist = 1 THEN VPWD$ = PWD$



WEND



DiagX = 0
DiagY = 0
DiagFC = 0
DiagBC = 0



IF NOT PWD$ = VPWD$ THEN
    DiagText$ = "The two passwords you have specified don't mach, try again."
    DialogBox
    LOCATE 1, 1, 0
    GetChoice
    GOTO LogOnAgain
END IF
IF LEN(Name$) = 0 THEN
    DiagText$ = "You MUST Specify A NAME!!!"
    DialogBox
    LOCATE 1, 1, 0
    GetChoice
    GOTO LogOnAgain
END IF
IF LEN(Alias$) = 0 THEN
    DiagText$ = "You MUST Specify A ALIAS!!!"
    DialogBox
    LOCATE 1, 1, 0
    GetChoice
    GOTO LogOnAgain
END IF
IF LEN(PWD$) = 0 THEN
    DiagText$ = "You MUST Specify A PASSWORD!!!"
    DialogBox
    LOCATE 1, 1, 0
    GetChoice
    GOTO LogOnAgain
END IF



LineNr$ = STRING$(2 - LEN(MID$(STR$(LineNr), 2, 2)), "0") + MID$(STR$(LineNr), 2, 2)



IF NamAli = 1 THEN SWAP Alias$, Name$
IF Exist = 0 THEN UserSave
SND$ = "99" + Name$ + " Entered Net-Chat"
IF Exist = 0 THEN SND$ = SND$ + " For The First Time." ELSE SND$ = SND$ + "."
SND$ = SND$ + SPACE$(82 - LEN(SND$))
OPEN Path$ + BName$ + "L" + LineNr$ FOR APPEND SHARED AS #1
PRINT #1, SND$
CLOSE #1
IF NamAli = 1 THEN SWAP Alias$, Name$



EXIT SUB



SW:
IF LogOnItem = 0 THEN SWAP Temp$, Name$
IF LogOnItem = 1 THEN SWAP Temp$, Alias$
IF LogOnItem = 2 THEN SWAP Temp$, PWD$
IF LogOnItem = 3 THEN SWAP Temp$, VPWD$
RETURN



EndLogOn:
COLOR 7, 0: CLS
HeadLine
LOCATE 5, 1: COLOR 12, 0: PRINT "Thank you for using Net-Chat, Welcome Again!"
LOCATE 6, 1: COLOR 7, 0: PRINT "Program ended successfully!"
LOCATE 9, 1: COLOR 7, 0
END



END SUB



SUB LogOnFindUser



DIM PersonalInfo AS PI



OPEN Path$ + BName$ + "DAT" FOR RANDOM SHARED AS #1 LEN = 78
 
L = LOF(1) / 78



FOR G = 1 TO L
    GET #1, G, PersonalInfo
    IF UCASE$(Name$) = UCASE$(LEFT$(PersonalInfo.UName, LEN(Name$))) THEN
        Exist = 1
        Alias$ = PersonalInfo.UAlias
        PWD$ = PersonalInfo.UPWD
        SysOp = VAL(PersonalInfo.SysOp)
        CLR$ = PersonalInfo.UColor
        NamAli = VAL(PersonalInfo.UAlNa)
        UpdInterval = VAL(PersonalInfo.UpdInt)
        UserID = VAL(PersonalInfo.UNumber)
        LogOnDate$ = PersonalInfo.LogDT
        LP = 0
        FOR A = 1 TO LEN(Alias$)
            IF LP = 0 AND MID$(Alias$, A, 1) = "|" THEN LP = A
        NEXT A
        IF LP = 0 THEN LP = 1
        Alias$ = LEFT$(Alias$, LP - 1): LP = 0



        FOR A = 1 TO LEN(PWD$)
            IF LP = 0 AND MID$(PWD$, A, 1) = "|" THEN LP = A
        NEXT A
        IF LP = 0 THEN LP = 1
        PWD$ = LEFT$(PWD$, LP - 1)



    END IF
NEXT G
CLOSE #1



END SUB



SUB RedrawBack
'COLOR 7, 0: CLS
VIEW PRINT 25 TO 25
COLOR 7, 0: CLS
VIEW PRINT 5 TO 25
COLOR 8, 0
LOCATE 5, 1
PRINT STRING$(80 * 20, "Û")



VIEW PRINT 1 TO 25
HeadLine
       
END SUB



SUB UserMenu



DIM MNU$(20)
WIDTH 80, 25



MenuItem% = 1
Changed = 0
DrawAgain:



IF ReDraw = 1 THEN
    VIEW PRINT 1 TO 25
    ReDraw = 0
    RedrawBack
    DiagX = 50
    DiagY = 9
    DiagFC = 15
    DiagBC = 1
    DiagText$ = SPACE$(21)
    DialogBox
END IF
IF NOT ReDraw = 0 THEN
    DiagX = 50
    DiagY = 9
    DiagFC = 15
    DiagBC = 1
    DiagText$ = SPACE$(21)
    ReDraw = 0
    DialogBox
END IF



MMx = 6
MMY = 17
mc = 1



MNU$(mc) = "1. Change Personal Color": mc = mc + 1
MNU$(mc) = "2. Change Alias         ": mc = mc + 1
MNU$(mc) = "3. Change Password      ": mc = mc + 1
MNU$(mc) = "4. Change Upd. Intervall": mc = mc + 1
MNU$(mc) = "5. View Other Users     ": mc = mc + 1
MNU$(mc) = "6. View All Lines       ": mc = mc + 1
IF NamAli = 1 THEN MNU$(mc) = "7. Use ALIAS/name       ": mc = mc + 1
IF NamAli = 0 THEN MNU$(mc) = "7. Use alias/NAME       ": mc = mc + 1
MNU$(mc) = "8. Save Changes         ": mc = mc + 1
MNU$(mc) = "9. SysOp Menu           ": mc = mc + 1
MNU$(mc) = "0. Exit To Main Menu    ": mc = mc + 1




mc = 1
COLOR 15, 1
LOCATE MMx + 0, MMY: PRINT "É" + STRING$(26, "Í") + "»"
LOCATE MMx + 1, MMY: PRINT "º  U s e r  O p t i o n s  º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
LOCATE MMx + 2, MMY: PRINT "º" + STRING$(26, "Ä") + "º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
FOR A = 1 TO 9
    LOCATE MMx + 2 + mc, MMY: PRINT "º ";: COLOR 7, 1: PRINT MNU$(mc);: COLOR 15, 1: PRINT " º";: COLOR 0, 0: PRINT "  ": mc = mc + 1: COLOR 15, 1
NEXT A
LOCATE MMx + 12, MMY: PRINT "º" + STRING$(26, "Ä") + "º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
LOCATE MMx + 13, MMY: PRINT "º ";: COLOR 7, 1: PRINT MNU$(mc);: COLOR 15, 1: PRINT " º";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
LOCATE MMx + 14, MMY: PRINT "È" + STRING$(26, "Í") + "¼";: COLOR 0, 0: PRINT "  ": COLOR 15, 1
COLOR 0, 0
LOCATE MMx + 15, MMY + 2: PRINT SPACE$(28)



FOR A = 1 TO 10
    mc = A
    IF MenuItem% = mc THEN COLOR 1, 7 ELSE COLOR 7, 1
    IF NOT mc = 10 THEN LOCATE MMx + 2 + mc, MMY + 2 ELSE LOCATE MMx + 3 + mc, MMY + 2
    PRINT MNU$(mc)
NEXT A



DO
    KeyAccept = False
    WHILE KeyAccept



        DO
            COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
            Key$ = INKEY$
        LOOP WHILE Key$ = ""



        IF Key$ = "+" THEN MenuItem% = MenuItem% + 1: KeyAccept = True
        IF Key$ = "-" THEN MenuItem% = MenuItem% - 1: KeyAccept = True
        IF Key$ = CHR$(0) + "P" THEN MenuItem% = MenuItem% + 1: KeyAccept = True
        IF Key$ = CHR$(0) + "H" THEN MenuItem% = MenuItem% - 1: KeyAccept = True
        FOR A = 1 TO 10
            IF VAL(Key$) = A AND NOT MenuItem% = VAL(Key$) THEN MenuItem% = VAL(Key$): KeyAccept = True
        NEXT A
        IF Key$ = "0" AND NOT MenuItem% = VAL(Key$) THEN MenuItem% = VAL(Key$): KeyAccept = True



        IF Key$ = CHR$(13) AND MenuItem% = 10 THEN Key$ = CHR$(27): KeyAccept = True
        IF Key$ = CHR$(27) THEN KeyAccept = True



        IF MenuItem% >= 11 THEN MenuItem% = 1
        IF MenuItem% <= 0 THEN MenuItem% = 10



        IF Key$ = CHR$(13) AND MenuItem% = 7 THEN NamAli = NamAli + 1: KeyAccept = True: Key$ = "": Changed = 1
        IF NamAli > 1 THEN NamAli = 0
        mc = 7
        IF NamAli = 1 THEN MNU$(mc) = "7. Use ALIAS/name       "
        IF NamAli = 0 THEN MNU$(mc) = "7. Use alias/NAME       "



        FOR A = 1 TO 10
            mc = A
            IF MenuItem% = mc THEN COLOR 1, 7 ELSE COLOR 7, 1
            IF NOT mc = 10 THEN LOCATE MMx + 2 + mc, MMY + 2 ELSE LOCATE MMx + 3 + mc, MMY + 2
            PRINT MNU$(mc)
        NEXT A



        IF Key$ = CHR$(13) AND MenuItem% = 1 THEN UserNewColor: Key$ = "": RedrawBack: ReDraw = 2: KeyAccept = True: Changed = 1
        IF Key$ = CHR$(13) AND MenuItem% = 4 THEN UserUpdIntCh: Key$ = "": RedrawBack: ReDraw = 2: KeyAccept = True: Changed = 1
        IF Key$ = CHR$(13) AND MenuItem% = 8 AND Changed = 1 THEN UserSave: KeyAccept = True: Key$ = "": Changed = 0



        IF Key$ = CHR$(13) AND MenuItem% = 9 THEN
            DiagX = 0: DiagY = 11: DiagFC = 0: DiagBC = 0
            DiagText$ = "I'm really sorry, but you are not authorised to use this option!"
            DialogBox
            DO
                Key$ = INKEY$
                COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
            LOOP WHILE Key$ = ""
            Key$ = "": RedrawBack: ReDraw = 2: KeyAccept = True
        END IF







    WEND
    ExitOK = 0
    IF Key$ = CHR$(27) THEN ExitOK = 1
    IF Key$ = CHR$(13) AND MenuItem% = 10 THEN ExitOK = 1



    'IF Key$ = CHR$(13) AND MenuItem% = 9 THEN About: KeyAccept = True




    IF NOT ReDraw = 0 THEN GOTO DrawAgain
LOOP UNTIL ExitOK = 1



IF Changed = 1 THEN
    DiagX = 0: DiagY = 11: DiagFC = 0: DiagBC = 0
    DiagText$ = "Do you wish to keep current changes next time you log on [Y/N] ?"
    DialogBox
    DO
        COLOR 15, 1: LOCATE 10, 52, 0: PRINT DATE$ + " - " + TIME$
        Key$ = INKEY$
    LOOP WHILE Key$ = ""
    IF UCASE$(Key$) = "Y" THEN UserSave
    RedrawBack
END IF



Changed = 0



END SUB



SUB UserNewColor
CLR = VAL(CLR$)
IF CLR <= 0 OR CLR >= 16 THEN CLR = 7
CLRItem = CLR



DiagX = 59
DiagFC = 8
DiagBC = 8
DiagText$ = " "



DiagY = 10
DialogBox



DiagText$ = SPACE$(46)
DiagX = 14
DiagY = 12
DialogBox




X = 10
Y = 14




COLOR 15, 0
LOCATE X, Y: PRINT "É" + STRING$(48, "Í") + "»"
LOCATE X + 1, Y: PRINT "º" + STRING$(48, " ") + "º"
LOCATE X + 2, Y: PRINT "º" + STRING$(48, " ") + "º"
LOCATE X + 3, Y: PRINT "º" + STRING$(48, " ") + "º"
LOCATE X + 4, Y: PRINT "È" + STRING$(48, "Í") + "¼"



COLOR 14, 0: LOCATE X + 1, Y + 2: PRINT "Please Choose Your Color:"
DO



    FOR A = 1 TO 15
        LOCATE X + 3, Y + (A * 3)
        COLOR A, 0
        IF A = CLRItem THEN COLOR A, 15
        IF A = CLRItem AND A = 7 THEN COLOR 0, 7
        PRINT STRING$(2 - LEN(MID$(STR$(A), 2, 2)), "0") + MID$(STR$(A), 2, 2)
    NEXT A



    DO
        Key$ = INKEY$
        COLOR 15, 1: LOCATE 10, 65, 0: PRINT TIME$
    LOOP WHILE Key$ = ""




    IF Key$ = "+" THEN CLRItem = CLRItem + 1
    IF Key$ = "-" THEN CLRItem = CLRItem - 1
    IF Key$ = CHR$(0) + "P" THEN CLRItem = CLRItem - 1
    IF Key$ = CHR$(0) + "H" THEN CLRItem = CLRItem + 1
    IF Key$ = CHR$(0) + "K" THEN CLRItem = CLRItem - 1
    IF Key$ = CHR$(0) + "M" THEN CLRItem = CLRItem + 1



    IF CLRItem > 15 THEN CLRItem = 1
    IF CLRItem < 1 THEN CLRItem = 15



LOOP UNTIL Key$ = CHR$(13) OR Key$ = CHR$(27)



IF Key$ = CHR$(27) THEN EXIT SUB
CLR$ = STRING$(2 - LEN(MID$(STR$(CLRItem), 2, 2)), "0") + MID$(STR$(CLRItem), 2, 2)



END SUB



SUB UserSave
OPEN Path$ + BName$ + "DAT" FOR APPEND SHARED AS #1
Temp$ = DATE$ + " - " + TIME$
Temp$ = Temp$ + MID$(STR$(UserID), 2, 4)
Temp$ = Temp$ + Name$ + STRING$(20 - LEN(Name$), "|")
Temp$ = Temp$ + Alias$ + STRING$(20 - LEN(Alias$), "|")
Temp$ = Temp$ + PWD$ + STRING$(6 - LEN(PWD$), "|")
Temp$ = Temp$ + CLR$
Temp$ = Temp$ + MID$(STR$(NamAli), 2, 1)
Temp$ = Temp$ + MID$(STR$(UpdInterval), 2, 1)
Temp$ = Temp$ + MID$(STR$(SysOp), 2, 1)
PRINT #1, Temp$
CLOSE #1
END SUB



SUB UserUpdIntCh
DiagX = 0
DiagY = 0
DiagFC = 0
DiagBC = 0
DiagText$ = "Change Update Intervall: *"
DialogBox



UpdInt = UpdInterval
OKExit = False
DO
    COLOR 0, 7
    LOCATE 11, 54: PRINT MID$(STR$(UpdInt), 2, 1)
    Key$ = INKEY$
    IF Key$ = CHR$(27) THEN OKExit = True
    IF Key$ = CHR$(13) THEN UpdInterval = UpdInt: OKExit = True



    IF Key$ = "+" THEN UpdInt = UpdInt + 1
    IF Key$ = "-" THEN UpdInt = UpdInt - 1
    IF Key$ = CHR$(0) + "P" THEN UpdInt = UpdInt - 1
    IF Key$ = CHR$(0) + "H" THEN UpdInt = UpdInt + 1
    IF Key$ = CHR$(0) + "K" THEN UpdInt = UpdInt - 1
    IF Key$ = CHR$(0) + "M" THEN UpdInt = UpdInt + 1
    IF NOT VAL(Key$) = 0 THEN UpdInt = VAL(Key$)



    IF UpdInt > 9 THEN UpdInt = 9
    IF UpdInt < 1 THEN UpdInt = 1



LOOP UNTIL OKExit = True
END SUB

 

 

Leave a Reply