 REM File: Dndinitf/Dndinit1 for Dndbbs Version v5.0a Release r2.0 Tweak t5.0a
 REM $INCLUDE: 'DNDINIT.INC'

 ON ERROR GOTO ERROR.ROUTINE
 Command.Line$ = Command$
 If RIGHT$(Command.Line$, 2) = "/Q" Then
    Quiet.Mode = True
    Command.Line$ = LEFT$(Command.Line$, 2)
 Endif
 If Command.Line$ <> "/I" Then
    Print "This program can only be run from Dndinit."
    End
 Endif
 Color 14, 0
 Call Get.Config
 If Quiet.Mode = False Then
    Print "Deleting data files."
 Endif
 CALL DELETE.DATA.FILES
 Var$ = "DNDINIT2.EXE"
 If Dir$(Var$)="" Then
    Color 12, 0
    Print "File: "+Var$+" not found."
 Else
    Color 14, 0
    If Quiet.Mode = False Then
       Print "Writing treasure file."
    Endif
    Var$=Var$+" "+Command.Line$
    SHELL Var$
 Endif
 Color 14, 0
 If Quiet.Mode = False Then
    Print "Writing action file."
 Endif
 CALL WRITE.ACTION.FILE
 If Quiet.Mode = False Then
    Print "Writing monster class file."
 Endif
 CALL WRITE.MONCLASS.FILE
 If Quiet.Mode = False Then
    Print "Writing monster talk file."
 Endif
 CALL WRITE.MONTALK.FILE
 If Quiet.Mode = False Then
    Print "Writing spell file."
 Endif
 CALL WRITE.SPELL.FILE
 If Quiet.Mode = False Then
    Print "Writing nonplayer file."
 Endif
 CALL WRITE.NONPLAYER.FILE
 If Quiet.Mode = False Then
    Print "Writing monster file."
 Endif
 CALL WRITE.MONSTER.FILE1
 CALL WRITE.MONSTER.FILE2
 END

ERROR.ROUTINE:
 PRINT
 IF ERR = 61 THEN
    PRINT "Disk full."
 ELSE
    PRINT "Dndinit error";Err
 END IF
 COLOR 7, 0
 END

Sub Get.Config
 On Local Error Goto Config.Error
 DND.Path$=Environ$("DNDBBS")
 If DND.Path$<>Nul Then
    If Right$(DND.Path$,1)<>"\" Then
       DND.Path$=DND.Path$+"\"
    Endif
 Endif
 FileName=DND.Path$+"DND.CFG"
 Close #1
 Open FileName For Input Shared As #1
 Line Input #1,Var$
 For Temp1=1 To MaxConfigArray1
    Input #1,Var!
 Next
 For Temp1=1 To MaxConfigArray2
    Input #1,Var%
 Next
 For Temp1=1 To MaxConfigArray3
    Line Input #1,Var$
    Var$ = Rtrim$(Var$)
    Select Case Temp1
    Case 11
       Var1$ = Var$
    Case 12
       MonClass.FileName=Var$
    Case 13
       MonTalk.FileName=Var$
    Case 15
       Var2$ = Var$
    Case 18
       Monster.FileName=Var$
    Case 19
       Treasure.FileName=Var$
    Case 20
       Spell.FileName=Var$
    Case 21
       User.FileName=Var$
    Case 22
       NonPlayer.FileName=Var$
    Case 57
       Team.FileName=Var$
    Case 71
       Action.FileName=Var$
    Case 80
       Container.FileName=Var$
    Case 85
       Strng3=Var$
    Case 86
       UserInv.FileName=Var$
    Case 87
       CtnInv.FileName=Var$
    Case 88
       TeamInv.FileName=Var$
    Case 90
       Moninv.Filename=Var$
    End Select
 Next
 Out2$=Environ$("DNDDAT")
 If Out2$<>Nul Then
    If Right$(Out2$,1)<>"\" Then
       Out2$=Out2$+"\"
    Endif
    Var1$=Out2$
 Endif
 MonClass.FileName=Var1$+MonClass.FileName+Var2$
 MonTalk.FileName=Var1$+MonTalk.FileName+Var2$
 Monster.FileName=Var1$+Monster.FileName+Var2$
 Treasure.FileName=Var1$+Treasure.FileName+Var2$
 Spell.FileName=Var1$+Spell.FileName+Var2$
 User.FileName=Var1$+User.FileName+Var2$
 NonPlayer.FileName=Var1$+NonPlayer.FileName+Var2$
 Team.FileName=Var1$+Team.Filename+Var2$
 Action.FileName=Var1$+Action.Filename+Var2$
 Container.FileName=Var1$+Container.Filename+Var2$
 UserInv.FileName=Var1$+UserInv.Filename+Var2$
 CtnInv.FileName=Var1$+CtnInv.Filename+Var2$
 TeamInv.FileName=Var1$+TeamInv.Filename+Var2$
 Moninv.Filename=Var1$+Moninv.FileName+Var2$
 Exit Sub
Config.Error:
 Print Lcase$(FileName)+" not found. Run dndcnfg."
 Color 7, 0
 End
End Sub
