Thread Rating:
  • 601 Vote(s) - 2.84 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Started1:Creating a Simple Applet: Hello World
06-15-2011, 02:06 PM, (This post was last modified: 06-16-2011, 01:09 PM by kino.)
#1
Getting Started1:Creating a Simple Applet: Hello World
One of the powers of the Curl language is that it combines the worlds of document markup, scripting, and object-oriented programming into a single language.


3 Languages in 1

Language Feature: Description
Markup Language: Similar to HTML, it allows you to easily format text, tables, and lists
Scripting Language: Similar to JavaScript, it allows you to create interface elements such as buttons and drop-down menus
Programming Language: Similar to Java, it combines the flexibility of object-oriented programming

Curl was specifically designed to have a gentle slope learning curve. At one end of the curve is a simple markup language and at the highest end of the curve is a feature rich programming language in which you can build object-oriented applications with 3-D graphics and other advanced tools.

Starting at the beginning of the curve, the simplest element in an applet written in the Curl language is text. When you include text in a Curl applet, the browser displays that text that is displayed in the default font and point size. It treats spaces in the same manner as HTML does, by collapsing spaces that appear between words. In other words, if a number of consecutive spaces appear between words, the spaces are collapsed and only one space is displayed in the browser.


Creating Hello World
You will now learn how to write code for your first Curl applet; the all too familiar "Hello World" applet. We can create the applet content by adding the text after the herald declarations.

In each Curl example, you will see the source code. You will see two lines of code at the top of the file that are present for the applet to properly run.


Code:
{curl 6.0, 7.0 applet}
{applet {compiler-directives careful? = true}

In this case:
•The first line of code is called the herald. It indicates the Curl API version and the type of content (either applet, package, or script).

•The second line of code indicates applet properties. In this case, compiler-directives specifies careful?=true which is the recommended default.

Next, we can type the text Hello World using a Curl Example Box.

Tip: Throughout the Curl Cues, you will be able to interactively view and manipulate the examples using an interactive example box. The example box displays the source code and the result of evaluating that code. Unlike static examples, the example box allows you to change the code and view the new result in a pop-up window.

Code:
{curl 6.0, 7.0 applet}
{applet {compiler-directives careful? = true}}

Hello World

Congratulations!! This is your first applet. Any text in your file is treated by the Curl runtime as text that should be displayed. Now, if a line with no text appears in a Curl applet, the runtime stops collapsing the whitespace and creates a new paragraph for the text that follows.

Code:
{curl 6.0, 7.0 applet}
{applet {compiler-directives careful? = true}}

Hello World
This is my first applet

Hello World

This is my first applet


For more information regarding example boxes, please refer to the following section in the Curl Documentation: Curl Developer's Guide > Getting Started > Viewing the Documentation


Adding Comments
Commenting your code is always good practice. In the Curl Language, comments follow two vertical bar characters ||. Everything following these characters is considered a comment, and is ignored by the Curl runtime when interpreting the applet.

You can also use the combination of |# and #| to comment out multiple lines of code.

Code:
{curl 6.0, 7.0 applet}
{applet {compiler-directives careful? = true}}

|| This is a comment

|#
Comments can also
be specified in a
block format
#|

This is my first applet!

For more information regarding comments, please refer to the following section in the Curl Documentation: Curl Developer's Guide > Core Language - Syntax > Basic Syntax



Messages In This Thread
Getting Started1:Creating a Simple Applet: Hello World - by kino - 06-15-2011, 02:06 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  Styling3:Creating Styles with the Style Designer kino 0 5,086 06-16-2011, 09:52 AM
Last Post: kino
  Serving Content1:Launching a Curl Applet kino 0 5,371 06-15-2011, 05:12 PM
Last Post: kino
  Forms1:Creating Forms kino 0 5,336 06-15-2011, 04:55 PM
Last Post: kino
  User Interface Basics3:Creating Dialogs kino 0 3,360 06-15-2011, 03:55 PM
Last Post: kino
  Getting Started5:Creating Lists kino 0 3,380 06-15-2011, 03:15 PM
Last Post: kino
  Getting Started3:Top-level Applet Specifications kino 0 3,448 06-15-2011, 02:42 PM
Last Post: kino
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('1')