'             EAMON-QB
'              WORLD
'        A COMPUTERIZED FANTASY
'         ROLE-PLAYING SYSTEM
'
'     ORIGINAL RULES AND CORE PROGRAMS
'           BY DONALD BROWN
'           IBM-PC version
'           BY JOHN NELSON
'
'    Send Inquiries to:
'
'    National Eamon User's Club
'        c/o John Nelson
'
'    biggraybeard@hotmail.com
'
'
    DEFINT A-Z
    DECLARE SUB Normalize (Nam$)
REM $$INCL:'\EAMON\COPY\CHARDEF.BAS'
	' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	'
	'   Module:  CHARDEF.BAS
	'   Eamon Version:  Eamon-QB (or Eamon-PC)
	' ------------------------------------------------------------
	'  Character Definition for Eamon QB/PC
	'        Basic version:  QuickBASIC 4.0, GW-BASIC, QBasic *
	'                        or BASIC 7.0 PDS
	'       uses Field statements for record description
	'       This module will work for QBasic, but QBasic cannot
REM $$INCL:statements, so module must be copied
	'       into programs manually or merged using a utility
	' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	'
TYPE WeaponRec
	Nam             AS STRING * 20
	Wpntyp          AS INTEGER
	Odds            AS INTEGER
	Dice            AS INTEGER
	Sides           AS INTEGER
END TYPE

TYPE CharacterRecord
	Nam             AS STRING * 30
	Hd              AS INTEGER
	Ag              AS INTEGER
	Ch              AS INTEGER
	SA1             AS INTEGER
	SA2             AS INTEGER
	SA3             AS INTEGER
	SA4             AS INTEGER
	WA1             AS INTEGER
	WA2             AS INTEGER
	WA3             AS INTEGER
	WA4             AS INTEGER
	WA5             AS INTEGER
	Sex             AS STRING * 1
	Gold            AS LONG
	Bank            AS LONG
	AE              AS INTEGER
	ArmNam          AS STRING * 20
	ArmHit          AS INTEGER
	Armadj          AS INTEGER
	ShdNam          AS STRING * 20
	ShdHit          AS INTEGER
	ShdAdj          AS INTEGER
	Wpn1Nam         AS STRING * 20
	Wpn1typ         AS INTEGER
	Wpn1Wpntyp      AS INTEGER
	Wpn1odds        AS INTEGER
	Wpn1Dice        AS INTEGER
	Wpn1Sides       AS INTEGER
	Wpn2Nam         AS STRING * 20
	Wpn2typ         AS INTEGER
	Wpn2Wpntyp      AS INTEGER
	Wpn2odds        AS INTEGER
	Wpn2Dice        AS INTEGER
	Wpn2Sides       AS INTEGER
	Wpn3Nam         AS STRING * 20
	Wpn3typ         AS INTEGER
	Wpn3Wpntyp      AS INTEGER
	Wpn3odds        AS INTEGER
	Wpn3Dice        AS INTEGER
	Wpn3Sides       AS INTEGER
	Wpn4Nam         AS STRING * 20
	Wpn4typ         AS INTEGER
	Wpn4Wpntyp      AS INTEGER
	Wpn4odds        AS INTEGER
	Wpn4Dice        AS INTEGER
	Wpn4Sides       AS INTEGER
	Filler          AS STRING * 23
END TYPE
DIM Char AS CharacterRecord
TYPE CharControl
	NbrChar         AS INTEGER
	Filler          AS STRING * 254
END TYPE
DIM CharCtl AS CharControl

    '------- (end of include file) -------    
 ' 
    LOCATE , , , 6, 7
    RANDOMIZE TIMER
    DEF fnr (X) = INT(RND(1) * X + 1)
    KEY OFF
    READ NS
    DIM SN$(NS)
    FOR X = 1 TO NS
    READ SN$(X)
    NEXT
    DATA 8
    DATA "muttering about strange saxon names..."
    DATA "muttering about someday running off with  the bar wench."
    DATA "muttering about computerizing this book   business someday."
    DATA "saying he shoulda listened to his mother, and gone into taxidermy."
    DATA "scratching his belly and rubbing his head yawning, and burping."
    DATA "muttering foul curses and emitting a bad  breath that could curl your toes."
    DATA "yelling about snotty nosed greenhorns,    always needing full instructions fer everythin!"
    DATA "farting like a demon and clearing tables  within a dozen yards."
    ' =========================================================
    '   The following code is so the man behind the desk can go do
    '   something completely different ...
    READ NV
    DIM VM$(NV)
    FOR X = 1 TO NV
    READ VM$(X)
    NEXT
    VM = INT(RND(1) * NV) + 1
    VitalMission$ = VM$(VM)
    DATA 10
    DATA "go out back and take a squirt..."
    DATA "perform a little drunk management..."
    DATA "chase the bar wench fer a bit..."
    DATA "take the garbage out..."
    DATA "refill the wine bottles..."
    DATA "mop up the mess in back..."
    DATA "throw out this drunk..."
    DATA "change some bottle labels..."
    DATA "polish some fine silver..."
    DATA "water down the whiskey..."
    ' ------------
REM $$INCL:'\eamon\copy\colorrtn.bas'
     ON ERROR GOTO NoColors
     OPEN "EAMCOLOR" FOR INPUT AS #1
     INPUT #1, fgc%
     INPUT #1, bgc%
     INPUT #1, hfg%
     INPUT #1, hbg%
     CLOSE
In.BW:
     ON ERROR GOTO 0
     COLOR fgc%, bgc%
     GOTO Colorset
NoColors:
      fgc% = 7
      bgc% = 0
      hfg% = 0
      hbg% = 7
      RESUME In.BW
Colorset:

    '------- (end of include file) -------    
 ' 
    ON ERROR GOTO No.Champ
    OPEN "Champion" FOR INPUT AS #1
    INPUT #1, Nam$
    INPUT #1, REC
    CLOSE 1
    GOTO Champion.Found
No.Champ:
    CLOSE
    RESUME Continue1
Continue1:
    ON ERROR GOTO 0
    CLS
    DIM SA%(4), WA%(5), WN$(4), WR%(4), WT%(4), WC%(4), WD%(4), WS%(4)
    GOSUB OPEN.CHARACTERS
    GOSUB READ.NBR.CHARS
    GOSUB Find.Dead.Guys
    IF CountDead = 0 THEN
	Necro = 0
    END IF
    CLS
At.Door:
    PRINT
    PRINT "You are in the outer chamber of the hall of the Guild of Free Adventurers "
    PRINT
    PRINT "Many men and women are guzzling beer and there is loud singing and laughter."
    PRINT
    IF Necro THEN
	PRINT "At one of the tables at the far side, what appears to be a powerful Necromancer"
	PRINT
	PRINT "sits alone at the end of a long bench, sipping a strange brew.  "
	PRINT
    END IF
    PRINT "On the north side of the chamber is a cubby hole with a desk. Over the desk"
    PRINT
    PRINT "is a sign which says 'REGISTER HERE OR ELSE!'"
    PRINT
    PRINT "Do you go over to the desk, ";
    IF Necro = 0 THEN PRINT "or ";
    PRINT "join the men and women drinking beer";
    IF Necro THEN
	PRINT ", or go"
	PRINT
	PRINT " over to the mysterious Necromancer?  "
    ELSE
	PRINT "? "
    END IF
Tryagain:
    PRINT
    PRINT " Enter 'D' for Desk ";
    IF Necro = 0 THEN PRINT "or ";
    PRINT "'M' for Men ";
    IF Necro THEN PRINT "or 'N' for Necromancer ";
    'IF INSTR(UCASE$(Cmd$), "DESK") > 0 THEN A$ = "D"
    'IF INSTR(UCASE$(Cmd$), "DRINK") > 0 OR INSTR(UCASE$(Cmd$), "MEN") > 0 THEN A$ = "M"
    'IF INSTR(UCASE$(Cmd$), "NECRO") > 0 AND Necro = -1 THEN A$ = "N"
    RANDOMIZE TIMER
    VALID$ = "DM"
    IF Necro THEN VALID$ = VALID$ + "N"
    GOSUB GET.KEYSTROKE
    PRINT A$
    IF A$ = "D" THEN GOTO WENT.TO.DESK
    IF A$ = "M" THEN GOTO Drinking
    IF A$ <> "N" THEN PRINT : PRINT "I don't understand what you want. Try going to the desk, to the men or": PRINT "to the Necromancer.": GOTO Tryagain
    GOTO Necromancer
Drinking:
    R = fnr(100)
    SELECT CASE R
	CASE 1 TO 50
	    PRINT
	    PRINT "   As you go over to the men, you feel a sword being thrust through your back"
	    PRINT
	    PRINT "and you hear someone say, 'You really must learn to follow directions!'"
	    END
	CASE 51 TO 60
	    PRINT
	    PRINT "You join the men and women drinking beer and get very drunk. At some"
	    PRINT
	    PRINT "point you pass out and find yourself outside much later."
	    END
	CASE 61 TO 80
	    PRINT
	    PRINT "You join a band of rowdy ale drinkers and end up dancing with the wrong"
	    PRINT
	    PRINT "person.  They find your body out back the next day."
	    END
	CASE 81 TO 100
	    PRINT
	    PRINT "You join the men a women drinking beer and singing.  You are almost"
	    PRINT
	    PRINT "unaware of it when someone hit you over the head with a bottle and "
	    PRINT
	    PRINT "you wake up the next morning at the front door again."
	    END
	CASE ELSE
    END SELECT
WENT.TO.DESK:
    PRINT
    PRINT "   You are greeted there by a burly Irishman who looks at you with a scowl"
    PRINT
    PRINT "and asks you, 'What's your name?'"
    PRINT
    PRINT
Get.Adven.Name:
    LINE INPUT "You give him your name (Type it in now)        ", Nam$
    m = INSTR(Nam$, ",")
    IF m > 0 THEN
	MyN$ = MID$(Nam$, m + 1)
	Nam$ = RTRIM$(LEFT$(Nam$, m - 1))
	GOSUB Check.Cursing
	PRINT
	PRINT "Who're you callin' a "; MyN$; ", anyway?!"
    END IF
    PRINT
    Normalize Nam$
    IF LEFT$(UCASE$(Nam$), 7) = "PLEASE " THEN
	Cmdstr$ = UCASE$(MID$(Nam$, 8))
	IF INSTR(Cmdstr$, "ALLOW TITLES") > 0 THEN of% = -1: from% = -1
	IF INSTR(Cmdstr$, "DON'T KILL ME") > 0 THEN NoKill = -1
	PRINT "The Burly Irishman says, 'Jest gimme yer name, if ye please!'"
	GOTO Get.Adven.Name
    END IF
    '  The following code was put in to prevent users from entereing their
    '  names with 'titles'  like Mork the Dork but it has been commented out
    '  in the interest of allowing more flexibility for now...
    'IF AllowTit = 0 THEN
    't = INSTR(LCASE$(Nam$), " the ")
    'IF t > 0 THEN
    '    WT$ = MID$(Nam$, t + 5)
    '    PRINT "So, ye think yer "; WT$; ", huh?  Well I don't think so. I'll just"
    '    PRINT "ignore the self-proclaimed title, if ye don' mind!"
    '    PRINT
    '    IF of% = 0 THEN
    '        Nam$ = LEFT$(Nam$, t - 1)
    '    END IF
    'END IF
    't = INSTR(LCASE$(Nam$), " of ")
    'IF t > 0 THEN
    '    WT$ = MID$(Nam$, t + 4)
    '    PRINT "So, yer from "; WT$; ", huh?  Well we don't much care fer where "
    '    PRINT "yer from around here, so I'll ignore the reference, if ye don' mind!"
    '    PRINT
    '    IF of% = 0 THEN Nam$ = LEFT$(Nam$, t - 1)
    'END IF
    'END IF
    IF Nam$ = "" THEN GOSUB NO.NAME: GOTO Get.Adven.Name
    IF LEN(Nam$) < 2 THEN GOSUB NO.NAME: GOTO Get.Adven.Name
    IF LEFT$(UCASE$(Nam$), 1) < "A" OR LEFT$(UCASE$(Nam$), 1) > "Z" THEN GOSUB NO.NAME: GOTO Get.Adven.Name
    IF LEN(Nam$) > 20 THEN PRINT "   He scowls at you and says, 'Yer name's too long fer me book.  I canna": PRINT : PRINT "use more than twenty letters.": PRINT : GOTO Get.Adven.Name
    PHR = INT(RND(1) * NS + 1)
    PRINT "  He starts looking through his book, " + SN$(PHR)
    PRINT
    PRINT
    FOR R = 1 TO NC
    REC = R + 1
    GET #1, REC, Char
    A$ = RTRIM$(Char.Nam)
    NM$ = A$
    IF UCASE$(Nam$) = UCASE$(NM$) THEN GOTO NAME.FOUND
    NEXT R
    PRINT "   He eventually looks at you and says, 'Yer name's na in here. Have ye given"
    PRINT
    PRINT "it to me aright?'"
    PRINT
    PRINT "How do you answer (Press 'Y' OR 'N')  ";
    VALID$ = "YN"
    GOSUB GET.KEYSTROKE
    PRINT A$
    IF A$ = "N" THEN PRINT : GOSUB NO.NAME: GOTO Get.Adven.Name
    PRINT
    PRINT "   He hits his forehead and says, 'Ah, ye must be new here!  Well, wait just"
    PRINT
    PRINT "a minute and I'll bring someone out to take care of ye.'"
    PRINT
    GOSUB WRITE.ADVENT
    RUN "CREATE"
NAME.FOUND:
    PRINT
    PRINT " He looks up and says, 'Ah, here ye be! Well, go and have fun in the hall!'"
    PRINT
    GOSUB WRITE.ADVENT
    RUN "HALL"
Champion.Found:
    CLS
    PRINT "As you enter the Main Hall, the burly Irishman comes up and pats you on the"
    PRINT
    PRINT "back and says, 'Ah, "; Nam$; " you made it back.  I'll be anxious to hear yer"
    PRINT
    PRINT "tales later... Right now I got to "; VitalMission$
    PRINT
    GOSUB WRITE.ADVENT
    RUN "HALL"
Necromancer:
    CLS
    PRINT "As you approach the Necromancer, a field of mystical energy surrounds you"
    PRINT
    PRINT "and holds you fast.  You try to pull away, but cannot.  The Necromancer then"
    PRINT
    PRINT "rises and says, 'I suppose you're here because you've had a friend die"
    PRINT
    PRINT "recently and want to resurrect him?' "
    PRINT
    PRINT "How do you answer?  (Y or N)  ";
    VALID$ = "YN"
    GOSUB GET.KEYSTROKE
    PRINT A$
    IF A$ = "N" THEN
	PRINT
	PRINT "'Then go away and leave me alone!'  With that, you find yourself back at the"
	PRINT
	PRINT "door."
	PRINT
	PRINT " ==================== Press any key to continue ==================";
	A$ = INPUT$(1)
	GOTO At.Door
    END IF
    PRINT
    PRINT "'And what would this friend's name be?' "
    PRINT
    PRINT "  (Enter his/her name now)  ";
    INPUT "", RNAM$
    FOR R = 1 TO NC
	REC = R + 1
	GET #1, REC, Char
	A$ = RTRIM$(Char.Nam)
	NM$ = A$
	IF LEFT$(NM$, 1) = "*" AND RTRIM$(UCASE$(RNAM$)) = MID$(RTRIM$(UCASE$(NM$)), 2) THEN
	    Found = REC
	END IF
    NEXT
    PRINT
    PRINT "The Necromancer goes into a strange trance as blue waves of crackling force "
    PRINT
    PRINT "dance above his head.  Men and women scream and dive to the floor, cowering"
    PRINT
    PRINT "under the tables and benches...."
    PRINT
    IF Found > 0 THEN GOTO Resurrection
    PRINT "Soon, the old wizard says, 'I'm sorry, but I am unable to make contact with ":
    PRINT
    PRINT RNAM$; "'s spirit.  It's possible they're still alive. At any rate, ":
    PRINT
    PRINT "I won't be able to help you, I'm afraid.  With that, you find yourself back":
    PRINT
    PRINT " at the door."
    PRINT
    PRINT " ==================== Press any key to continue ==================";
    A$ = INPUT$(1)
    GOTO At.Door
Resurrection:
    REC = Found
    PRINT
    PRINT "After several minutes, you see your friend's body appear before you and "
    PRINT
    PRINT "find yourself merging with them. Your vision blurs and soon you find you "
    PRINT
    PRINT "have actually become "; RNAM$; "!!"
    PRINT " ==================== Press any key to continue ==================";
    A$ = INPUT$(1)
    GOSUB READ.CHARACTER
    Nam$ = RNAM$
    GOSUB WRITE.CHARACTER
    PRINT
    GOSUB WRITE.ADVENT
    RUN "HALL"
WRITE.ADVENT:
    OPEN "ADVENT" FOR OUTPUT AS #2
    WRITE #2, Nam$
    WRITE #2, REC
    CLOSE
    RETURN
NO.NAME:
    PRINT " He pulls out a sword and begins to sharpen it, saying 'Ye'd best be givin'"
    PRINT "me yer name laddie, if ye know wots good fer ye!!!'"
    RETURN
GET.KEYSTROKE:
    A$ = ""
    WHILE A$ = ""
    A$ = INKEY$
    WEND
    A$ = UCASE$(A$)
    IF VALID$ = "" THEN RETURN
    IF INSTR(VALID$, A$) > 0 THEN RETURN
    GOTO GET.KEYSTROKE
Check.Cursing:
    IF UCASE$(Nam$) = "FUCK YOU" THEN PRINT : PRINT "The burly Irishman slaps you across the head, and says 'Watch yer langwich,": PRINT " Asshole!'"
    RETURN
Nofrom:
    CLOSE
    OPEN "EAMCOLOR" FOR OUTPUT AS #1
    PRINT #1, fgc%
    PRINT #1, bgc%
    PRINT #1, hfg%
    PRINT #1, hbg%
    PRINT #1, brt%
    PRINT #1, Necro
    PRINT #1, 0
    PRINT #1, 0
    PRINT #1, 0
    PRINT #1, 0
    CLOSE
    RESUME In.BW
REM $$INCL:'\EAMON\COPY\CHARIO.BAS'
        ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        '
        '   Module:  CHARIO.BAS
        '   Eamon Version:  Eamon-QB (or Eamon-PC)
        ' ------------------------------------------------------------
        '  Character File I/O Routines for Eamon QB/PC
        '        Basic version:  QuickBASIC 4.0, GW-BASIC, QBasic *
        '                        or BASIC 7.0 PDS
        '       uses User defined types for record definition
        '       This module will work for QBasic, but QBasic cannot
REM $$INCL:statements, so module must be built
        '       manually or merged using a utility
        ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        '
OPEN.CHARACTERS:
      OPEN "CHARACT.DAT" FOR RANDOM AS #1 LEN = LEN(Char)
      RETURN
READ.NBR.CHARS:
      GET #1, 1, CharCtl
      NC = CharCtl.NbrChar
      IF NC > LOF(1) \ LEN(Char) THEN NC = LOF(1) \ LEN(Char) - 1
      RETURN
READ.CHARACTER:
      GET #1, REC, Char
      Nam$ = RTRIM$(Char.Nam$)
      HD = Char.Hd
      AG = Char.Ag
      CH = Char.Ch
      SA%(1) = Char.SA1
      SA%(2) = Char.SA2
      SA%(3) = Char.SA3
      SA%(4) = Char.SA4
      WA%(1) = Char.WA1
      WA%(2) = Char.WA2
      WA%(3) = Char.WA3
      WA%(4) = Char.WA4
      WA%(5) = Char.WA5
      SEX$ = Char.SEX
      GOLD& = Char.GOLD
      BANK& = Char.BANK
      AE = Char.AE
      ArmNam$ = RTRIM$(Char.ArmNam)
      ArmHit = Char.ArmHit
      ArmAdj = Char.ArmAdj
      ShdNam$ = RTRIM$(Char.ShdNam)
      ShdHit = Char.ShdHit
      ShdAdj = Char.ShdAdj
      WN$(1) = RTRIM$(Char.Wpn1Nam)
      WR%(1) = Char.Wpn1Typ
      WT%(1) = Char.Wpn1WpnTyp
      WC%(1) = Char.Wpn1Odds
      WD%(1) = Char.Wpn1Dice
      WS%(1) = Char.Wpn1Sides
      WN$(2) = RTRIM$(Char.Wpn2Nam)
      WR%(2) = Char.Wpn2Typ
      WT%(2) = Char.Wpn2WpnTyp
      WC%(2) = Char.Wpn2Odds
      WD%(2) = Char.Wpn2Dice
      WS%(2) = Char.Wpn2Sides
      WN$(3) = RTRIM$(Char.Wpn3Nam)
      WR%(3) = Char.Wpn3Typ
      WT%(3) = Char.Wpn3WpnTyp
      WC%(3) = Char.Wpn3Odds
      WD%(3) = Char.Wpn3Dice
      WS%(3) = Char.Wpn3Sides
      WN$(4) = RTRIM$(Char.Wpn4Nam)
      WR%(4) = Char.Wpn4Typ
      WT%(4) = Char.Wpn4WpnTyp
      WC%(4) = Char.Wpn4Odds
      WD%(4) = Char.Wpn4Dice
      WS%(4) = Char.Wpn4Sides
      RETURN
WRITE.CHARACTER:
      Char.Nam = Nam$
      Char.Hd = HD
      Char.Ag = AG
      Char.Ch = CH
      Char.SA1 = SA%(1)
      Char.SA2 = SA%(2)
      Char.SA3 = SA%(3)
      Char.SA4 = SA%(4)
      Char.WA1 = WA%(1)
      Char.WA2 = WA%(2)
      Char.WA3 = WA%(3)
      Char.WA4 = WA%(4)
      Char.WA5 = WA%(5)
      Char.SEX = SEX$
      Char.GOLD = GOLD&
      Char.BANK = BANK&
      Char.AE = AE
      Char.ArmNam = ArmNam$
      Char.ArmHit = ArmHit
      Char.ArmAdj = ArmAdj
      Char.ShdNam = ShdNam$
      Char.ShdHit = ShdHit
      Char.ShdAdj = ShdAdj
      Char.Wpn1Nam = WN$(1)
      Char.Wpn1Typ = WR%(1)
      Char.Wpn1WpnTyp = WT%(1)
      Char.Wpn1Odds = WC%(1)
      Char.Wpn1Dice = WD%(1)
      Char.Wpn1Sides = WS%(1)
      Char.Wpn2Nam = WN$(2)
      Char.Wpn2Typ = WR%(2)
      Char.Wpn2WpnTyp = WT%(2)
      Char.Wpn2Odds = WC%(2)
      Char.Wpn2Dice = WD%(2)
      Char.Wpn2Sides = WS%(2)
      Char.Wpn3Nam = WN$(3)
      Char.Wpn3Typ = WR%(3)
      Char.Wpn3WpnTyp = WT%(3)
      Char.Wpn3Odds = WC%(3)
      Char.Wpn3Dice = WD%(3)
      Char.Wpn3Sides = WS%(3)
      Char.Wpn4Nam = WN$(4)
      Char.Wpn4Typ = WR%(4)
      Char.Wpn4WpnTyp = WT%(4)
      Char.Wpn4Odds = WC%(4)
      Char.Wpn4Dice = WD%(4)
      Char.Wpn4Sides = WS%(4)
      PUT #1, REC, Char
      RETURN
WRITE.NBR.CHARS:
      CharCtl.NbrChar = NC
      PUT #1, 1, CharCtl
      RETURN

    '------- (end of include file) -------    
 ' 
Find.Dead.Guys:
    CountDead = 0
    FOR R = 1 TO NC
	REC = R + 1
	GET #1, REC, Char
	A$ = RTRIM$(Char.Nam)
	IF LEFT$(A$, 1) = "*" THEN
	    CountDead = CountDead + 1
	END IF
    NEXT
    RETURN

SUB Normalize (Nam$)
    Nam$ = UCASE$(Nam$)
    ND = 8
    REDIM N$(ND)
    p = INSTR(Nam$, " ")
    WHILE p > 0
    N$(X) = RTRIM$(LEFT$(Nam$, p))
    Nam$ = LTRIM$(MID$(Nam$, p))
    X = X + 1
    p = INSTR(Nam$, " ")
    WEND
    N$(X) = Nam$
    Nam$ = ""
    FOR N = 0 TO X
	IF N$(N) <> "OF" AND N$(N) <> "THE" AND N$(N) <> "AT" AND N$(N) <> "FROM" THEN
	    Nam$ = Nam$ + UCASE$(LEFT$(N$(N), 1)) + LCASE$(MID$(N$(N), 2)) + " "
	ELSE
	    Nam$ = Nam$ + LCASE$(N$(N)) + " "
	END IF
    NEXT
    Nam$ = LTRIM$(RTRIM$(Nam$))
END SUB

