sync on
sync rate 60
 
sync
sync
 
randomize timer()
 
start:
cls
choice = 0
 
repeat
   print "1-save 100 random names to a file"
   print "2-choose a certain length, create names of that length, and save them to a file"
   print "3-choose a first letter, create names that use it, and save them to a file"
   print "4-do both option 2 and 3 (set your own length AND first letter)"
   print "5-Exit"
   print "What would you like to do?"
   sync
   input "",choice
   if choice > 0 and choice < 6
      valid = 1
   else
      valid = 0
      CLS
      print "You must enter a number between 1 and 5"
      print " "
      sync
   endif
until valid=1
 
sync
 
if choice = 1
   cls
 
   file$ = getfilename()
 
   if file exist(file$ + ".txt") then delete file file$ + ".txt"
 
   open to write 1, file$ + ".txt"
 
   for i=1 to 100
      length = rnd(4)+3
      write string 1, name(length, "")
      sync
   next i
 
   close file 1
 
   print "The 100 names have been saved to '" + file$ + ".txt'"
   print "Press any key to continue"
   sync
   wait key
   goto start
endif
 
 
if choice = 2
   cls
 
   length = getlength()
 
   num = 0
   print "How many names do you want to save to the file?"
   sync
   input "",num
 
   file$ = getfilename()
 
   if file exist(file$ + ".txt") then delete file file$ + ".txt"
 
   open to write 1, file$ + ".txt"
 
   for i=1 to num
      write string 1, name(length, "")
      sync
   next i
 
   close file 1
 
   print "The names have been saved to '" + file$ + ".txt'"
   print "Press any key to continue"
   sync
   wait key
   goto start
endif
 
 
if choice = 3
   cls
   first$ = ""
   length = 0
 
   print "Enter the letter you want your names to start with"
   sync
   input "",first$
 
   num = 0
   print "How many names do you want to save to the file?"
   sync
   input "",num
 
   file$ = getfilename()
 
   if file exist(file$ + ".txt") then delete file file$ + ".txt"
 
   open to write 1, file$ + ".txt"
 
   for i=1 to num
      length = rnd(4)+3
      write string 1, name(length, first$)
      sync
   next i
 
   close file 1
 
   print "The names have been saved to '" + file$ + ".txt'"
   print "Press any key to continue"
   sync
   wait key
   goto start
endif
 
if choice = 4
   cls
   first$ = ""
   length = 0
 
   print "Enter the letter you want your names to start with"
   sync
   input "",first$
 
   length = getlength()
 
   num = 0
   print "How many names do you want to save to the file?"
   sync
   input "",num
 
   file$ = getfilename()
 
   if file exist(file$ + ".txt") then delete file file$ + ".txt"
 
   open to write 1, file$ + ".txt"
 
   for i=1 to num
      write string 1, name(length, first$)
      sync
   next i
 
   close file 1
 
   print "The names have been saved to '" + file$ + ".txt'"
   print "Press any key to continue"
   sync
   wait key
   goto start
endif
 
if choice = 5
   end
endif
 
 
 
 
function name(length, first$)
   select length
 
      case 3
         name$ = firstletter(first$) + lower$(midletter()) + lower$(lastletter())
         break
      endcase
 
      case 4
         name$ = firstletter(first$) + lower$(midletter()) + lower$(lastletter()) + lower$(midletter())
         break
      endcase
 
      case 5
         name$ = firstletter(first$) + lower$(midletter()) + lower$(lastletter()) + lower$(midletter()) + lower$(lastletter())
         break
      endcase
 
      case 6
         name$ = firstletter(first$) + lower$(midletter()) + lower$(lastletter()) + lower$(midletter()) + lower$(firstletter("")) + lower$(midletter())
         break
      endcase
 
      case 7
         name$ = firstletter(first$) + lower$(midletter()) + lower$(lastletter()) + lower$(midletter()) + lower$(firstletter("")) + lower$(midletter()) + lower$(lastletter())
         break
      endcase
 
   endselect
endfunction name$
 
function firstletter(rule$)
   if rule$=""
      num = rnd(2)+1
      select num
         case 1
            letters$ = "BCDLMNRS"
         endcase
         case 2
            letters$ = "BCDFGHKLMNPRSTW"
         endcase
         case 3
            letters$ = "BCDFGHJKLMNPQRSTVWXYZ"
         endcase
      endselect
 
      a$ = mid$(letters$, rnd(len(letters$)-1)+1)
   else
      a$ = rule$
   endif
 
endfunction a$
 
function midletter()
   letters$ = "AEIOU"
   a$ = mid$(letters$, rnd(len(letters$)-1)+1)
endfunction a$
 
 
function lastletter()
   letters$ = "RTNHLMNB"
   a$ = mid$(letters$, rnd(len(letters$)-1)+1)
endfunction a$
 
function getlength()
 
   length = 0
   print "Enter the length you want your names to be. From 3 to 7"
   sync
   input "",length
   repeat
      if length > 2 and length < 8
         complete = 1
      else
         cls
         print "That is an illegal length! please enter a length between 3 and 7"
         sync
         input "",length
         complete = 0
      endif
   until complete = 1
endfunction length
 
function getfilename()
   complete = 0
   repeat
      file$ = ""
      print "Enter a name for the file"
      sync
      input "",file$
 
      ask$ = ""
      if file exist(file$ + ".txt")
         print "That file exists, overwrite? y/n"
         sync
         input "",ask$
         if ask$ = "y"
            complete = 1
         else
            complete = 0
            cls
         endif
      else
         complete = 1
      endif
   until complete = 1
endfunction file$