Curl Global Community
Getting Started1:Creating a Simple Applet: Hello World - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Tutorials (https://communities.curl.com/forumdisplay.php?fid=3)
+--- Forum: Public Training (https://communities.curl.com/forumdisplay.php?fid=4)
+---- Forum: Curl Clues (https://communities.curl.com/forumdisplay.php?fid=5)
+---- Thread: Getting Started1:Creating a Simple Applet: Hello World (/showthread.php?tid=1)



Getting Started1:Creating a Simple Applet: Hello World - kino - 06-15-2011

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




RE: Getting Started1:Creating a Simple Applet: Hello World - joe.coyle - 08-02-2016


I am just learning curl and I have tried your Hello Word! applet but when I run the start.curl file from curl IDE or Eclipse, the web browser is launched but I am just getting a URL that looks like File:/// and it is not launching as a web applet. All the code is displayed in the browser.

Any help would be greatly appreciated.

Joey

(06-15-2011, 02:06 PM)kino Wrote: 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




RE: Getting Started1:Creating a Simple Applet: Hello World - dyoshida - 08-15-2016

Probably I think that your default browser is Google chrome or Microsoft edge.
Because Google chrome not supported NPAPI, chrome cannot display an applet in the the browser window.

Please refer this news release. (However, the language is Japanese)
http://www.curlap.com/release/2015/20150806.html

Therefore, I think it better to use a detached applets (.dcurl).
Step1. Create new curl project and select detached applets type.
Step2. Open start.dcurl file. You can see the code, such as:
Code:
{curl 8.0 applet}
{curl-file-attributes character-encoding = "shift-jis"}
{applet manifest = "manifest.mcurl",
    {compiler-directives careful? = true}
}

{View
    {Frame width = 8cm, height = 8cm},
    visibility = "normal",
    {on WindowClose do
        {exit}
    }
}

Step3. Please modify "Frame" like this.
Code:
{Frame width = 8cm, height = 8cm,
    "Hello World"
},