$LET: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "$LET is precompiler command, which is now usable by modern day cavemen to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions. {{PageSyntax}} : $LET variable = expression {{PageDescription}} * Unlike LET, $LET is not optional. * $LET a = 12 sets a precompiler variable "a" to the value of 12. This variable is only valid for the precompiler itself and does nothing to affect...")
 
No edit summary
Tag: Manual revert
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[$LET]] is precompiler command, which is now usable by modern day [[cavemen]] to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions.
[[$LET]] is a precompiler command, which helps to include and/or exclude sections of code in a program based on OS/bit-size or other predefined conditions.




Line 9: Line 9:
* Unlike [[LET]], [[$LET]] is not optional.
* Unlike [[LET]], [[$LET]] is not optional.
* $LET a = 12 sets a precompiler variable "a" to the value of 12.  This variable is only valid for the precompiler itself and does nothing to affect the values of any variable/constant which might also be called "a" in the program.
* $LET a = 12 sets a precompiler variable "a" to the value of 12.  This variable is only valid for the precompiler itself and does nothing to affect the values of any variable/constant which might also be called "a" in the program.
* Variable names can contain numbers, letters, and periods in any order. [[$LET]] '''3.2 = TRUE''' is a perfectly valid variable and expression.
* Variable names must follow QB64's variable naming conventions.
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order. [[$LET]] '''3.2 = "TRUE"''' is also perfectly valid, but [[$LET]] '''3.2 = ""TRUE""''' will error because of the double quotes.
* You can check a precompiler variable against special values '''DEFINED''' and '''UNDEFINED''', in order to assess whether the variable has already been assigned a value. Useful for code in libraries which may be repeated.
* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. These are:
** '''WIN''' or '''WINDOWS''' if the user is running QB64 in a Windows environment.
** '''LINUX''' if the user is running QB64 in a Linux environment.
** '''MAC''' or '''MACOSX''' if the user is running QB64 in a macOS environment.
** '''32BIT''' if the user is running a 32-bit version of QB64.
** '''64BIT''' if the user is running a 64-bit version of QB64.
** '''VERSION''', which is set to the version of the QB64 compiler.




Line 22: Line 29:
* [[$ELSEIF]]
* [[$ELSEIF]]
* [[$END IF]]
* [[$END IF]]
* [[Cavemen]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 18:03, 25 November 2022

$LET is a precompiler command, which helps to include and/or exclude sections of code in a program based on OS/bit-size or other predefined conditions.


Syntax

$LET variable = expression


Description

  • Unlike LET, $LET is not optional.
  • $LET a = 12 sets a precompiler variable "a" to the value of 12. This variable is only valid for the precompiler itself and does nothing to affect the values of any variable/constant which might also be called "a" in the program.
  • Variable names must follow QB64's variable naming conventions.
  • You can check a precompiler variable against special values DEFINED and UNDEFINED, in order to assess whether the variable has already been assigned a value. Useful for code in libraries which may be repeated.
  • The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. These are:
    • WIN or WINDOWS if the user is running QB64 in a Windows environment.
    • LINUX if the user is running QB64 in a Linux environment.
    • MAC or MACOSX if the user is running QB64 in a macOS environment.
    • 32BIT if the user is running a 32-bit version of QB64.
    • 64BIT if the user is running a 64-bit version of QB64.
    • VERSION, which is set to the version of the QB64 compiler.


Examples

  • See example 1 in $IF.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link