Quick Reference - Tables: Difference between revisions
Jump to navigation
Jump to search
(Return to Table of Contents)
(Return to Table of Contents)
(Return to Table of Contents)
(Return to Table of Contents)
(Return to Table of Contents)
Wiki Pages
Main Page with Articles and Tutorials
QB64 specific keywords (alphabetical)
Original QBasic keywords (alphabetical)
QB64 OpenGL keywords (alphabetical)
Keywords by Usage
Got a question about something?
Frequently Asked Questions about QB64
QB64 Phoenix Edition Community Forum
Links to other QBasic Sites:
Pete's QBasic Forum
Pete's QBasic Downloads
No edit summary |
No edit summary |
||
Line 28: | Line 28: | ||
{{ | {{PageReferences}} |
Latest revision as of 12:22, 19 November 2024
QB64 Variable Types
Table 1: The variable types supported by the QB64 language. ┌───────────────────────────────────────────────────────────────────────────┐ │ Numerical types │ ├──────────────────────┬───────────┬────────────────────────────┬───────────┤ │ Type Name │ Type │ Minimum value │ Size in │ │ │ suffix │ Maximum value │ Bytes │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _BIT │ ` │ -1 │ 1/8 │ │ │ │ 0 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _BIT * n │ `n │ -128 │ n/8 │ │ │ │ 127 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _UNSIGNED _BIT │ ~` │ 0 │ 1/8 │ │ │ │ 1 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _BYTE │ %% │ -128 │ 1 │ │ │ │ 127 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _UNSIGNED _BYTE │ ~%% │ 0 │ 1 │ │ │ │ 255 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ INTEGER │ % │ -32,768 │ 2 │ │ │ │ 32,767 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _UNSIGNED INTEGER │ ~% │ 0 │ 2 │ │ │ │ 65,535 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ LONG │ & │ -2,147,483,648 │ 4 │ │ │ │ 2,147,483,647 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _UNSIGNED LONG │ ~& │ 0 │ 4 │ │ │ │ 4,294,967,295 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _INTEGER64 │ && │ -9,223,372,036,854,775,808 │ 8 │ │ │ │ 9,223,372,036,854,775,807 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _UNSIGNED _INTEGER64 │ ~&& │ 0 │ 8 │ │ │ │ 18,446,744,073,709,551,615 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ │ │ -3.402823E+38 │ │ │ SINGLE │ ! or none │ 1.175494E-38 │ 4 │ │ │ │ +3.402823E+38 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ │ │ -1.797693134862315D+308 │ │ │ DOUBLE │ # │ 2.225073858507201D-308 │ 8 │ │ │ │ +1.797693134862315D+308 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ │ │-1.189731495357231765F+4932 │ │ │ _FLOAT │ ## │ 3.362103143112093506F-4932 │ 32 │ │ │ │+1.189731495357231765F+4932 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _OFFSET │ %& │ -9,223,372,036,854,775,808 │ use LEN │ │ │ │ 9,223,372,036,854,775,807 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ _UNSIGNED _OFFSET │ ~%& │ 0 │ use LEN │ │ │ │ 18,446,744,073,709,551,615 │ │ ├──────────────────────┼───────────┼────────────────────────────┴───────────┤ │ _MEM │ none │ An internal TYPE like memory variable. │ └──────────────────────┴───────────┴────────────────────────────────────────┘ For the floating-point numeric types SINGLE (default when not assigned), DOUBLE and _FLOAT, the middle values represent the smallest possible fraction, while the min./max. values above and below represent the limits of the possible number range. _OFFSET dot values are used as a part of the _MEM variable type in QB64 to return or set the position in memory. ┌───────────────────────────────────────────────────────────────────────────┐ │ Text types │ ├──────────────────────┬───────────┬────────────────────────────┬───────────┤ │ Type Name │ Type │ Minimum value │ Size in │ │ │ suffix │ Maximum value │ Bytes │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ STRING │ $ │ 0 │ use LEN │ │ │ │ 2,147,483,647 │ │ ├──────────────────────┼───────────┼────────────────────────────┼───────────┤ │ STRING * n │ $n │ 1 │ n │ │ │ │ 2,147,483,647 │ │ └──────────────────────┴───────────┴────────────────────────────┴───────────┘ While a regular variable length STRING may have a minimum length of zero (empty string), the fixed length string type STRING * n, where n is an integer length value, must have a minimum length of at least one character. |
OpenGL Types
Table 2: Relations between the OpenGL variable types vs. C/C++ and QB64. ┌──────────────┬────────────────┬──────────────────────────────────────────┐ │ OpenGL │ C/C++ │ QB64 │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLenum │ unsigned int │ _UNSIGNED LONG │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLboolean │ unsigned char │ _UNSIGNED _BYTE │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLbitfield │ unsigned int │ _UNSIGNED LONG │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLbyte │ signed char │ _BYTE │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLshort │ short │ INTEGER │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLint │ int │ LONG │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLsizei │ int │ LONG │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLubyte │ unsigned char │ _UNSIGNED _BYTE │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLushort │ unsigned short │ _UNSIGNED INTEGER │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLuint │ unsigned int │ _UNSIGNED LONG │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLfloat │ float │ SINGLE │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLclampf │ float │ SINGLE │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLdouble │ double │ DOUBLE │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLclampd │ double │ DOUBLE │ ├──────────────┼────────────────┼──────────────────────────────────────────┤ │ GLvoid (1) │ void │ _OFFSET(any fixed lenght string or _BYTE │ │ │ │ array element) │ └──────────────┴────────────────┴──────────────────────────────────────────┘ Note: If a parameter has an asterisk (*) in front, then it's a pointer to the designated OpenGL variable type, rather than a value of that type. Those must be passed using the _OFFSET(...) notation. E.g. GLuint *anyParam is actually the offset of a _UNSIGNED LONG (~&) variable or array, which must be passed as _OFFSET(anyVar~&) or _OFFSET(anyArr~&()) respectively. (1) This type is regularly only used for pointers (with asterisk (*)) to any byte sized memory data, hence _BYTE or fixed length strings. |
Relational Operations
Table 3: The relational operations for condition checking. In this table, A and B are the Expressions to compare. Both must represent the same general type, i.e. they must result into either numerical values or STRING values. If a test succeeds, then true (-1) is returned, false (0) if it fails, which both can be used in further Boolean evaluations. ┌─────────────────────────────────────────────────────────────────────────┐ │ Relational Operations │ ├────────────┬───────────────────────────────────────────┬────────────────┤ │ Operation │ Description │ Example usage │ ├────────────┼───────────────────────────────────────────┼────────────────┤ │ A = B │ Tests if A is equal to B. │ IF A = B THEN │ ├────────────┼───────────────────────────────────────────┼────────────────┤ │ A <> B │ Tests if A is not equal to B. │ IF A <> B THEN │ ├────────────┼───────────────────────────────────────────┼────────────────┤ │ A < B │ Tests if A is less than B. │ IF A < B THEN │ ├────────────┼───────────────────────────────────────────┼────────────────┤ │ A > B │ Tests if A is greater than B. │ IF A > B THEN │ ├────────────┼───────────────────────────────────────────┼────────────────┤ │ A <= B │ Tests if A is less than or equal to B. │ IF A <= B THEN │ ├────────────┼───────────────────────────────────────────┼────────────────┤ │ A >= B │ Tests if A is greater than or equal to B. │ IF A >= B THEN │ └────────────┴───────────────────────────────────────────┴────────────────┘ The operations should be very obvious for numerical values. For strings be aware that all checks are done case sensitive (i.e. "Foo" <> "foo"). The equal/not equal check is pretty much straight forward, but for the less/greater checks the ASCII value of the first different character is used for decision making: E.g. "abc" is less than "abd", because in the first difference (the 3rd character) the "c" has a lower ASCII value than the "d". This behavior may give you some subtle results, if you are not aware of the ASCII values and the written case: E.g. "abc" is greater than "abD", because the small letters have higher ASCII values than the capital letters, hence "c" > "D". You may use LCASE$ or UCASE$ to make sure both strings have the same case. |
Logical Operations
Table 4: The logical operations and its results. In this table, A and B are the Expressions to invert or combine. Both may be results of former Boolean evaluations. ┌────────────────────────────────────────────────────────────────────────┐ │ Logical Operations │ ├───────┬───────┬───────┬─────────┬────────┬─────────┬─────────┬─────────┤ │ A │ B │ NOT B │ A AND B │ A OR B │ A XOR B │ A EQV B │ A IMP B │ ├───────┼───────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ │ true │ true │ false │ true │ true │ false │ true │ true │ ├───────┼───────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ │ true │ false │ true │ false │ true │ true │ false │ false │ ├───────┼───────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ │ false │ true │ false │ false │ true │ true │ false │ true │ ├───────┼───────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ │ false │ false │ true │ false │ false │ false │ true │ true │ └───────┴───────┴───────┴─────────┴────────┴─────────┴─────────┴─────────┘ Note: In most BASIC languages incl. QB64 these are bitwise operations, hence the logic is performed for each corresponding bit in both operators, where true or false indicates whether a bit is set or not set. The outcome of each bit is then placed into the respective position to build the bit pattern of the final result value. As all Relational Operations return negative one (-1, all bits set) for true and zero (0, no bits set) for false, this allows us to use these bitwise logical operations to invert or combine any relational checks, as the outcome is the same for each bit and so always results into a true (-1) or false (0) again for further evaluations. |
Formatted Print Symbols
Table 5: The formatting symbols used by the [L]PRINT USING[#] commands. ┌───────┬────────────────────────────────────────────────────────────────┐ │ & │ Prints an entire string value. STRING length should be limited │ │ │ as template width will vary. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ \ \ │ Denotes the start and end point of a fixed string area with │ │ │ spaces between(LEN = spaces + 2). │ ├───────┼────────────────────────────────────────────────────────────────┤ │ ! │ Prints only the leading character of a string value. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ # │ Denotes a numerical digit. An appropriate number of digits │ │ │ should be used for values received. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ ^^^^ │ After # digits prints numerical value in exponential E+xx │ │ │ format. Use ^^^^^ for E+xxx values. (1) │ ├───────┼────────────────────────────────────────────────────────────────┤ │ . │ Period sets a number's decimal point position. Digits following│ │ │ determine rounded value accuracy. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ ,. │ Comma to left of decimal point, prints a comma every 3 used # │ │ │ digit places left of the decimal point. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ + │ Plus sign denotes the position of the number's sign. + or - │ │ │ will be displayed. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ - │ Minus sign (dash) placed after the number, displays only a │ │ │ negative value's sign. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ $$ │ Prints a dollar sign immediately before the highest non-zero # │ │ │ digit position of the numerical value. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ ** │ Prints an asterisk in any leading empty spaces of a numerical │ │ │ value. Adds 2 extra digit positions. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ **$ │ Combines ** and $$. Negative values will display minus sign to │ │ │ left of $. │ ├───────┼────────────────────────────────────────────────────────────────┤ │ _ │ Underscore preceding a format symbol prints those symbols as │ │ │ literal string characters. │ └───────┴────────────────────────────────────────────────────────────────┘ Note: Any string character not listed above will be printed as a literal text character. (1) Any # decimal point position may be specified. The exponent is adjusted with significant digits left-justified. |