The Curl Programming Environment

by Friedger Mueffke



Listing One

<html>

<head>

<title> Moving Letter Box</title>

<meta name="author" content="Friedger M&uuml;ffke">

</head>

<body>

<div align="center">

<embed src="start2.curl" width=500 height=400 pluginurl="http://www.curl.com">

</embed>

</div>

</body>

</html>

Listing Two

|| File: start2.curl

|| Contents:

||     This applet allows to enter a value to a TextField

||     The prompt and result will be shown with funny, jumping letters

|| Author: Friedger Mueffke

|| Version: 1.2



{curl 1.5 applet}



{import * from MUEFFKE.COMPONENTS.LETTERBOX,

    location="letterbox.curl"}



|| Create a document without margins and scrollbars

|| that it can neatly integrated in a HTML document

{document-style PlainDocument}





|| Define function that fetches a string from a web site

{define-proc {get-web-string}:String

    {let nr: int = {value

                         {let rand:LinearRandom={LinearRandom}}

                         {rand.next-in-range 0, 6}

                     },

        result: String ="Welcome"

    }



    {try

        let intext: TextInputStream =

            {read-open{url "txt.php3?nr=" & nr}}

        {set result={{intext.read-one-line}.to-String}}

         {intext.close}

     catch err: MissingFileException do

        {error "Cannot find that file. Sorry!"}

    }

    {return result}



}



|| Declare a global variable without instanziation

{let c:#LetterBox}



|| The output of this environement is its last line

{value

    {set

        || Define Canvas containing the letters

         c={LetterBox

                        "Enter your Name",

                        width=10cm,

                        height=5cm,

                        background="black"

                     }

    }

    {let

        || Define TextField to enter a value

        tf:TextField={TextField

                         {on ValueFinished do

                             {if (tf.value != null ) then

                                 {do

                                     {c.set-string ({get-web-string} & " " &

tf.value)}

                                     {c.move-string-to-center}

                                 }

                             }

                         }

                     }

    }



    {c.add tf,

        x=1cm,

        y=1cm

    }



    c

}



|| This environment doesn't produce any output!

|| Resize the Letter Box to a size of 500 x 400 pixel

{do

    {set c.height=c.points-per-pixel*400}

    {set c.width=c.points-per-pixel*500}



}

Listing Three

<?

$strings = array("Welcome", "Willkommen", "Bien Venue", "Servus",

                              "Bien Venidos", "Benvenuto","Bem Vindo");

print($strings[$nr]);

exit;

?>











