User Tools

Site Tools


fb_variables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fb_variables [2022/12/03 07:12] – [DIM] praetorfb_variables [2022/12/04 01:39] (current) – [CONST] praetor
Line 19: Line 19:
  
 <code freebasic> <code freebasic>
-dim personName as string +dim as string personName 
-dim personAge as integer +dim as integer personAge 
-dim radius as float+dim as single radius
  
-dim as integer x,y 
-</code> 
- 
-**PITFALL** 
-While it may seem that 
-<code freebasic> 
-dim x,y as integer 
-</code> 
-will work, it will in fact cause a compile time error. While this may seem counter-intuitive, it's a feature of FreeBASIC's syntax. Instead, to declare multiple variables of the same time, you must use: 
- 
-<code freebasic> 
 dim as integer x,y dim as integer x,y
 </code> </code>
Line 43: Line 32:
 CONST variables are constants, that is their assigned value does not change. An example would be CONST variables are constants, that is their assigned value does not change. An example would be
 <code freebasic> <code freebasic>
-const pi as float = 3.14+const as single pi = 3.14
 </code> </code>
  
Line 51: Line 40:
 ^ Variable types ^ ^ Variable types ^
 | integers | Any whole number that is neither a decimal nor a fraction | | integers | Any whole number that is neither a decimal nor a fraction |
-float | Any number with a decimal place |+single | Any number with a decimal place (single precision) |
 | string | A string of characters | | string | A string of characters |
  
Line 64: Line 53:
  
 <code freebasic> <code freebasic>
-dim as integer +dim as integer a 
-dim as integer +dim as integer b 
-dim as integer+dim as integer c
  
 a = 5 a = 5
Line 80: Line 69:
 First First
 <code freebasic> <code freebasic>
-dim as integer +dim as integer a 
-dim as integer +dim as integer b 
-dim as integer+dim as integer c
 </code> </code>
 declares 3 variables of the integer type. declares 3 variables of the integer type.
fb_variables.1670051556.txt.gz · Last modified: 2022/12/03 07:12 by praetor