suve
Warning: Illegal string offset 'doublequoteopening' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 766 Warning: Illegal string offset 'doublequoteopening' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 766 Warning: Illegal string offset 'doublequoteclosing' in /usr/home/svgames/domains/svgames.pl/public_html/dokuwiki/inc/parser/xhtml.php on line 774

awful: tutorial: data types

This section of the tutorial focuses on various data types one can encounter and use in awful.

Integer numbers

:writeln b1000101   # Binary (base 2)
:writeln o105       # Octal (base 8)
:writeln i69        # Decimal (base 10)
:writeln h45        # Hexadecimal (base 16)

There are four basic integer types in awful: bin, oct, int and hex. They are functionally identical - all are integer types, signed, and 64bit in size - except for their behaviour when reading/writing to files and converting from/to strings. As can be guessed, the bin type is used to represent numbers in binary, oct in octal, hex in hexadecimal, and int uses the standard decimal system. Values are prefixed by the appropriate lowercase letter (b o i h), which may be followed by a - or + sign. When parsing a number, any non-digit characters are ignored, and the process stops at the first comma (,) or dot (.) encountered.

Real numbers (floating point values)

:writeln f+3.1415926535
:writeln f-1.2345

Floating point values in awful are defined by prefixing them with the lowercase letter f, which may be followed by a - or + sign. When parsing a number, any non-digit characters are ignored, and the first comma (,) or dot (.) marks the border between integer and fraction parts. Any subsequent commas or dots are ignored. Floats in awful are either 80 or 64 bits. You can check this using the :sizeof function.

Strings

:writeln s"Hello world!"
:writeln sXHello world!X

Strings in awful are defined by prefixing them with the lowercase letter s. The first character after the prefix is then used as the string delimiter - which means, in the example above, that the first string is delimited by p, and the second one by X. All characters between the delimiters will be used in the string. If the second delimiter is missing, string will contain everything until the end of line.

:writeln u"Komm, süßer Tod..."
:writeln u-Zażółć gęślą jaźń.-

Revision 33 added support for UTF-8 strings via a new built-in type, utf8. UTF-8 strings are placed in code using the lowercase letter u prefix, followed by a (single-byte!) delimiter. More information about UTF-8 strings can be found in the manual.

Logical (boolean) values

:writeln lTRUE
:writeln l1
:writeln lfalse

Boolean values in awful are defined by the l prefix. After the prefix, you can either put TRUE/FALSE, or a numeric value - any value other than 0 will be recognized as TRUE.

NIL

:writeln =NIL

NIL is the special pnothing typep in awful. It represents no value. It is often used when no other appropriate value can be returned, or to signal errors. To insert a NIL in the code, one can use the =NIL constant.


Next: ⇒ Variables ⇒
Back: ⇐ Hello world! ⇐

wikistrona zmodyfikowana 2014/0601/2317