Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Programming Gambas from Zip/DataTypes

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Data Types and Conversions Data Types One byte is the amount of memory required to store a single character such as the letter “A” or the digit “1”. It is eight bits (1’s or 0’s, like little switches that are on or off, up or down). 8 bits = 1 byte. 4 bits = 1 nibble, but that one is not used much. http://Gambaswiki.org/wiki/lang/type Description and LimitsDefault value Size in memoryBoolean True or falseFALSE 1 byteByte 0 to 255 0 1 byteShort -32,768 to +32,767 0 2 bytesInteger -2,147,483,648 to +2,147,483,647 0 4 bytesLong -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 0 8 bytesSingle Single precision0.0 4 bytesFloat Floating point or double precision0.0 8 bytesDate Date and time, each stored in an integer. NULL 8 bytesString A variable length string of characters. NULL 4 bytes on 32 bits systems, 8 bytes on 64 bits systemsVariant Any datatype. NULL 12 bytes on 32 bits systems, 16 bytes on 64 bits systemsObject Anonymous reference to any object. NULL 4 bytes on 32 bits systems, 8 bytes on 64 bits systems.Pointer A memory address. 0 4 bytes on 32 bits systems, 8 bytes on 64 bits systems Conversions Some conversions are omitted. Many of these conversions are done automatically as required. For example, these are fine without explicitly having to write the functions:label1.text = 54.65 Dim d As Date = "09/06/1972 01:45:12" Dim d As Date = 2484515 gives d the date 05/16/2002 CBoolto a BooleanAn expression is false if it is A false boolean A zero number A zero length string A null date A null object CBool(0) is false CBool(1) is true CBool("Gambas") is true CBool("") is false CBool(Null) is false 0 → False; Anything else → True e.g. 6 is True; -4 is True; 3-(1+2) is False.CDateto a DateCDate("09/06/1972 01:45:12") CDate(2484515)CFloat or CFltto a FloatCFloat("+3.1416") Cfloat("1.0E+3") is 1000CInt or CIntegerto an IntegerCInt("17") is the number 17 CInt(True) is -1 CInt(Now) is 2490779 CInt(3.2) is 3 CInt(3.9) is 3 CInt(6) is 6 CInt(-7.2) is -7 CInt(-7.9) is -7 TRUE → -1 FALSE → 0CStr or CStringto a StringCStr(-1972) is -1972 CStr(Now) is 05/16/2002 15:08:31 CStr(Pi) is 3.14159265359Stra number or a date into a stringThe opposite of Val() Use Format() to have control of what form the number or date takes.Vala string into a number or a dateConversion follows these steps until if finds something it can convert: Look for a date Look for a long Look for an integer Look for a true or false If none, return NULL. IsNull(Val("Gambas")) is True Operators Formatting