Declaration
Declaration .... List Of Variables ... EndDeclaration
 
Parameters: NONE
Returns: NONE
 

      Declaration opens a variable declaration block. The block is closed by the EndDeclaration statement. Within this block Variables (integer/float & string) can be implicitly listed (declared) . Variables can either be listed one per line, or be separated across a line using the coma character.

      Declaration blocks are really only useful when the compiler has Explicit Mode enabled.



FACTS:


      * Declaration blocks only support the declaration of Integer, Float and String variables.

      * Variables listed between the Declaration and EndDeclaration statements must be implicitly declared (Use their postfix symbol). Therefore you can NOT use the "As DataType" method.




Mini Tutorial:


This example just demos the basic of PlayBASIC Explicit mode.

  
; -------------------------------------------------------
; NOTE: Explicit and ForceDeclaration  are interchangeable
; -------------------------------------------------------
  
; Force PlayBASIC to expect all variables to be
; declared prior to use
  
  Explicit
  
  
; declare a list of variables using a Declaration Block
  Declaration
     MyVariable
     MyFloatVariable#
     MyStringVariable$
  EndDeclaration
  
; Declare Variables with DIM
  
  Dim ThisIsAnotherIntegerVariable As Integer
  Dim ThisIsAnotherFloatVariable As Float
  Dim ThisIsAnotherStringVariable As String
  
  
  
; Assign these variables some data
  MyVariable               =99
  MyFloatVariable#     =123.456
  MyStringVariable$ = "Hello World"
  
  
; Assign these variables some data
  ThisIsAnotherIntegerVariable          =12345678
  ThisIsAnotherFloatVariable#          =111.222
  ThisIsAnotherStringVariable$          ="Hello World Again"
  
  
; Display the variables
  Print MyVariable
  Print MyFloatVariable#
  Print MyStringVariable$
  
; Print the second batch of variables
  Print ThisIsAnotherIntegerVariable
  Print ThisIsAnotherFloatVariable#
  Print ThisIsAnotherStringVariable$
  
  
  
; Display the screen and wait for the user to press a key
  Sync
  WaitKey
  
  
  



This example would output.

  
  99
  123.456
  Hello World
  12345678
  111.222
  Hello World Again
  

 
Related Info: Byte | Dim | Explicit | Float | ForceDeclaration | Global | Integer | Local | Pointer | Static | String | Type | Word :
 


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