Float in this form is not a command. It's a keyword used to explicitly declare an item as being that of Float data type.
FACTS:
* PlayBasic expects all Float Variables to have '#' symbol. * 32bit Float values are single precision. * 32bit Float values are 4 bytes wide. * Note: Not all declaration forms in PlayBasic V1.64 accept explicit as Float declarations at this time.
Float Variable Examples:
Float Variables can be declared either explicitly or Implicitly, it's up to you. However by default when PlayBasic sees a possible variable with the "#" symbol, it will automaticaly declared it as a Float for you.
Declaration Examples
; *=----------------------------------------=* ; Implicit Float Variable Declaration. ; *=----------------------------------------=* ; By Default when PlayBasic notices a variable ; with the # postfix symbol it will ; automatically cast this variable as a ; Float for you. MyFloatVariable# = 123.456 Print MyFloatVariable# ; *=----------------------------------------=* ; Explicit Float Variable Declaration using DIM ; *=----------------------------------------=* ; Note: Dim Does Not support the # postfix as this time Dim MyFloatVariable As Float ; *=----------------------------------------=* ; Declaring via Declaration/EndDeclaration Blocks ; *=----------------------------------------=* ; Note Declaration lists don't suport the AS Data Type method Declaration ; List your variables in here MyFloatVariable1# ; Implicit MyFloatVariable2# ; Implicit ; etc EndDeclaration ; *=----------------------------------------=* ; Declaring Global Float Variables ; *=----------------------------------------=* Global MyGlobalFloatVariable# ; Implicit ; or Global MyGlobalFloatVariable# = 123.456 ; *=----------------------------------------=* ; Declaring Local Float Variables ; *=----------------------------------------=* Local MyLocalFloatVariable# ; or, Local MyLocalFloatVariable# = 123.456 |
Float User Defined Types:
Examples of defining user defined types fields As Float
; *=--------------------------------------------=* ; Declaring Float Fields in User Defined Types ; *=--------------------------------------------=* Type MyType MyFloatField# ; Implicit MyFloatField2 As Float ; Explicit EndType ; Implicit fields can be listed by using the , ; between them Type MyType2 MyFloatField,MyFloatField2 ; Implicit EndType |
Float Pointer Examples:
This example shows some valid usages of Float pointers.
Pointer Declaration Example
; Declare a Float Pointer (a pointer to read/write Float values) Dim MyPointer As Float 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 Float values to a bank For lp=0 To 10 *MyPointer=123.456+lp ; INcrease the pointer by 1 Float 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. 123.456 124.456 125.456 126.456 127.456 128.456 129.456 130.456 131.456 132.456 133.456 |
|