V1 support following datatypes: Numbers, Strings, Boolean, Handles, Arrays
Numbers are internally stored as floating point double values. That means also integer numbers are internally double values.
Its important to know that, because of a big 64 Bit integer cannot be stored completely into a double value.
Types of number formats:
<?v1 a = 10; // Integer number a = 10.12; // Floating point number a = 10e-9; // Exponent number a = 0x8000; // Hexadecimal number a = 0b0001; // Binary number a = 0666; // Octal number ?>
Big numbers:
<?v1 a = 0xFFFFFFFFFFFFFFFF; // Assign a 64 Bit hexadecimal number print (a); /* The real value is 18446744073709551615. But the internal floating point representation is 1.844674407371e+019 It differs from the 13th position. */ ?>
Strings are internally representated as a buffer of bytes. A string can contain every character from 0 to 255, but usually UTF8 formatted text. V1 functions work with UTF8 charset. You can use the utf8_encode() and utf8_decode() functions to reformat from or to Latin2 charset. A String can be longer than the ending zero byte. The length of a string in bytes can be determined with strlen() function.
String formats:
<?v1 a = 'String with single quotes. \'Internal single quotes must be escaped\' "Internal double quotes", All other escaped characters like \r\n have no effect.'; a = "String with double quotes. 'Internal single quotes', \"Internal double quotes must be escaped\", For escaped characters like \\ \r\n \t \x32 \77 see description below."; ?>
Escaped characters in double quoted strings:
\r = Carriage return
\n = Line feed
\t = Tabulator
\\ = Backslash
\" = Double quote
\0 = Zero byte
\xHEX = Hexadecimal representated byte
\OOO = Octal representated byte (only decimal range 0..255)
Dynamic conversion between Strings and Numbers:
V1 detect if a string represents a number. Numbers can be used also in string functions.
<?v1 c = "10.23"+"12.23"; print (gettype (c)); // Will output number c = null + 10.23; print (gettype (c)); // Will output number c = 10.23 + ""; print (gettype (c)); // Will output number c = 10e10; print (strlen (c)); // Will output 12 ?>
V1 support Boolean datatype with true and false, usually used for arguments.
Handles are references to internal objects and data structures such as Sockets or Files, generated from V1 functions.
V1 support multi dimensional Arrays.
There are two ways to define an array.
<?v1 // Array as a list. Every entry has a unique index beginning from 0. a = array [true, 1.333, "String", ["Internal Array", 172.3]]; print (a[1]); // will output 1.333 print_r (a[count(a)-1]); // will dump the internal array ("Internal Array", 172.3); // Array as a dictionary with key/value pairs a = array ("Key1"=>"Value1", "Key2"=>"Value2", "Key3"=>1.333, "Key4"=>array ("Key5"=>"Internal Array")); print (a["Key2"]); // will output Value2 ?>
null is the identifier for an empty and undefined variable.
See also Datatype functions.