AutoIt poem generator.

Presented here is an abbreviated version of my poem generator script for use with AutoIt. The original version is 504 lines long due to the size of the arrays, so I shrank them for this post without compromising the script’s functionality. This script generates three short poems and writes them to a file called “atpoem.htm” in your Documents folder. A word of warning: because the page colors are also randomly generated, the text may not be readable in some cases, so just run the script again for a different color combination. Enjoy.

ProgressOn("@Random", "Generating atpoem.htm...", "0 percent complete")

dim $po[15]
dim $adj[20]
dim $nou[20]
dim $lin[20]

$adj[0]="happy"
$adj[1]="sad"
$adj[2]="angry"
$adj[3]="doubtful"
$adj[4]="horrible"
$adj[5]="terrifying"
$adj[6]="painful"
$adj[7]="healthy"
$adj[8]="sick"
$adj[9]="worried"
$adj[10]="high"
$adj[11]="low"
$adj[12]="near"
$adj[13]="far"
$adj[14]="calm"
$adj[15]="wild"
$adj[16]="blind"
$adj[17]="sightful"
$adj[18]="blessed"
$adj[19]="cursed"

$nou[0]="ambitions"
$nou[1]="dreams"
$nou[2]="horizons"
$nou[3]="colors"
$nou[4]="world"
$nou[5]="perspective"
$nou[6]="love"
$nou[7]="hate"
$nou[8]="desire"
$nou[9]="passion"
$nou[10]="lust"
$nou[11]="appeal"
$nou[12]="proposal"
$nou[13]="maze"
$nou[14]="music"
$nou[15]="chords"
$nou[16]="strings"
$nou[17]="lyrics"
$nou[18]="melodies"
$nou[19]="songs"

$lin[0]="in a"
$lin[1]="outside the"
$lin[2]="under the"
$lin[3]="your"
$lin[4]="his"
$lin[5]="her"
$lin[6]="my"
$lin[7]="on top of"
$lin[8]="listening to the"
$lin[9]="tell me about"
$lin[10]="or"
$lin[11]="and"
$lin[12]="but"
$lin[13]="beware of"
$lin[14]="this is"
$lin[15]="that is"
$lin[16]="because"
$lin[17]="like the"
$lin[18]="life is"
$lin[19]="sing about"

$file=@MyDocumentsDir & "\atpoem.htm"
$FileOpen = FileOpen ($file, 2)
FileWriteLine($file, "<HTML>")
FileWriteLine($file, "<HEAD>")
FileWriteLine($file, "<TITLE>Random Poems</TITLE>")
FileWriteLine($file, "</HEAD>")
FileWrite ($file, "<BODY TEXT="& chr(34) & "#")
for $g=1 to 6
$a=random (1,9,1)
FileWrite ($file, hex($a,1))
next
FileWrite ($file, chr(34) & chr (32))
FileWrite ($file, "BGCOLOR=" & chr(34) & "#")
for $g=1 to 6
$a=random (1,9,1)
FileWrite ($file, hex($a,1))
next
FileWrite ($file, chr(34) & " LINK=" & chr(34) &"#")
for $g=1 to 6
$a=random (1,9,1)
FileWrite ($file, hex($a,1))
next
FileWrite ($file, chr(34) & ">" & @CRLF)
FileWriteLine ($file, "<center>")
FileWriteLine ($file, "<h1>Random Poems</h1>")
FileWriteLine ($file, "<h3>")

for $g=1 to 3
$a=random (0,19,1)
$b=random (0,19,1)
$t=stringupper ($adj[$a] & chr(32) & $nou[$b] )
FileWriteLine ($file, $t & "<p>")

$c=random (1,10,1)
for $j=0 to $c
$a=random (0,19,1)
$b=random (0,19,1)
$d=random (0,19,1)
FileWriteLine ($file, $lin[$d] & chr(32) & $adj[$a] & chr(32) & $nou[$b] & "<br>")
next
FileWriteLine ($file, "<p>")
ProgressSet( int(($g*33)), int(($g*33)) & " percent complete")
next

FileWriteLine ($file, "</h3>")
FileWriteLine ($file, "</BODY>")
FileWriteLine ($file, "</HTML>")
FileClose ($FileOpen)
ProgressSet(100 , "Done.", "Done.")
sleep (500)
ProgressOff ()
Advertisements

Tags:

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: