'--------------------------------------------
' Theremino Automation - Strings
'--------------------------------------------

' Early versions of Theremino Automation
' did not distinguish between numbers and strings.

' The variables were all the same (V1 to V9)
' and this was very simple, but in some cases
' the results became, not intuitive and unpredictable.

' So from version 3.0 there are two types of data.
' Numbers (double precision floating point numbers)
' Strings (simple sequences of ASCII characters)

' -----------------------------------------------------------------------------------
' USER DEFINED VARIABLES - EXAMPLES
' -----------------------------------------------------------------------------------
' Variable Numeric Goofy      ' Numerical variable (initially = 0)
' Variable String  Pluto      ' String variable   (initially = "")

' -----------------------------------------------------------------------------------
' PREDEFINED VARIABLES
' -----------------------------------------------------------------------------------
' v1 v2 v3 v4 v5 v6 v7 v8 v9  ' Numerical variables
' s1 s2 s3 s4 s5 s6 s7 s8 s9  ' String variables

' String text must be enclosed with ""
' Examples:
v1 = 12345.67
s1 = "This is a string"

' -----------------------------------------------------------------------------------
' STRING TO NUMBER CONVERSIONS
' -----------------------------------------------------------------------------------
' The symbol "=" is used.
' The decimal separator is alwais the dot.
' Examples:
v1 = "12345.67"
Print v1

' -----------------------------------------------------------------------------------
' NUMBER TO STRING CONVERSIONS
' -----------------------------------------------------------------------------------
' The "Format" Instruction is used.
' For more instructions search: "VBNET Format" on Google
' Examples:
Print Format(1234.56, "000000.000")		'Result "001234.560"
Print Format(1234.56, "0.0")			'Result "1234.6"
Print Format(1234.56, "0")				'Result "1235"
Print Format(Math_PI, "")				'Result "3.14159265358979"
Print Format(1234.56, "+0.000;-0.000")	'Result "+1234.6" or "-1234.6"

' -----------------------------------------------------------------------------------
' STRING COMPARATIONS
' -----------------------------------------------------------------------------------
' Strings comparations are: > < = >= <= <>
' The result "True" or "False" can be printed
' or used in the conditional instruction "If".

' Examples:
Print "Duck" = "Cat"            ' Result "False"

Print Mid("Duck", 4, 1) = "k"   ' Result "True"

s1 = "Duck"
If s1 = "Duck"                  ' Condition is True
	Beep                        ' the Beep is executed
EndIf
Stop

' -----------------------------------------------------------------------------------
' STRING FUNCTIONS
' -----------------------------------------------------------------------------------
' Mid(string, index, len)   ' Extracts characters, index starts at 1
' Len(string)               ' The result is the number of characters
' Trim(string)              ' Remove leading and final spaces
' PadLeft (string, length)  ' Returns the string padded with spaces up to "length"
' PadRight (string, length) ' Returns the string padded with spaces up to "length"

' Str(number)               ' Turn a number in string with the max number of figures
' Format(number)            ' Turn a number in string with the max number of figures
' Str(number, style)        ' Turn a number in string with specified style
' Format(number, style)     ' Turn a number in string with specified style

' UCase(string)             ' Transforms the entire string to uppercase
' LCase(string)             ' Transforms the entire string to lowercase
' WCase(string)             ' Transforms the string capitalized
' Chars(string, number)     ' Returns the first char of the string repeated "n" times

' Chr(code)                 ' Returns the character with the specified code
' Asc(string)               ' Returns the code of the first character of the string
' Bin(number)               ' Returns a string with the binary representation of the number
' FromBin(string)           ' Returns a number converted from the binary string
' Hex(number)               ' Returns a string with the hex representation of the number
' FromHex(string)           ' Returns a number converted from the hexadecimal string

' This function returns a string with all the "OldStr" replaced with "NewStr"
' Replace(string, OldStr, NewStr)

' This function returns a string without the comments starting from '
' RemoveComments(string)

' These functions count and extract substrings separated by spaces
' GetSeparatedStringCount(str)
' GetSeparatedString(str)

' These functions count and extract substrings with any separator (string too)
' GetSeparatedStringCount(str, separator)
' GetSeparatedString(str, separator)

' -----------------------------------------------------------------------------------
' STRING CONSTANTS
' -----------------------------------------------------------------------------------
' CRLF    ' String containing CR and LF (characters 10 and 13)
' CR	  ' String containing CR (character 13)
' LF	  ' String containing LF (character 10)
' CLS     ' String containing the character 12 (that clears the print area)
' NBSP	  ' Returns a string containing a non-breakable-space
' TAB	  ' Returns a string containing a TAB (tabulation) (character 9)

' -----------------------------------------------------------------------------------
' TIME FUNCTIONS
' -----------------------------------------------------------------------------------
' Now()                  ' Responds a string with date and time
' Today()                ' Responds a string with the date
' Date(year, month, day) ' Create a date from numeric values
' ElapsedTime()          ' The time from the program start in seconds and fractions


