home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
ST_WORLD
/
STWORLD5.MSA
/
PROGRAMS_NAME_GEN_NAMEGEN.GFA
(
.txt
)
< prev
next >
Wrap
GFA-BASIC Atari
|
1991-08-17
|
14KB
|
527 lines
' ********************************************************
' ********* NAME GENERATOR ********
' ********************************************************
' * by Richard Karsmakers *
' ********************************************************
' ********* Version 1.0 14-02-1990 ********
' ********* Version 1.1 22-02-1990 ********
' ********* Version 1.2 23-02-1990 ********
' ********* Version 1.3 09-03-1990 ********
' ********* Version 1.4 01-02-1991 ********
' ********* Version 1.5 20-05-1991 ********
' ********************************************************
'
' Variables: Counter% Number of name parts
' Used% Number of used names
' Another% Number of cross list names
' Current% Current word
' Name$() Array with name parts
' Used$() Array with used names
' Word$() History of words
' Ana%() Anagram ascii buffer array
' Pos$() Array for all anagrams
' Fac%() Array with precalculated faculties (0-12)
' Dummy% Dummy variable
' Screen$ Contains menu screen
' Taste% Inp(2) value for key press
' Status$ Current word/remark, etc.
' Seed% Buffer for random character
' Links$ Left part of name
' Rechts$ Right part of name
' Word$ Current word
' Ownword$ Own word part
' Fault! Error flag
' X% Temporary buffer for loops
' Lo$ Temporary Load name string
' Buffer$() Temporary buffer for cross lists
' Buf$ A buffer
' Flag! A flag (with cross - saved or not?)
' Anagram$ String for original Anagram word
' Ana% The length of Anagram$
' Pos Number of actually DIFFERENT anagrams possible
'
@check_low
@load_database !Load database from current directory
DIM word$(999) !History array
current%=0
DIM use$(999) !Used history array
use%=0
DIM ana%(25) !Anagram buffer array (ascii array)
DIM fac%(12) !Prepared faculty stuff
x%=0
DO
READ fac%(x%)
INC x%
EXIT IF x%>12
LOOP
@print_menu !Print menu
SGET screen$
status$=STR$(counter%)+" name parts loaded... "+STR$(counter%*counter%)+" names possible..."
DO
SPUT screen$ !Get menu screen
PRINT AT(1,25);SPACE$((80-LEN(status$))/2);status$;
@get_key
SELECT taste%
CASE 187 !F1
@create_name
CASE 188 !F2
@add_name_part
CASE 189 !F3
@cross_list
CASE 190 !F4
@mark_as_used
CASE 191 !F5
@cross_used_lists
CASE 192 !F6
@history
CASE 193 !F7
@used_history
CASE 194 !F8
@entry
CASE 195 !F9
@create_anagram
CASE 196 !F10
@program_credits
CASE 27
EDIT
CASE 225
EDIT
ENDSELECT
IF taste%<187 OR taste%>196
seed%=RANDOM(5)
SELECT seed%
CASE 0
status$="Why do you press a key that isn't valid? Are you a nurd?"
CASE 1
status$="You must be the doofest creature on earth...that key is non-valid!"
CASE 2
status$="Keep your hands off the wrong keys, man! Are you a fuckin' sexist?!"
CASE 3
status$="Sir, I am afraid this in a key which beliefs it is a non-entity..."
CASE 4
status$="Try something better to make this program crash, potatobrain!"
ENDSELECT
ENDIF
LOOP
'
PROCEDURE check_low
IF XBIOS(2)=0 !Low resolution?
ALERT 1,"NO LOW RES SUPPORT!",1,"SHIT!",dummy%
EDIT
ENDIF
RETURN
'
PROCEDURE load_database
DIM naam$(999) !1000 slots for names
DIM used$(999) !1000 slots for used names
OPEN "I",#1,"NAMES.TXT" !Open file NAMES.TXT for input
counter%=0 !Start reading at first slot
WHILE NOT EOF(#1) !While end of file not reached
INPUT #1,naam$(counter%) !Get name
naam$(counter%)=UPPER$(naam$(counter%))
INC counter% !Prepare counter for next slot
WEND !Wend
CLOSE #1
IF EXIST("USED.TXT") !Already filenames used?
OPEN "I",#1,"USED.TXT" !Open file NAMES.TXT for input
used%=0 !Start reading at first slot
WHILE NOT EOF(#1) !While end of file not reached
INPUT #1,used$(used%) !Get name
used$(used%)=UPPER$(used$(used%))
INC used% !Prepare counter for next slot
WEND !Wend
CLOSE #1
ELSE
used%=1
ENDIF
RETURN
'
PROCEDURE print_menu
CLS !Clear the screen
@on
PRINT SPACE$(80);
PRINT SPACE$(80);
PRINT SPACE$(80);
PRINT SPACE$(80);
PRINT SPACE$(30);"NAME GENERATOR V1.5";SPACE$(30)
@off
PRINT
PRINT
PRINT SPACE$(20);"F 1 ---------------------- Create name"
PRINT SPACE$(20);"F 2 -------------------- Add name part"
PRINT SPACE$(20);"F 3 ------------- Cross name part list"
PRINT SPACE$(20);"F 4 --------------------- Mark as used"
PRINT SPACE$(20);"F 5 ----------------- Cross used lists"
PRINT SPACE$(20);"F 6 ----------------- Creation history"
PRINT SPACE$(20);"F 7 --------------------- Used history"
PRINT SPACE$(20);"F 8 -------- Delete entries from lists"
PRINT SPACE$(20);"F 9 ------------------- Create anagram"
PRINT SPACE$(20);"F10 ------------------ Program credits"
PRINT
PRINT
PRINT SPACE$(26);"(Press ESC or UNDO to quit!)"
@on
PRINT SPACE$(80);
PRINT SPACE$(80);
PRINT SPACE$(80);
@off
RETURN
'
PROCEDURE on
PRINT CHR$(27);"p"; !Reverse video on
RETURN
'
PROCEDURE off
IF XBIOS(4)=2 !High resolution
PRINT CHR$(27);"q"; !Reverse video off
ELSE
PRINT CHR$(27);"q" !Reverse video off
ENDIF
RETURN
'
PROCEDURE create_name
' get two random name parts, tie them together
seed%=RANDOM(counter%)
links$=naam$(seed%)
REPEAT
seed%=RANDOM(counter%)
rechts$=naam$(seed%)
UNTIL links$<>rechts$
word$=links$+rechts$
status$=word$
word$(current%)=word$
INC current%
RETURN
'
PROCEDURE add_name_part
' Add name part, save to disk
CLS
INPUT "Enter the name part ";ownword$
ownword$=UPPER$(ownword$)
@namealready
IF fault!
status$="Name part already present! Not used!"
ELSE
naam$(counter%)=ownword$
INC counter%
OPEN "O",#1,"NAMES.TXT"
x%=0
REPEAT
PRINT #1;naam$(x%)
INC x%
UNTIL x%=counter%
CLOSE #1
status$="Name part added to list!"
ENDIF
RETURN
'
PROCEDURE cross_list
' load in other base, cross them (do not include doubles!)
buf$=ownword$
ERASE buffer$()
DIM buffer$(999)
FILESELECT "*.TXT","",lo$
IF EXIST(lo$)
OPEN "I",#1,lo$ !Open file for input
another%=0 !Start reading at first slot
WHILE NOT EOF(#1) !While end of file not reached
INPUT #1,buffer$(another%) !Get name
buffer$(another%)=UPPER$(buffer$(another%))
INC another% !Prepare counter for next slot
WEND !Wend
CLOSE #1
x%=0
flag!=FALSE
REPEAT
ownword$=buffer$(x%)
@namealready !Exists already?
IF fault!=FALSE !Negative!
naam$(counter%)=ownword$ !Add it!
INC counter%
flag!=TRUE !Set flag to save new list later
ENDIF
INC x%
UNTIL x%=another%
IF flag! !Words were added!
OPEN "O",#1,"NAMES.TXT" !Save the file!
x%=0
REPEAT
PRINT #1;naam$(x%)
INC x%
UNTIL x%=counter%
CLOSE #1
status$="Names added and file saved!"
ELSE !No words were added!
status$="No new name parts found...nothing added!"
ENDIF
ELSE
ALERT 1,"FILE NOT FOUND!",1,"TAUB!",dummy%
status$="Something went wrong!"
ENDIF
ownword$=buf$
RETURN
'
PROCEDURE mark_as_used
' compare old used list with word....when not found, mark as used
LOCAL x%
IF word$<>""
@usedalready
ELSE
fault!=TRUE
ENDIF
IF fault!
status$="Word was already used before!!"
ELSE
used$(used%)=word$
INC used%
OPEN "O",#1,"USED.TXT"
x%=0
REPEAT
PRINT #1;used$(x%)
INC x%
UNTIL x%=used%
CLOSE #1
status$="Name '"+word$+"' marked as 'used'!"
use$(use%)=word$
INC use%
ENDIF
RETURN
'
PROCEDURE cross_used_lists
buf$=word$
ERASE buffer$()
DIM buffer$(999)
FILESELECT "*.TXT","",lo$
IF EXIST(lo$)
OPEN "I",#1,lo$ !Open file for input
another%=0 !Start reading at first slot
WHILE NOT EOF(#1) !While end of file not reached
INPUT #1,buffer$(another%) !Get name
buffer$(another%)=UPPER$(buffer$(another%))
INC another% !Prepare counter for next slot
WEND !Wend
CLOSE #1
x%=0
flag!=FALSE
REPEAT
word$=buffer$(x%)
@usedalready !Exists already?
IF fault!=FALSE !Negative!
used$(used%)=word$ !Add it!
INC used%
flag!=TRUE !Set flag to save new list later
ENDIF
INC x%
UNTIL x%=another%
IF flag! !Words were added!
OPEN "O",#1,"USED.TXT" !Save the file!
x%=0
REPEAT
PRINT #1;used$(x%)
INC x%
UNTIL x%=used%
CLOSE #1
status$="Names added and new 'used' file saved!"
ELSE !No words were added!
status$="No new used names found...nothing added!"
ENDIF
ELSE
ALERT 1,"FILE NOT FOUND!",1,"TAUB!",dummy%
status$="Something went wrong!"
ENDIF
word$=buf$
RETURN
'
PROCEDURE history
IF current%<>0
CLS
x%=0
REPEAT
PRINT SPACE$(40-(LEN(word$(x%)))/2);word$(x%)
INC x%
IF INP?(2)
PRINT
PRINT SPACE$(30);"Hit a key to continue..."
@get_key
ENDIF
UNTIL x%=current%+1
@get_key
status$="That was interesting, wasn't it?"
ELSE
status$="No History in this session yet!"
ENDIF
taste%=190
RETURN
'
PROCEDURE used_history
IF use%<>0
CLS
PRINT "Screen or printer? (S/P)"
@get_key
IF taste%<>112 AND taste%<>80 !No 'P' pressed
x%=0
REPEAT
PRINT SPACE$(40-(LEN(use$(x%)))/2);use$(x%)
INC x%
IF INP?(2)
PRINT
PRINT SPACE$(30);"Hit a key to continue..."
@get_key
ENDIF
UNTIL x%=use%+1
@get_key
status$="That was a really interesting list of GREAT words, don't you agree?"
ELSE
IF GEMDOS(17)=0 !Check if printer on
ALERT 1,"NO PRINTER THERE!",1,"WHAT?!",dummy%
status$="You tried to print the 'Used History' shit, but without printer..."
ELSE
x%=0
REPEAT
LPRINT use$(x%),
INC x%
UNTIL x%=use%+1
status$="You just printed the 'Used History' shit!"
ENDIF
ENDIF
ELSE
status$="No names used in this session yet!"
ENDIF
taste%=190
RETURN
'
PROCEDURE entry
CLS
PRINT
PRINT
PRINT
PRINT
PRINT
@on
PRINT " Use TEMPUS or another editor to delete the lines in the corresponding files ";
PRINT SPACE$(7);"NAMES.TXT contains the word parts; USED.TXT contains the used words";SPACE$(7);
PRINT SPACE$(14);"Do not forget to save the files back as ASCII file!!";SPACE$(14)
@off
@get_key
taste%=190
RETURN
'
PROCEDURE create_anagram
' This routine has not yet been entirely coded.
' Enough feedback will get it coded. If you want to code it, feel free!
' If you send that version than I will credit you there!
CLS
@on
PRINT " Anagram Creator. Tnx to Nic. Enter max. 12 characters (NO NUMERALS!)";SPACE$(11)
@off
DO
INPUT " Name to create anagram of : ",anagram$
ana%=LEN(anagram$)
EXIT IF ana%<13 AND ana%<>0
LOOP
anagram$=UPPER$(anagram$)
ARRAYFILL ana%(),0
x%=1
DO
INC ana%(ASC(MID$(anagram$,x%,1))-65) !Analyse character occurence
INC x%
EXIT IF x%>ana%
LOOP
pos#=1
x%=0
DO !Calculate possibilities
pos#=pos#*fac%(ana%(x%))
INC x%
EXIT IF x%>25
LOOP
pos#=1/(pos#/fac%(ana%))
PRINT " Number of possibilities : ";pos#
ERASE pos$()
DIM pos$(pos#) !Create array for possible words
x%=1
DO
' Create anagram
' Check validity
IF fac%(ana%)<>pos#
' Check if already used before (only if there are double chars)
ENDIF
INC x%
EXIT IF x%>pos#
LOOP
PRINT
PRINT " Hit any key to continue!"
@get_key
taste%=190
RETURN
'
PROCEDURE program_credits
CLS
dummy%=PEEK(16745024)
SPOKE 16745024,0
PRINT " Why, for heaven's sake, do you wish to have a look at the program credits? Is"
PRINT "it of any importance to you? Well, I guess it isn't. However, since I am a"
PRINT "bleedin' egomaniac that thrives on getting famous, I will honour you with the"
PRINT "required information anyway - also because I really do not want to do anything"
PRINT "else at this moment (which is the moment on which I am programming this shit)."
PRINT " It will probably not be of any importance for you to know that I am right now"
PRINT "listening to Iron Maiden and gently moving my head back and forth on the rhythm"
PRINT "of the sounds coming from my headphones. But I told you this for precisely the"
PRINT "same reasons as those because of which I will soon tell you who I am. I hope"
PRINT "you haven't read the status line in the previous menu screen, yet, 'cause that"
PRINT "will then most likely spoil all your fun."
PRINT " Well, well."
PRINT " When I started writing this text, I decided that it had to be one full page"
PRINT "in bloody length - and this at ANY costs. So I guess I can write a bit more,"
PRINT "since there are still a couple of lines left. Do you also notice that everything";
PRINT "I have written here uptil now is sheer BULLSHIT?"
PRINT " I am glad you did, for otherwise you're even more stupid than I fuckin'"
PRINT "thought. So I guess you're not as bad at all, and therefore I will honour thee"
PRINT "with letting you know who the fuck I am. Yeah......who IS that fuckin' lunatic"
PRINT "that keeps on fuckin' abusing the fuckin' English language by using a whole"
PRINT "fuckin' lot of fuckin' fuckin'? Well....it is the fuckin' author of this fuckin'";
PRINT "program and he is fuckin' called Richard (Yeah! Right fuckin' on!)."
PRINT
PRINT " Sorry for this blatant abuse of the English language, folx!"
status$="You just had a look at those stupid program credits..."
@get_key
taste%=196
SPOKE 16745024,dummy%
RETURN
'
PROCEDURE get_key
LPOKE XBIOS(14,1)+6,0 !Clear keyboard buffer
taste%=INP(2)
RETURN
'
PROCEDURE namealready
' This routine checks if a word already exists in the NAAM$()
' returns a fault! is true when found
LOCAL x%
x%=0
fault!=FALSE
REPEAT
IF ownword$=naam$(x%)
fault!=TRUE
ENDIF
INC x%
UNTIL fault!=TRUE OR x%=counter%
RETURN
'
PROCEDURE usedalready
' This routine checks if a word already exists in the USED$()
' returns a fault! is true when found
LOCAL x%
x%=0
fault!=FALSE
REPEAT
IF word$=used$(x%)
fault!=TRUE
ENDIF
INC x%
UNTIL fault!=TRUE OR x%=used%
RETURN
'
' Precalculated faculty shit
'
DATA 1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600