Curl Language Examples
      See CurlLanguage
From
        The Curl Programming Environment
        Dr. Dobb's Journal September 2001
        http://www.ddj.com/documents/s=1485/ddj0109f/0109f.htm
      
      
        || 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}
      
      
        }
        || 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}
      
      
        }