EnglishРусский  

   hello

   square

   easymath

   runini

   easyhtml

   calendar

   samefiles

   To be continued

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

easyhtml

This lesson presents one type of function, the text function. As its name suggests, this type of function deals with texts. Unlike other functions, a text with built-in code serves as the basis for text functions.

Example 1

Display a color palette, which is frequently used for creating an HTML page. Save data as an HTML file.

First, determine the number of colors displayed in one line using the define command.

define {
   lcount = 12
}

Note that such constant quantities are called macros. The dollar sign '$' is used before the name in order to run them.
Let's tackle the last point first.

func color< main >
{
   str out
   
   out @ colorhtm()
   out.write( "color.htm" )
   shell( "color.htm" )
}

out @ colorhtm()
As you can see, the result of the colorhtm text function is output to the out string. Using the following commands, we save the obtained string to the file which is opened in the browser window. In our example, ellipses are substituted for the title and the end of the html file.

text  colorhtm
...
\{ 
   int vrgb i j k
   uint cur
   
   subfunc outitem
   {
      str  rgb

      rgb.out4( "%06X", vrgb )
      @ item( rgb )
      if ++cur == $lcount 
      {
         @"</TR><TR>"
         cur = 0 
      }
   }
   for i = 0xFF, i >= 0, i -= 0x33
   {
      for j = 0xFF, j >= 0, j -= 0x33
      {
         for k = 0xFF, k >= 0, k -= 0x33
         {
            vrgb = ( i << 16 ) + ( j << 8 ) + k
            outitem()
         }     
      }     
   }
   for vrgb = 0xFFFFFF, vrgb >= 0, vrgb -= 0x111111 : outitem()
   for vrgb = 0xFF0000, vrgb > 0, vrgb -= 0x110000 : outitem()
   for vrgb = 0x00FF00, vrgb > 0, vrgb -= 0x001100 : outitem()
   for vrgb = 0x0000FF, vrgb > 0, vrgb -= 0x000011 : outitem()
}
...
\!

The \{...} command is used to insert the code into a text. outitem minorant function is defined like thisas:

rgb.out4( "%06X", vrgb )
@ item( rgb )

Here, using the local variable named vrgb, the string is created that contains the hexadecimal representation, then another text function item is called for outputting the cell with the indicated color. The unary operator @ is used to output into the current string or, if there is no string to the console. Then, we determine the total number of cells in the row and add a new row to the table where approriate.

We use three embedded color cycles for searching possible values. Red, green or blue color components are affected by color cycling. Then these color components are arranged in the vrgb variable and we call the minorant function described above.

The next four color cycles display additional palette entries for gray, red, green and blue colors.
The \! command indicates the termination of a text function. By default, a text function works until the end of the file.

Let's take an example - a text function of cell entries.
We want a function that works like this:

text  item( str rgb )
<TD ALIGN=CENTER><TABLE BGCOLOR=#\(rgb) WIDTH=60><TR><TD>  </TD></TR></TABLE>
<FONT FACE="Courier">\(rgb)</FONT>
</TD>
\!

As you can see, this is an HTML text that outputs the rgb color parameter. It is used as the background color of a table cell and for the display of its value output under the table cell.

Exercise 2

Create a HTML file that contains the multiplication table.

Source