# Curl/Print version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/Curl

# Example 1

Explanation
Curl commands appear between curly braces - hence the name "Curl".
In this example the first line of the code starts with a comment, the two vertical lines. This is similar to the REMark or // of other languages and is used for documentation.
{curl 3.0, 4.0, 5.0, 6.0 applet}
The second line is the 'herald ' - it declares the language and compatible Curl API version numbers and is similar to the <html> header in web pages. It is required. When multiple API version numbers are listed, that means that the applet is intended to be compatible with running in any of those versions of the Runtime Environment (RTE). A user can have more than one version of the RTE installed at the same time, but the highest version installed is the plug-in which will control the interactions with the browser, invoking lower numbered versions of the RTE if needed.
The remaining lines are the applet itself.
Hello World!
| ======end of program ========
which displays the familiar Hello World!

# Example 2

This displays a table just like the declarative HTML inside the Comment.
Lines 1 - 4 are standard.
Line 5 declares a new table.
Lines 6 - 9 put the values into four rows
Line 10 ends the table.

# Example 3

The above example shows some simple procedural code to create a table with the numbers 1 - 25 with Square and Cube Values. Lines 1-3 are as described above.
The 4th line starts a Value Block - this is a mechanism to hide some level of code within a Scope and to Return a Value - in this case to display in the web page. (Curl also has a do block that does not return anything)
Line 5 loads the row that holds the header information into the table.
Line 7 defines a new variable - my-table, of type Table and assigns it an initial value, the {Table} part of the line creates a new instance of Table. Curl does support an any type but its use is slower as the system has to make runtime checks on the type.
Line 9 creates a for iterator with a locally scoped variable i of type integer. Line 10 defines a local variable square and line 11 does the same for cube.
line 12 adds a new row to the table with the values of i, square and cube.
Line 13 ends the for construct.
Line 15 has the name of my-table so the value of my-table will be used as the result of the Value block.
Line 16 ends the value block.

# Example 4

This Example shows some OO capability along with Declarative layout.
Lines 1-3 are as described above.
Line four starts the definition of a new OO class called Circle that inherits from Ellipse (isa relationship).
Line 5 defines a field for the circle to hold the value of the diameter. Didn't really need it could just reference the width and height that is already stored for the ellipse. Likewise we should keep other programmers from changing the value of Width and Height independent of diameter. That's what I mean by simple OO examples are never enough.
Line 6 declares the constructor for the new class. A Little description on the parameters. the first parameter to Circle is a keyword argument that has a default value. Curl supports positional and keyword parameters. The second parameter is the ellipsis "...", also called 'rest arguments'. This is a construct for passing in an arbitrary number of arguments and you get to parse them. It is very helpful and usually isn't too much work.
Line 7 Saves in the diameter value in the objects field called diameter.
Line 8 calls the constructor for Ellipse but overwrites any mention of width and height with the diameter given.
The rest of the program closes out constructor and class definition then creates a simple display to hold a triple of circles. Note that other information is passed to the ellipse (fill-color) by way of the rest arguments. This is a screen capture of the output:
The dynamic nature of Curl can be used to create composite applications. Here comes a simple composite program that includes a chat capability and a web browser. Just save the script below as a file
say "c:\webbrowser.curl" and type the following line into your "Run..." field
Requirement is that you have Internet Explorer and Curl 3 installed.
You can also show the address bar, automagically fill in forms etc.

# Example 6

Curl is a gentle slope language. Here I will put some code to draw a UPC bar code that shows how you can program it using two techniques. Note that in the code below I have used markup and some text procs too. This is to demonstrate how these things can all be done so seamlessly in Curl.
I have implemented the UPC bar code using two techniques. The first technique uses Rule objects to draw the bars of the bar code. The second technique is more efficient. It uses the rendering APIs to render the bars of the bar code.

# Setting up

Before you can run any Curl application you have to install the Curl Engine. It is available as the Curl Runtime Environment (RTE) which is a browser plug-in, or as the Curl IDE which is a development environment that includes the RTE.
Both are available from Curl Inc..
After downloading just open the installation file. An installation wizard will guide you through the installation.
After the installation just goto any website that features a Curl application.
Calling an applet will start the Curl Engine and the applet will run.
Note, that Curl has a security policy which uses a privilege system. Some applets needs privileges, e.g. applets that are run from your local machine. Privileges are necessary if the applet requires access to your local file system, etc. In order to give privileges you have to enter the location of the application into the Curl Surge Control Panel, under menu item "Privileged Locations".

# Version numbers

The version number in applets, scripts and packages specifies the Curl API that has to be supported by the Curl Engine, i.e. by the plug-in. It is possible to have several APIs installed at the same time. Currently, Curl Inc. offers versions 5.0.3, 4.0.5 and 3.0.11 for download.
Within an application the Version number cannot be changed, i.e. each package has to be written for the same API. This eliminates the problems with downwards-compatibility.
However, it is possible to use other version by creating sub-applications, that are applications which run within an application. There is a (limited) possibility to exchange information between the main-applet and sub-applets.

# Linux support

Curl supports several versions of Linux now, but if you are a Linux fan, you can, of course, make Curl run on almost any Linux desktop.
Hardware:
Pentium® 166 MHz
Minimum of 64 MB RAM
46 MB hard disk space
Supported browsers:
* Firefox 2.0, 3.0
* Konqueror 3.x, 4.x
* Opera 9.5, 10

# The IDE

The VLE (Visual Layout Editor) is adequate. The online help (Curl Documentation Viewer) is an outstanding resource. With the IDE installed the online examples in the help are 'live' output from code that can be edited, restored and saved as an applet. This feature is usually only found in an advanced IDE such as Smalltalk.
The VLE is an interesting place to start: the source code for the VLE is installed as part of the IDE installation - it is written in Curl and constitututes a very large example.
There is a java-type packaging system that encourages modular software. Imported packages are usually a part of compilation (on the fly) and code reuse.
Curl provides an OCC (Occasionally Connected Computing) set of features for applications which can also run when not connected to the Internet: this includes client-side persistent data and local protected storage for each user of a web application.
One of the web GUI challenges is 'stretchy' widgets provided in Curl by using make-elastic. This is a feature required in most RIA applications.

# Interviews

Interviews
Please feel free to add your own questions and answers!

# Interview with "The Fridge"
## Are you known as 'the Fridge' because you are a kewl programmer?

When last time I had a temperature I wasn't so kewl. I think Fridge is the transcription of the German word "Fritte" (like potato chips) which is my nickname in Germany.

## Is Curl evolutionary or revolutionary?

This binary question is not so easily answered. Curl is of course evolutionary because there have been other programming languages before. It wouldn't be the MIT if they hadn't learnt from previous mistakes. On the other hand Curl comes with a revolutionary license policy. Don't ask for details the answer might take months.

## What is your favourite piece of Curl programming? Hint: try and include curlchat

I would say the "Hello World" program, as it nicely shows how markup language is integrated in the object-oriented programming language. There are also some really good applications around, most of them are not available on the net but have a look a www.curlchat.info for example and you will know what I mean.

## Can Curl be used for programming mobile phones or PDA's?

No, not yet. If the Asian market produces enough revenue there might be a possibility that Curl is ported to these devices.

## Why is your baby son a worshipped deity?

I don't understand the question.

## How does Curl fit in with the Semantic Web?

Oh, a technical question. Curl is great in collection information and preparing them in a sensible way. Yes, Curl programs can give meaning to a arbitrary sets of data retrieved from different sources.

## What is your connection to alchemy and time travel?

Yesterday, I was working with Curl version 4.2 that was released in 1992. But unfortunately, I was already so rich (look at all these gold nuggets on my desk) that I couldn't to see the ingenuity of the release.

## Why are you so keen on Curl?

Because. Do you really want a personal answer?

# External links
## External links

* Download English version
* Download Japanese version
* Curl Links
* CurlChat - Chat program written in Curl
* Curl blog
* Curl Corp