Home Notices Documents Classes Download Others Rice
Documents  >  tutorial  >  Basic usage  >  Navigation
Navigation of CookerGX

Purpose of this page

CookerGX is an application for Web Automation and Web Scraping. Therfore, we need to display the target web page.

We will learn how to load a web page into CookerGX on this page.

Declaration statement

sample_003.cgx is shown below. This is a script to navigate CookerGX to Google search page.

1:

class main

2:

// Navigating browser to google search page.

3:

open method void start()

4:

browser brw; // Declaration statement. Creates variable - brw - of browser class.

5:

brw.Navigate("https://www.google.com/"); // Calling the Navigate method.

6:

endmethod

7:
8:

open method void end()

9:

endmethod

10:

endclass

sample_003.cgx is a script that has added two lines to the start() method of sample_002.cgx.


Here, the point is the fourth line. The word browser is followed by the word brw and ends with a semicolon.

A word sequence like word, word, and semicolon is called a declaration statement in Rice. However, the words must meet the declaration statement rule.

The first word must be a class name. It is specified the word browser that indicates the browser class in this case.

The class is explained later. Please remember “CookerGX has a group of functions for operating the browser, and name of the group is browser.". That is enough for now.

The second word is the variable name. Here we use the word brw as appropriate name.

The variables and their naming rule are described later. It is enough to understand that brw is valid as a variable name.

The last is a semicolon. This is a symbol that indicates the end of a statement.





Declaration statement is a statement for introducing a name to script. It Informs the CookerGX that the name will be used in the script.

The above declaration has told CookerGX the name brw and its class.

Call statement

Next is the fifth line. This word sequence consists of brw declared in the fourth line followed by a dot, followed by word Navigate, and ("https: //www.google ...");.

Such word sequence is called the call statement in Rice. The important thing in the call statement is the dot. This is an operator called the dot operator which instructs CookerGX to call a member.


CookerGX knows that brw is a browser class by declaration statement in the fourth line. CookerGX can know the intent of "calling Navigate from a group of functions called browser" because the brw followed by a dot and Navigate.

The feature of the Navigate is browser navigation. The navigation requires destination URL. It is passed by ("https://www.google.com/"). The final semicolon (;) indicates the end of the sentence.





When this call statement is executed, the browser of CookerGX starts navigation to the Google search page.

Script execution

Let's execute sample_003.cgx. Is Google search page displayed?


sample_003.cgx is a script that only navigates to a fixed URL, but if you rewrite the URL part, you can freely jump to the desired web page.

The browser class has many other useful features like Navigate. In addition, many named feature groups - class - are included other than the browser class.

These combinations will create new functions you want.

Class and member

All the sample scripts that came out so far were definitions of the main class. And we already explained that can freely define new classes other than main.

Classes defined by users are called user-defined classes.


CookerGX has predefined classes that are not user-defined classes. These predefined classes are called the built-in class.

There are two types of built-in classes. they are Rice basic classes and CookerGX built-in classes.

Rice basic classes : A class that can be used commonly by all Rice scripts. they are basic elements such as numbers and strings.

CookerGX built-in classes : Classes that can be used only with Rice script on CookerGX. They are components of CookerGX such as windows and browsers.


For example, there is no program that does not handle numbers.

For example, CookerGX has a browser as a component. It can be easily predicted that the browser is frequently operated from user-defined classes.

The built-in class predefineds such functions that are used by many users. The browser class mentioned above is one of such built-in classes.

A list of built-in classes can be check here.


The term member in Rice means the component of class.

The member types are shown below.

field

fitter

setter

getter

method

For more information about individual members, please refer to the manual.

The Navigate mentioned above is the Navigate method that is a member of the browser class.



Variable and name

The exact variables definition of Rice are as follows.

A name given to memory area that holds an address of the memory.

This is not an appropriate explanation for the tutorial, so we restate it easily.

Variable is a container with name. In addition, A variable is bound to a class as shown in the above declarative statement, so it is a named container, and the class of value to enter is fixed.

A value can be replaced because a variable is a container. However, since a class to enter is fixed, other classes can not be entered.





A naming rules for variables are as follows.

Usable characters are single-byte characters. Double-byte characters can not be used.

The first letter is underscore or alphabet, and followed by zero or more repetitions of the alphabet, underscore or numbers.

Uppercase and lowercase letters are distinguished.

There is no limit on the number of characters.

Reserved words can not be used for names. Reserved words are keywords and class names of built-in classes.


For more detailes of the naming rules, Please refer to the manual.

Dot operator and method call

The dot operator is an operator for calling a member of the class to the left of the operator. In the above example, the left side of the dot operator is a browser class variable, so the member of the browser class is called, but the left side of the operator is not limited to a variable.

If the kind of the class on the left side can be determined, the members of the determined class are called.





The above example called the Navigate method which is a member of the browser class. A method is a member that can pass zero or more values at calling time. This passed value is called an argument.

The number of arguments and their class are strictly defined for each method. The Navigate method is defined to pass one string - URL - as an argument, so "https: //www.google ..." in parentheses is passed as an argument even in the above example.

For notations when no argument or more than one argument, please see the manual.

Statement and semicolon

A word sequence of meaningful such as a declaration statement or a call statement is called a statement. And a semicolon is a symbol indicating the end of a statement. In fact, both the declaration statement and the call statement end with a semicolon.

However, There are some statements do not end with a semicolon. They will be explained each time they come out in the later tutorials.

Next
Previous
Copyright © CookerGX All rights reserved.