String is not a command. It's a keyword used to explicitly declare an item as being that of String data type.
FACTS:
* PlayBASIC expects all String Variables to have '$' symbol.
* Each character within a String is takes 1 byte of memory. So the string "Hello World" is at least 11 bytes. PlayBASIC will generally pad strings though to help avoid memory allocation where possible.
* Note: Not all declaration forms in PlayBASIC V1.64 accept explicit as String declarations at this time.
String Variable Examples:
String 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 String for you.
Declaration Examples
; *=----------------------------------------=* ; Implicit String Variable Declaration. ; *=----------------------------------------=* ; By Default when PlayBASIC notices a variable ; with the $ postfix symbol, it will ; automatically cast this variable as a ; String for you. MyStringVariable$= "Hello World" Print MyStringVariable$ ; *=----------------------------------------=* ; Explicit String Variable Declaration using DIM ; *=----------------------------------------=* ; Note: Dim Does Not support the $ postfix as this time Dim MyStringVariable As String ; *=----------------------------------------=* ; Declaring via Declaration/EndDeclaration Blocks ; *=----------------------------------------=* ; Note Declaration lists don't suport the AS Data Type method Declaration ; List your variables in here MyStringVariable1$ ; Implicit MyStringVariable2$ ; Implicit ; etc EndDeclaration ; *=----------------------------------------=* ; Declaring Global String Variables ; *=----------------------------------------=* Global MyGlobalStringVariable$ ; Implicit ; or Global MyGlobalStringVariable$ = "Hello World" ; *=----------------------------------------=* ; Declaring Local String Variables ; *=----------------------------------------=* Local MyLocalStringVariable$ ; or, Local MyLocalStringVariable$ = "Hello World" ; *=--------------------------------------------=* ; Declaring String Fields in User Defined Types ; *=--------------------------------------------=* Type MyType MyStringField$ ; Implicit MyStringField2 As String ; Explicit EndType ; Implicit fields can be listed by using the , ; between them Type MyType2 MyStringField$,MyStringField2$ ; Implicit EndType |
String User Defined Types:
Examples of defining user defined types fields As String
; *=--------------------------------------------=* ; Declaring String Fields in User Defined Types ; *=--------------------------------------------=* Type MyType MyStringField$ ; ; *=--------------------------------------------=* ; 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 MyStringField2 As String ; Explicit EndType ; Implicit fields can be listed by using the , ; between them Type MyType2 MyStringField$,MyStringField2$ ; Implicit EndType |
String Pointer Examples:
Not supported at this time.
|