Integer
 

      Integer is not a command. It's a keyword used to declare an item as being that of a Integer data type.




FACTS:


      * 32bit Integer values can represent a numeric range of -2147483648 to 2147483647
      * 32bit Integer values are signed.
      * 32bit Integer are 4 bytes wide
      * 32bit Integer are 2 words wide

      * Note: Not all declaration forms in PlayBasic V1.28 accept explicit as Integer declarations at this time.




Integer Variable Examples:

      Integer Variables can be declared either explicitly or Implicitly, it's up to you. However by default when PlayBasic sees a possible variable without a postfix symbol (ie. '#' or '$'), it will automaticaly declared it as a Integer for you.



Declaration Examples

  
  
; *=----------------------------------------=*
; Implicit Integer Variable Declaration.
; *=----------------------------------------=*
;  By Default when PlayBasic notices a variable
; without a post fix symbol of like # or $, it
; will automatically cast this variable as an
; Integer for you.
  
  MyIntegerVariable = 1234567
  Print MyIntegerVariable
  
  
  
; *=----------------------------------------=*
; Explicit Integer Variable Declaration using DIM
; *=----------------------------------------=*
  
  Dim MyIntegerVariable As Integer
  
  
  
; *=----------------------------------------=*
;  Declaring  via a declaration/enddeclaration Blocks
; *=----------------------------------------=*
  
; Note Declaration lists don't suport the AS Data Type method
  
  Declaration
   ; List your variables in here
     MyIntegerVariable1 ; Implicit
     MyIntegerVariable2 ; Implicit
   ; etc
  EndDeclaration
  
  
  
; *=----------------------------------------=*
;  Declaring  Global Integer Variables
; *=----------------------------------------=*
  
  Global MyGlobalIntegerVariable   ; Implicit
  
  
; or
  Global MyGlobalIntegerVariable = Expression
  
  
  
; *=----------------------------------------=*
;  Declaring  Local Integer Variables
; *=----------------------------------------=*
  Local MyLocalIntegerVariable
  
; or,
  Local MyLocalIntegerVariable = 42
  




Integer User Defined Types:

      Examples of defining user defined types fields As Integer

  
  
; *=--------------------------------------------=*
; Declaring  Integer Fields in User Defined Types
; *=--------------------------------------------=*
  
  Type MyType
     MyIntegerField                 ; Implicit
     MyIntegerField2 As Integer     ; Explicit
  EndType
  
  
; Implicit fields can be listed by using the ,
; between them
  
  Type MyType2
     MyIntegerField,MyIntegerField2  ; Implicit
  EndType
  
  
  
  
  







Integer Pointer Examples:

      This example shows some valid usages of Integer pointers.


Pointer Declaration Examples

  
; Declare a Integer Pointer (a pointer to read/write Integer values)
  Dim MyPointer As Integer Pointer
  
; Create a bank
  CreateBank 1,100
  
; Get the address of this bank and store it in MyPointer
  MyPointer=GetBankPtr(1)
  
; Use this pointer to write some Integer values to a bank
  For lp=0 To 10
     *MyPointer=1234567+lp
   ; INcrease the pointer by 1 integer value (4 bytes)
     MyPointer=MyPointer+1
  Next
  
; Get the address of this bank and store it in MyPointer again
  MyPointer=GetBankPtr(1)
  
; Use this pointer to read the values back
  For lp=0 To 10
     Print *(MyPointer+lp)
  Next
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  




This example would output.

  
  1234567
  1234568
  1234569
  1234570
  1234571
  1234572
  1234573
  1234574
  1234575
  1234576
  1234577
  

 
Related Info: Byte | Dim | Float | Global | Literals | Local | Pointer | Static | Type | Variables | Word :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com