LIBERTY BASIC HAIKU GENERATOR

© 2003, John Fisher

author website:

http://www.tauntonschool.co.uk

Home

Tip Cornner

Alyce's Favorite LB Sites

Haiku For Programmers

Haiku Generator

API File Operations

OS Selection

Binary Coding

Beginning Programming 3

DatePup32 DLL

Newsletter Help

Index

How the Haiku Generator Came to be...

John Fisher was really quite gracious and granted me my request to publish his Haiku Generator written in Liberty Basic, which he posted on the Liberty Basic Yahoogroups email list some weeks ago. He was also equally gracious in allowing me to publish a version that I tweaked slightly. The work still remains wholly Johns, and it is most remarkable in concept and execution. I hope you enjoy the Haiku Generator as much as I did.

The whole episode really comes about as a result of the various Haiku poems that were posted on the list during late February (see Haiku for Programmers elsewhere in this issue). John had thought back to earlier days when he had a Haiku Generator running on a different bread of machine. He wrote:

"Has anyone rejigged any old haiku-generators? If not I must dust off mine. Following was one of its more insightful creations 15 years ago in another universe of more primitive machines..."

The turgid flow snarls.
Behind a lone program
A concept crashes.

A few days later John was back with his creation born anew. He says about the Liberty Basic version of the Haiku Generator: "I've just put a Haiku generator, customized to produce 21st century computer vocabulary based Haikus, on my site at [http://atschool.eduweb.co.uk/taunton/LB/indexlb.html] (or go direct to [http://atschool.eduweb.co.uk/taunton/LB/haiku.bas] if you have slow connection or expensive connection charges & don't want to see all my other programs)."

Here is a sample that John posted:

The silent program . . .
    The data quits within the byte.
    Open night.

I queried John a few weeks back about the possibility of publishing his work, an idea he was happy to support. I had modified his original program by adding a PAUSE button at the bottom of the window, because the generator ran too fast on my PC for me to see the results, much less select and copy them from the TextEditor they are displayed in. John was also encouraging about the changes, permitting me to publish his work with them. I hope it adds to the experience. John had some final thoughts about Haiku and the Haiku generator.

"...my first haikus were probably on a PET in about 1980. Always glad to see improvements to programs. One I'd thought of was to give a user option of what SORT of vocabulary to use- instead of speaking 'nerdish' to use a more traditional 'Japanese' vocabulary of flowers, blossom & abstract thought! Perhaps a challenge for someone."

So there is a challenge for someone to think about! Thank you John for the chance to share your work. I hope my fingers in the code have not spoiled your intent. - Brad

The Haiku Generator:


    'Haiku v6 generator

    nomainwin

    UpperLeftX   =  32
    UpperLeftY   =  32
    WindowWidth  = 400
    WindowHeight = 480

    paused = 0

    texteditor #w.t, 10, 10, 380, 390
    button      #w.wait, "Wait...",[holdup],UL, 260, 406, 110, 25

    open "Random Haiku Generator, Johnf (tenochtitlanuk)" for window as #w

    print #w, "trapclose [quit]"
    print #w.t, "!font Times_New_Roman 12"

    numArticles = 4
    numAd       =30
    numNouns    =30
    numVerbs    =24
    numPrepos   =24

    dim article$( numArticles)
    dim adject$(  numAd)
    dim noun$(    numNouns)
    dim verb$(    numVerbs)
    dim prepos$(  numPrepos)

    for i =1  to numArticles
        read i$: article$( i) =i$
    next i
    data "a", "the", "an", "the"

    for i =1  to numAd
        read i$: adject$( i) =i$
    next i
    data "hurried", "hidden",   "bitter",   "careless",   "silent",   "empty"
    data "valued",  "sudden",   "wintry",   "stylish",    "top-down", "broken"
    data "little",  "morning",  "looping",  "halfbaked",  "turgid",   "tricky"
    data "happy",   "lesser",   "open",     "recent",     "problem",  "Basic"
    data "outright","opaque",   "evil",     "inane",      "idiot",    "arcane"

    for i =1  to numNouns
        read i$: noun$( i) =i$
    next i
    data "step",    "frame",   "base",   "field",  "data",   "rate"
    data "charge",  "slope",   "shape",  "shade",  "hue",    "cell"
    data "zero",    "byte",    "bit",    "chain",  "link",   "night"
    data "sound",   "peak",    "shape",  "curve",  "wave",   "concept"
    data "program", "PC",      "human",  "God",    "troll",  "root"

    for i =1  to numVerbs
        read i$: verb$( i) =i$
    next i
    data "drifts",  "crashed", "passed",  "runs",  "rose",   "floats"
    data "creeps",  "runs",    "fails",   "ends",  "sighs",  "loops"
    data "crawls",  "raced",   "halts",   "goes",  "quits",  "loves"
    data "starts",  "strives", "finds",   "posts", "fades",  "falls"

    for i =1  to numPrepos
        read i$: prepos$( i) =i$
    next i
    data "within", "beyond",  "throughout", "but now",   "but then", "although"
    data "ahead",  "in line", "at speed",   "with love", "for ever", "for now"
    data "thereby","alack",   "my love",    "perchance", "ere long", "'til when"
    data "without","thoughtless","all through","under",  "between", "never"

[showProse]
    while 1 =1
        x =int( 1 +4 *rnd( 1))
        x=1
        select case x
            case 1
                gosub [type1]
            case 2
                gosub [type2]
            case 3
                gosub [type3]
            case 4
                gosub [type4]
        end select
        print #w.t, haiku$
        gosub [checkArticles]
        gosub [checkCapitals]
        print #w.t, haiku$
        #w.t "____________________________________________________"
        scan
        for delay =1 to 50000
            '
        next delay
    wend
    wait

    [holdup]
       if paused = 0  then
          #w.wait "Show More!"
          paused = 1
          wait
       else
          paused = 0
          #w.wait "Wait"
          goto [showProse]
       end if

    [type1]
    haiku$ =chr$( 10) +" "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +" . . . " +chr$( 13) +"    "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +" "_
           +verb$(    int( 1 +rnd( 1)*numVerbs)) +" "_
           +prepos$(  int( 1 +rnd( 1)*numPrepos)) +" "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +"." +chr$( 13) +"    "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +"." +chr$(13)
    return

    [type2]
    haiku$ =chr$( 10) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +" "_
           +prepos$(  int( 1 +rnd( 1)*numPrepos)) +" "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +";" +chr$( 13) +"    "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +" "_
           +prepos$(  int( 1 +rnd( 1)*numPrepos)) +" "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +"." +chr$( 13) +"    "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +"." +chr$(13)
    return

    [type3]
    haiku$ =chr$( 10) +" "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +";" +chr$( 13) +"    "_
           +prepos$(  int( 1 +rnd( 1)*numPrepos)) +" "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +"." +chr$( 13) +"    "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +" "_
           +verb$(    int( 1 +rnd( 1)*numVerbs)) +"."
    return

    [type4]
    haiku$ =chr$( 10) +" "_
           +adject$(  int( 1 +rnd( 1)*numArticles)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +" "_
           +verb$(    int( 1 +rnd( 1)*numVerbs)) +";" +chr$(13) +"    "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +";" +chr$( 13) +"    "_
           +prepos$(  int( 1 +rnd( 1)*numPrepos)) +" "_
           +article$( int( 1 +rnd( 1)*numArticles)) +" "_
           +adject$(  int( 1 +rnd( 1)*numAd)) +" "_
           +noun$(    int( 1 +rnd( 1)*numNouns)) +"." +chr$(13)
    return

    [checkArticles]
        for k =1 to len( haiku$)
            if ( mid$( haiku$, k, 3) =" a ") and ( instr( "aeiou", mid$( haiku$, k+3, 1)) <>0) then
                haiku$ =left$( haiku$, k +1) +"n" +mid$( haiku$, ( k +2))
            end if
            if ( mid$( haiku$, k, 4) =" an ") and ( instr( "aeiou", mid$( haiku$, k+4, 1))  =0) then
                haiku$ =left$( haiku$, k +1) +mid$( haiku$, ( k +3))
            end if
        next k
    return

    [checkCapitals]
        for k =1 to len( haiku$)
            if k =3 then
                haiku$ =left$( haiku$, 2)    +upper$( mid$( haiku$, 3, 1))    +mid$( haiku$, 4)
            end if
            if mid$( haiku$, k, 1) =chr$( 13) then
                haiku$ =left$( haiku$, k +4) +upper$( mid$( haiku$, k +5, 1)) +mid$( haiku$, k +6)
            end if
        next k
    return

    [quit]
    close #w
    end



Home

Tip Cornner

Alyce's Favorite LB Sites

Haiku For Programmers

Haiku Generator

API File Operations

OS Selection

Binary Coding

Beginning Programming 3

DatePup32 DLL

Newsletter Help

Index