Home About Rice Downloads Documents Others Cooker CookerGX
Documents  >  Tutorial  >  minimumstructure
Minimum Rice program structure

Purpose of this chapter.

We will learn about a minimum structure of the Rice program through a program that displays the "Hello World!".

Hello world!

Let's look at a code that outputs the "Hello world!".

1:

class main

2:

open method void start()

3:

message m;

4:

m.MessageDialog("Hello world!");

5:

endmethod

6:

endclass

When the above code is executed, it produces the following result.

Figure 1 : Hello world!

If there is no problem, a dialog should be displayed.


The above code has two important structures. Those are the class main and the start method.

Let's look at about those structures.

class main

The class main is a class that serves as an interface between the application and the Rice. Therefore, class main is required for Rice program.

In the application, the execution of the Rice program is to invoke an open-method of class main. If the class main has not been properly defined, you cannot run the Rice program.


Let's look at the elements that make up the definition of the class main.

Figure 2 : elements of the class main definition.

class keyword

The class keyword indicates the start of a class definition. It is required at the first of the class definition.

class name

The class name is an identifier that is the name of the class being defined. It is necessary to immediately after the class keyword.

endclass keyword

The endclass keyword indicates the end of the class definition. It is required at the end of the class definition.

start method definition

open-method of class main can be invoked from the application. Therefore, open-methods are available as a start method of the application.

start() method is special among the open-methods. It is the default start method of the Rice.


Let's look at the start method definition of the class main.

Figure 3 : start method definition.

access control

The method definition begin from the designation of the access control. The access control determine the level of access. If the access control is open, the method will be accessible from the outside. If the access control is closed, it will be inaccessible from the outside.

The start method have to be specified the open because it is invoked from the application.

method keyword

The method keyword indicates that it is a method definition. It has to be specified to the next of the access control.

return type

The return type is designation of the return value type of the method. It has to be specified to the next of the method keyword.

The void is specified as the return type in the above start method. It indicates that the method does not return a value.

The return value type of default start method is optional. You can specify to return a specific type. However, it is meaningless because applications ignore the return value of the default start method.

The return type of the default start method should be specified the void (no return value).

method name

The method name is an identifier that is the name of the method being defined. It has to be specified to the next of the return type.

arguments

The arguments is designation of a set of values that will be passed at the time of the method call. It has to be specified to the next of the method name. Also, it has to surround with a parenthesis.

In the above code, the inside of the parentheses is empty because default start method does not take any arguments.

variable declaration

A variable of the message class has been declared in order to display the dialog. Its name (identifier) is "m".

The message class is a embedded class of the Cooker. It has been implemented in C#. The message class returns an initialized instance in the declaration. Therefore, initialization of instance does not required.

method call

MessageDialog(string) method of the message class is invoked, and a dialogbox is displayed.


"Hello world!".


endmethod keyword

The endmethod keyword indicates the end of the method definition. It has to be specified at the end of the method definition.

Next
Previous
Copyright © Rice All rights reserved.