{{fbdoc item="title" value="ANY"}}----
##**Any**## is used as a placeholder for a type or value in various ways.

{{fbdoc item="syntax"}}##
	[[KeyPgDim Dim]] //identifier// [[KeyPgAs As]] **Any** [[KeyPgPointer Pointer]]|[[KeyPgPtr Ptr]]
##//or//##
	[[KeyPgDeclare Declare]] [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //identifier// ( [[KeyPgByref Byref]] //identifier// [[KeyPgAs As]] **Any** [ , ... ] )
##//or//##
	[[KeyPgDim Dim]] //identifier//(**Any** [, **Any**...]) [[KeyPgAs As]] [[DataType DataType]]
##//or//##
	[ [[KeyPgDeclare Declare]] ] { [[KeyPgSub Sub]] | [[KeyPgFunction Function]] } //proc_name// ( //param//(**Any** [, **Any**...]) [[KeyPgAs As]] [[DataType DataType]]  )
##//or//##
	[[KeyPgDim Dim]] //identifier// [[KeyPgAs As]] [[DataType DataType]] = **Any**
##//or//##
	[[KeyPgOpNew New]] [[DataType DataType]] **( Any )**
##//or//##
	[[KeyPgOpPlacementNew New(address)]] [[DataType DataType]] [//count//] **{ Any }**
##//or//##
	[[KeyPgInstr Instr]]|[[KeyPgInstrrev InstrRev]] ( //string//, **Any** //substring// )
##
{{fbdoc item="desc"}}

	- Pointers:
		A special pointer type called the ##**Any** [[KeyPgPtr Ptr]]## (or "##**Any** [[KeyPgPointer Pointer]]##") allows pointing to any variable type.  If you cast it to a ##//[[DataType]]// [[KeyPgPtr Ptr]]##, it can be indexed or dereferenced to access the memory as an instance of ##//[[DataType]]//##. Pointer arithmetic is allowed on an ##**Any** Ptr##, and treats it like a ##[[KeyPgByte Byte]] Ptr##: The pointer is changed by increments of ##1##.
		
		A pure ##**Any** [[KeyPgPtr Ptr]]## has no type checking by the compiler.  It can be implicitly converted to and from other pointer types through assignment or parameter passing.
		
		##**Any**## on its own is not a valid data type for a variable. Also, it is illegal to dereference an ##**Any** Ptr## (although an ##**Any** Ptr Ptr## may be dereferenced to produce a ##**Any** Ptr##).
		
		This should not be confused with ##**Variant**##, a Visual Basic data type which can contain any type of variable. ""FreeBASIC"" does not provide native support for a ##**Variant**## type.
	
	- Byref parameters:
		**##Any##** can be used in procedure prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## parameters to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it only exists for compatibility with QB.
	
	- Array dimensions:
		In array declarations, **##Any##** can be specified in place of the array bounds in order to create a dynamic array with a certain amount of dimensions that is determined based on the number of **##Any##**s specified (use the syntax with **##Any##** is mandatory when declaring a dynamic array member inside a ##[[KeyPgType Type]]##).
		
		In parameter declarations, **##Any##** can be also specified instead of empty parenthesis in order to fix the amount of dimensions.
	
	- Initialization:
		##**Any**## can be used as a fake initializer to disable the default initialization of variables to ##0##, leaving the variable uninitialized. This may save time in critical sections of a program. It is the program's responsibility to fill the variables with meaningful data before reading it.
		
		Comparison to ""C/C++"": This matches the behavior of a variable declaration without initialization value in ""C/C++"".
		
		Similar to **##Any##** initializers for variables, **##Any##** can also be used with the ##[[KeyPgOpNew New]]## or ##[[KeyPgOpPlacementNew Placement New]]## operators in order to leave the newly created object uninitialized (only allowed with data types that do not have constructors).
	
	- ""Instr/InstrRev"":
		**##Any##** can be used with ##[[KeyPgInstr Instr]]## or ##[[KeyPgInstrrev InstrRev]]## as a qualifier for the ##//substring//## parameter, to indicate that any individual character in it may be matched.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/misc/any.bas"}}%%(freebasic)
Declare Sub echo(ByVal x As Any Ptr) '' echo will accept any pointer type

Dim As Integer a(0 To 9) = Any '' this variable is not initialized
Dim As Double  d(0 To 4)

Dim p As Any Ptr

Dim pa As Integer Ptr = @a(0)
Print "Not initialized ";
echo pa       '' pass to echo a pointer to integer

Dim pd As Double Ptr = @d(0)
Print "Initialized ";
echo pd       '' pass to echo a pointer to double

p = pa     '' assign to p a pointer to integer
p = pd     '' assign to p a pointer to double      

Sleep

Sub echo (ByVal x As Any Ptr)
	Dim As Integer i
	For i = 0 To 39
		'echo interprets the data in the pointer as bytes
		Print Cast(UByte Ptr, x)[i] & " ";
	Next
	Print
End Sub
%%

{{fbdoc item="filename" value="examples/manual/misc/any-param.bas"}}%%(freebasic)
'Example of ANY disabling the variable type checking
Declare Sub echo (ByRef a As Any) '' ANY disables the checking for the type of data passed to the function

Dim x As Single
x = -15
echo x                  '' Passing a single to a function that expects an integer. The compiler does not complain!!             
Sleep

Sub echo (ByRef a As Integer)
  Print Hex(a)         
End Sub

%%

{{fbdoc item="filename" value="examples/manual/misc/any-dynamic-array.bas"}}%%(freebasic)
Dim a(Any) As Integer ' 1-dimensional dynamic array
Dim b(Any, Any) As Integer ' 2-dimensional dynamic array
Dim c(Any, Any, Any) As Integer ' 3-dimensional dynamic array
' etc.

' Further Redims or array accesses must have a matching amount of dimensions
Redim a(0 to 1) As Integer
Redim b(1 to 10, 2 to 5) As Integer
Redim c(0 to 9, 0 to 5, 0 to 1) As Integer
%%

{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang -lang qb]]// dialect.

{{fbdoc item="diff"}}
	- Pointers and initializers are new to ""FreeBASIC"".

{{fbdoc item="see"}}
	- ##[[KeyPgDim Dim]]##
	- ##[[KeyPgDeclare Declare]]##

{{fbdoc item="back" value="CatPgProcedures|Procedures"}}