[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
BeginnersGuideToCurl

Beginners Guide To Curl

Introduction

Curl is a technology to create rich and interactive contents for the web. It is called client/web technology because it has a fat client and makes the web executable. Thereby it reduces bandwith and server load. As the language is easy to learn and Curl code less error prone using Curl also reduces the development costs.

The Language

Curl Applets can be seen as documents. Therefore, the world most famous programm in Curl looks like
{curl 3.0 applet}
Hello World!


If served from a web site the browser will bring up the plugin, compiles the code on the fly (just-in-time) and shows the text in standard format.

To change the text format or properties of paragraphs, just put the text or paragraph in appropriate code blocks. For examples, a text in a bold-block will make the text bold:
{curl 3.0 applet}
Hello {bold World!}
Here are some of the predefinied formats:
bold, italic, red, blue, green, tiny, small, large,...

The first word in a code block determines the functionality of the block. This holds consitently throughout the whole language. Any block is evaluated and the result used instead of the block. The bold block is replaced by a representation of bold text. Some block don't have a return value. The effect of a for-block, that represents a for loop, is that the contained code is executed several times but there is no result of the block. The following code would just display Hello !.
{curl 3.0 applet}
Hello {for i:int = 1 to 4 do {bold World }}!


To make it work we need a graphical container, a box, where the text and visual objects are collected. The box is then displayed with its contents using a value-block. value just displays the value of any variable or any expression.

{curl 3.0 applet}
{let container = {HBox}}
{for i:int = 1 to 4 do 
  {container.add 
     {bold World}
   }
}
Hello {value container}!


In addition to
  • HBox (a box that aligns its contents horizontally) there are
  • VBox for vertical alignment,
  • DefaultTextFlowBox and RasterBox for text over several lines,
  • Table for tabular representation of data,
  • Grid for combined horizontal and vertical alignment,
  • Canvas for free positioning of graphical elements,
  • and a lot more ...
There exists a whole lot of GUI elements, like
  • CommandButton
  • MenuPane
  • RadioButton
  • DropdownList
  • and a lot more.
The nice thing is that event handlers can be easily added to these elements, e.g.
{curl 3.0 applet}
|| define and display a container
{let hb:HBox = {HBox}}
{value hb}
|| display a commandbutton
{CommandButton label = "click",
  {on Action do
      {hb.add "another click"}
  }
}


The definition of a class looks like the following. It defines a VBox that notifies its observers when it is attached to the graphical hierarchy, i.e. displayed on the screen.

|| comment: this square notifies its observers when it is displayed.
||    i.e. attached to the graphical representation
{define-class public Square {inherits RectangularGraphic, Observable}
  field my-data:any
  {constructor public {default data:any = null}
     set self.my-data = data
     {self.add-event-handler 
        {on AttachEvent do
           {self.notify-observers}
         }
      }
  }
}


The class is instantiated by calling one of the following lines. (The first three lines use the default value null to initialize the class field data.)
{Square}
{new Square}
{Square.default}
{Square data = "My Data"}
{new Square, data = "My Data"}
{Square.default data = "My Data"}


The product Curl Surge

There is the Curl Surge RTE which is basically just the plugin for the browse. This is what the normal user of site with Curl contents would need to download and install. This is usually a straight forward process.

The developer can download the Curl Surge Lab (recommended). This contains the RTE as well as a development environment, including a debugger, a visual layour editor and an excessive, interactive documentation. But one could also type there first applet into a simple text editor.

If you want to run the applet from your local machine you have in most cases to grant privileges to the location of the applet. That means open the surge control center and add the location as privileged location on "This computer". Privileges are needed when a file is read from the local file system, i.e. always when you run an applet from your local machine that reads an image file or an included file. Privileges are also needed when the Clipboard is used or a connection to other servers are made, etc.

To serve the applet from a server a license key is necessary. You can get it from Curl Corporation ( http://www.curl.com/html/products/request_licensekey.jsp ) for free if your applet is publicly available on the web and doesn't need user registraction, otherwise you get a 60day trial license key and have to negociate the price for a proper license. A free licens key is shipped with the IDE that allows to run applets from http://localhost

In addition to the license file named "curl-license-3.scurl" another file is needed on the server. This file declares which applets can read files from the server. Whenever an (unprivileged) Curl applet requests a file it is checked whether the applet is allowed to read the file. Just create a text file called "curl-access.txt" with the following contents
version: 2.0
allow-all:
You can place the license key and the access file in the root directory of the server or if you don't have control over the root directory you can place it in all directories that serve curl applets.

That's it. Now happy curling!





last edited (February 18, 2004) by friedger, Number of views: 36231, Current Rev: 6 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.