Revision history for KeyPgAny


Revision [22752]

Last edited on 2019-07-04 00:08:35 by fxm [merged the page POINTER (KeyPgPointer) within page PTR (KeyPgPtr)]
Additions:
[[KeyPgDim|Dim]] //identifier// [[KeyPgAs|As]] **Any** [[KeyPgPtr|Pointer]]|[[KeyPgPtr|Ptr]]
A special pointer type called the ##**Any** [[KeyPgPtr|Ptr]]## (or "##**Any** [[KeyPgPtr|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##.
Deletions:
[[KeyPgDim|Dim]] //identifier// [[KeyPgAs|As]] **Any** [[KeyPgPointer|Pointer]]|[[KeyPgPtr|Ptr]]
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##.


Revision [22643]

Edited on 2019-03-29 10:39:50 by fxm [Suppressed the type declaration that is redundant when resizing a dynamic array (in examples)]
Additions:
Redim a(0 to 1)
Redim b(1 to 10, 2 to 5)
Redim c(0 to 9, 0 to 5, 0 to 1)
Deletions:
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


Revision [22405]

Edited on 2018-08-29 06:53:07 by fxm ['New' -> 'New Expression']
Additions:
Similar to **##Any##** initializers for variables, **##Any##** can also be used with the ##[[KeyPgOpNew|New Expression]]## or ##[[KeyPgOpPlacementNew|Placement New]]## operators in order to leave the newly created object uninitialized (only allowed with data types that do not have constructors).
Deletions:
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).


Revision [22145]

Edited on 2018-02-04 14:44:43 by JeffMarshall [fix starting text]
Additions:
The ##**Any**## keyword is used as a placeholder for a type or value in various ways.
Deletions:
##**Any**## is used as a placeholder for a type or value in various ways.


Revision [21662]

Edited on 2016-11-06 17:42:30 by fxm [Formatting]
Deletions:





Revision [20048]

Edited on 2016-02-10 15:54:32 by DkLwikki [Update link format]
Additions:
[[KeyPgDim|Dim]] //identifier// [[KeyPgAs|As]] **Any** [[KeyPgPointer|Pointer]]|[[KeyPgPtr|Ptr]]
[[KeyPgDeclare|Declare]] [[KeyPgSub|Sub]]|[[KeyPgFunction|Function]] //identifier// ( [[KeyPgByref|Byref]] //identifier// [[KeyPgAs|As]] **Any** [ , ... ] )
[[KeyPgDim|Dim]] //identifier//(**Any** [, **Any**...]) [[KeyPgAs|As]] [[DataType|DataType]]
[ [[KeyPgDeclare|Declare]] ] { [[KeyPgSub|Sub]] | [[KeyPgFunction|Function]] } //proc_name// ( //param//(**Any** [, **Any**...]) [[KeyPgAs|As]] [[DataType|DataType]] )
[[KeyPgDim|Dim]] //identifier// [[KeyPgAs|As]] [[DataType|DataType]] = **Any**
[[KeyPgOpNew|New]] [[DataType|DataType]] **( Any )**
[[KeyPgOpPlacementNew|New(address)]] [[DataType|DataType]] [//count//] **{ Any }**
[[KeyPgInstr|Instr]]|[[KeyPgInstrrev|InstrRev]] ( //string//, **Any** //substring// )
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##** 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.
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]]##).
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).
**##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.
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect.
- ##[[KeyPgDim|Dim]]##
- ##[[KeyPgDeclare|Declare]]##
Deletions:
[[KeyPgDim Dim]] //identifier// [[KeyPgAs As]] **Any** [[KeyPgPointer Pointer]]|[[KeyPgPtr Ptr]]
[[KeyPgDeclare Declare]] [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //identifier// ( [[KeyPgByref Byref]] //identifier// [[KeyPgAs As]] **Any** [ , ... ] )
[[KeyPgDim Dim]] //identifier//(**Any** [, **Any**...]) [[KeyPgAs As]] [[DataType DataType]]
[ [[KeyPgDeclare Declare]] ] { [[KeyPgSub Sub]] | [[KeyPgFunction Function]] } //proc_name// ( //param//(**Any** [, **Any**...]) [[KeyPgAs As]] [[DataType DataType]] )
[[KeyPgDim Dim]] //identifier// [[KeyPgAs As]] [[DataType DataType]] = **Any**
[[KeyPgOpNew New]] [[DataType DataType]] **( Any )**
[[KeyPgOpPlacementNew New(address)]] [[DataType DataType]] [//count//] **{ Any }**
[[KeyPgInstr Instr]]|[[KeyPgInstrrev InstrRev]] ( //string//, **Any** //substring// )
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##** 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.
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]]##).
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).
**##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.
- Not available in the //[[CompilerOptlang -lang qb]]// dialect.
- ##[[KeyPgDim Dim]]##
- ##[[KeyPgDeclare Declare]]##


Revision [17387]

Edited on 2014-12-09 06:16:27 by FxMwikki [In parameter declarations, ANY can be also used to fix the amount of dimensions]
Additions:
[ [[KeyPgDeclare Declare]] ] { [[KeyPgSub Sub]] | [[KeyPgFunction Function]] } //proc_name// ( //param//(**Any** [, **Any**...]) [[KeyPgAs As]] [[DataType DataType]] )
In parameter declarations, **##Any##** can be also specified instead of empty parenthesis in order to fix the amount of dimensions.


Revision [17279]

Edited on 2014-09-20 08:13:10 by FxMwikki [Use the syntax with Any is mandatory when declaring a dynamic array member inside a Type.]
Additions:
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]]##).
Deletions:
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.


Revision [17036]

Edited on 2014-04-26 10:03:24 by DkLwikki [Reformat and document array(any, any, ...)]
Additions:
[[KeyPgDim Dim]] //identifier// [[KeyPgAs As]] **Any** [[KeyPgPointer Pointer]]|[[KeyPgPtr Ptr]]
[[KeyPgDeclare Declare]] [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //identifier// ( [[KeyPgByref Byref]] //identifier// [[KeyPgAs As]] **Any** [ , ... ] )
[[KeyPgDim Dim]] //identifier//(**Any** [, **Any**...]) [[KeyPgAs As]] [[DataType DataType]]
[[KeyPgDim Dim]] //identifier// [[KeyPgAs As]] [[DataType DataType]] = **Any**
[[KeyPgOpNew New]] [[DataType DataType]] **( Any )**
[[KeyPgOpPlacementNew New(address)]] [[DataType DataType]] [//count//] **{ Any }**
[[KeyPgInstr Instr]]|[[KeyPgInstrrev InstrRev]] ( //string//, **Any** //substring// )
- 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.
- 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="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
Deletions:
//identifier// [[KeyPgAs as]] **Any** [[KeyPgPointer Pointer]]|[[KeyPgPtr ptr]]
[[KeyPgDim Dim]] //identifier// [[KeyPgAs as]] [[DataType datatype]] = **Any**
[[KeyPgDeclare declare]] { [[KeyPgSub sub]] | [[KeyPgFunction function]] } //identifier// ( [ ..., ] [[KeyPgByref byref]] //identifier// [[KeyPgAs as]] **Any** [ , ... ] )
{ [[KeyPgOpNew New]] | [[KeyPgOpPlacementNew New(address)]] } [[DataType datatype]] { **(Any)** | [//count//] **{Any}** }
##**Any**## can be used in four different contexts: variable pointers; initialization; to indicate an unknown data type in a function declaration; and object construction.
##**1)**## 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]]//##.
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 passing as a parameter.
You may not create variables of the type ##**Any**##. It is illegal to dereference an ##**Any Pointer**## (although an ##**Any [[KeyPgPtr Ptr]] [[KeyPgPtr Ptr]]**## may be dereferenced once, resulting in an ##**Any [[KeyPgPtr Ptr]]**##).
Arithmetic may be performed on an ##**Any** [[KeyPgPtr Ptr]]## - the effect is that the pointer is changed by increments of ##1##, like with a ##[[KeyPgByte Byte]] [[KeyPgPtr Ptr]]##. However, the ##**Any** [[KeyPgPtr Ptr]]## may not be indexed.
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.
##**2) **## ##**Any**## can be used as a fake initializer to disable the default initialization of primitive variables to ##0##. This may save time in critical sections of a program. It is up to the program to fill the variables with significant data. This is the default behavior of C when a variable is declared without an initialisation value.
For an UDT data member, ##**Any**## only takes effect if there is a constructor (explicit or implicit).
##**3) **## **##Any##** can be used in function prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## arguments to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it is only there for compatibility with QB.
##**4) **## **##Any##** can be used with ##[[KeyPgOpNew New]]## or ##[[KeyPgOpPlacementNew Placement New]]## operator in order to not initialize the data (only valid on data types that do not have constructors).
##**Note: **## The **##Any##** keyword may also 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.


Revision [16972]

Edited on 2013-10-13 15:57:40 by CountingPine [Reword sentence]
Additions:
##**3) **## **##Any##** can be used in function prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## arguments to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it is only there for compatibility with QB.
##**Note: **## The **##Any##** keyword may also 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.
Deletions:
##**3) **## **##Any##** can be used in function prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## arguments to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it is only there for compatibility with QB.
##**Note: **## **##Any##** can also be used with ##[[KeyPginstr InStr]]## or ##[[KeyPgInstrrev InStrRev]]## but as qualifier for the substring parameter to indicate that any character in substring must be searched.


Revision [16971]

Edited on 2013-10-13 03:30:14 by FxMwikki [Added note for a particular use case of ANY with InStr or InStrRev]
Additions:
##**Note: **## **##Any##** can also be used with ##[[KeyPginstr InStr]]## or ##[[KeyPgInstrrev InStrRev]]## but as qualifier for the substring parameter to indicate that any character in substring must be searched.


Revision [16953]

Edited on 2013-09-18 11:51:57 by FxMwikki [For UDT data member, "=Any" only takes effect if there is constructor]
Additions:
For an UDT data member, ##**Any**## only takes effect if there is a constructor (explicit or implicit).


Revision [16952]

Edited on 2013-09-17 13:37:30 by FxMwikki [Any can also be used with New or Placement New operator]
Additions:
{ [[KeyPgOpNew New]] | [[KeyPgOpPlacementNew New(address)]] } [[DataType datatype]] { **(Any)** | [//count//] **{Any}** }
Deletions:
{ [[KeyPgOpNew New]] | [[KeyPgOpPlacementNew New(address)]] } [[DataType datatype]] { **(Any)** | [//count//]**{Any}** }


Revision [16951]

Edited on 2013-09-17 13:30:03 by FxMwikki [Any can also be used with New or Placement New operator]
Additions:
##**Any**## is used as a placeholder for a type or value in various ways.
Deletions:
##**Any**## is used as a placeholder for a type or value in seways.


Revision [16950]

Edited on 2013-09-17 13:23:35 by FxMwikki [Any can also be used with New or Placement New operator]
Additions:
{ [[KeyPgOpNew New]] | [[KeyPgOpPlacementNew New(address)]] } [[DataType datatype]] { **(Any)** | [//count//]**{Any}** }
Deletions:
[[KeyPgOpNew New]] ... (**Any**) | {**Any**}


Revision [16949]

Edited on 2013-09-17 07:37:46 by FxMwikki [Any can also be used with New or Placement New operator]
Additions:
[[KeyPgOpNew New]] ... (**Any**) | {**Any**}
##**Any**## can be used in four different contexts: variable pointers; initialization; to indicate an unknown data type in a function declaration; and object construction.
##**4) **## **##Any##** can be used with ##[[KeyPgOpNew New]]## or ##[[KeyPgOpPlacementNew Placement New]]## operator in order to not initialize the data (only valid on data types that do not have constructors).
Deletions:
##**Any**## can be used in three different contexts: variable pointers; initialization; and to indicate an unknown data type in a function declaration.


Revision [16948]

Edited on 2013-09-15 10:23:56 by FxMwikki [Suppressed false claim on QB]
Additions:
##**3) **## **##Any##** can be used in function prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## arguments to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it is only there for compatibility with QB.
Deletions:
##**3) **## **##Any##** can be used in function prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## arguments to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it is only there for compatibility with QB, where it was the only way of passing arrays as arguments.


Revision [16914]

Edited on 2013-08-11 19:09:04 by CountingPine [Some reworking]
Additions:
##**Any**## is used as a placeholder for a type or value in seways.
##**Any**## can be used in three different contexts: variable pointers; initialization; and to indicate an unknown data type in a function declaration.
##**1)**## 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]]//##.
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 passing as a parameter.
You may not create variables of the type ##**Any**##. It is illegal to dereference an ##**Any Pointer**## (although an ##**Any [[KeyPgPtr Ptr]] [[KeyPgPtr Ptr]]**## may be dereferenced once, resulting in an ##**Any [[KeyPgPtr Ptr]]**##).
Arithmetic may be performed on an ##**Any** [[KeyPgPtr Ptr]]## - the effect is that the pointer is changed by increments of ##1##, like with a ##[[KeyPgByte Byte]] [[KeyPgPtr Ptr]]##. However, the ##**Any** [[KeyPgPtr Ptr]]## may not be indexed.
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.
##**2) **## ##**Any**## can be used as a fake initializer to disable the default initialization of primitive variables to ##0##. This may save time in critical sections of a program. It is up to the program to fill the variables with significant data. This is the default behavior of C when a variable is declared without an initialisation value.
'echo interprets the data in the pointer as bytes
Print Cast(UByte Ptr, x)[i] & " ";
Deletions:
##**Any**## is not a real type, but it is used as a placeholder in various ways.
##**Any**## can be used in three different contexts: pointers; variable initialization; and to indicate an unknown data type in a function declaration.
##**1)**## A special pointer type called the ##**Any** [[KeyPgPtr Pointer]]## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc. However, a pure ##**Any Pointer**## has no type checking by the compiler.
You may not create variables of the type ##**Any**##. It is illegal to dereference an ##**Any Pointer**##, but an ##**Any Pointer Pointer**## may be dereferenced, because doing so will result in an ##**Any Pointer**##. Trying to dereference that resulting ##**Any Pointer**## would be illegal. Just for arithmetic on an ##**Any Pointer**##, the ##[[KeyPgByte Byte]]## is its associated datatype by default.
This should not be confused with ##**Variant**##, a Visual Basic data type which can contain any type of variable. ""FreeBASIC"" does not natively support the ##**Variant**## type.
##**2) **## ##**Any**## can be used as a fake initializer to disable the default initialization to ##0## of the variables. This may save time in critical sections of the programs. It is up to the program to fill the variables with significant data. You may recognize this as the default behavior of C.
'echo interprets the data in the pointer as bytes
Print Cast(UByte Ptr, x)[i] & " ";


Revision [16913]

Edited on 2013-08-11 18:59:59 by CountingPine [I'm not sure of the meaning here, but "At the opposite" is not an English idiom.]
Additions:
##**1)**## A special pointer type called the ##**Any** [[KeyPgPtr Pointer]]## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc. However, a pure ##**Any Pointer**## has no type checking by the compiler.
Deletions:
##**1)**## A special pointer type called the ##**Any** [[KeyPgPtr Pointer]]## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc. At the opposite, a pure ##**Any Pointer**## has no type checking by the compiler.


Revision [16911]

Edited on 2013-08-05 09:39:20 by FxMwikki [Added details on the Any Pointer]
Additions:
##**1)**## A special pointer type called the ##**Any** [[KeyPgPtr Pointer]]## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc. At the opposite, a pure ##**Any Pointer**## has no type checking by the compiler.
You may not create variables of the type ##**Any**##. It is illegal to dereference an ##**Any Pointer**##, but an ##**Any Pointer Pointer**## may be dereferenced, because doing so will result in an ##**Any Pointer**##. Trying to dereference that resulting ##**Any Pointer**## would be illegal. Just for arithmetic on an ##**Any Pointer**##, the ##[[KeyPgByte Byte]]## is its associated datatype by default.
Deletions:
##**1)**## A special pointer type called the ##**Any** [[KeyPgPtr Pointer]]## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc.
You may not create variables of the type ##**Any**##. It is illegal to dereference an ##**Any Pointer**##, but an ##**Any Pointer Pointer**## may be dereferenced, because doing so will result in an ##**Any Pointer**##. Trying to dereference that resulting ##**Any Pointer**## would be illegal.


Revision [15833]

Edited on 2012-01-25 11:05:08 by CountingPine [Remove usage section (largely a duplicate of syntax), reorder to match description, add description ]
Additions:
##**Any**## is not a real type, but it is used as a placeholder in various ways.
##//or//##
##//or//##
##**Any**## can be used in three different contexts: pointers; variable initialization; and to indicate an unknown data type in a function declaration.
##**1)**## A special pointer type called the ##**Any** [[KeyPgPtr Pointer]]## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc.
This should not be confused with ##**Variant**##, a Visual Basic data type which can contain any type of variable. ""FreeBASIC"" does not natively support the ##**Variant**## type.
Deletions:
##**Any**## is not a real type, but it's used as a placeholder in various ways.
//or//
//or//
{{fbdoc item="usage"}}##
**##1)**## Dim //identifier// as **Any** ptr
//or//
**##1)**## Declare Sub //identifier// ( [ byval | byref ] //identifier// as **Any** ptr )
//or//
**##2)**## Dim //identifier// As //datatype// = **Any**
//or//
**##3)**## Declare Sub //identifier// ( byref //identifier// as **Any** )
##**1)**## A special pointer type called the ##**Any [[KeyPgPtr Pointer]]**## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc.
This should not be confused with ##Variant##, a Visual Basic data type which can contain any type of variable. ""FreeBASIC"" does not natively support the ##Variant## type.


Revision [14498]

Edited on 2009-09-24 13:47:15 by CountingPine [Remove usage section (largely a duplicate of syntax), reorder to match description, add description ]
Additions:
##**1)**## A special pointer type called the ##**Any [[KeyPgPtr Pointer]]**## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr Pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger Integer]]##, etc.
Deletions:
##**1)**## A special pointer type called the ##**Any [[KeyPgPtr Pointer]]**## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger integer]]##, etc.


Revision [14497]

Edited on 2009-09-24 13:44:49 by CountingPine [Remove usage section (largely a duplicate of syntax), reorder to match description, add description ]
Additions:
##**Any**## is not a real type, but it's used as a placeholder in various ways.
##**1)**## A special pointer type called the ##**Any [[KeyPgPtr Pointer]]**## allows pointing to any variable type. If you cast it to an ##[[KeyPgInteger Integer]] [[KeyPgPtr pointer]]##, it will operate on the subject as though it were an ##[[KeyPgInteger integer]]##, etc.
This should not be confused with ##Variant##, a Visual Basic data type which can contain any type of variable. ""FreeBASIC"" does not natively support the ##Variant## type.
##**2) **## ##**Any**## can be used as a fake initializer to disable the default initialization to ##0## of the variables. This may save time in critical sections of the programs. It is up to the program to fill the variables with significant data. You may recognize this as the default behavior of C.
Deletions:
ANY is not a real type, it's used as a placeholder in various ways.
##**1)**## A special pointer type called the ##**Any Pointer**## allows pointing to any variable type. If you cast it to an integer pointer, it will operate on the subject as though it were an integer, etc.
This should not be confused with ##Variant##, a Visual Basic data type which can contain any type of variable. FreeBASIC does not natively support the ##Variant## type.
##**2) **## ##**Any**## can be used as a fake initializer to disable the default initialization to 0 of the variables. This may save time in critical sections of the programs. It is up to the program to fill the variables with significant data. You may recognize this as the default behavior of C.


Revision [14496]

Edited on 2009-09-23 03:38:00 by ChA0s [cha0s - Did some cleanups and improvements]
Additions:
ANY is not a real type, it's used as a placeholder in various ways.
**##1)**## Dim //identifier// as **Any** ptr
**##1)**## Declare Sub //identifier// ( [ byval | byref ] //identifier// as **Any** ptr )
**##2)**## Dim //identifier// As //datatype// = **Any**
**##3)**## Declare Sub //identifier// ( byref //identifier// as **Any** )
##**1)**## A special pointer type called the ##**Any Pointer**## allows pointing to any variable type. If you cast it to an integer pointer, it will operate on the subject as though it were an integer, etc.
You may not create variables of the type ##**Any**##. It is illegal to dereference an ##**Any Pointer**##, but an ##**Any Pointer Pointer**## may be dereferenced, because doing so will result in an ##**Any Pointer**##. Trying to dereference that resulting ##**Any Pointer**## would be illegal.
This should not be confused with ##Variant##, a Visual Basic data type which can contain any type of variable. FreeBASIC does not natively support the ##Variant## type.
##**2) **## ##**Any**## can be used as a fake initializer to disable the default initialization to 0 of the variables. This may save time in critical sections of the programs. It is up to the program to fill the variables with significant data. You may recognize this as the default behavior of C.
##**3) **## **##Any##** can be used in function prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## arguments to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it is only there for compatibility with QB, where it was the only way of passing arrays as arguments.
Deletions:
Built-in pseudo data type used in declarations and initializers
Dim //identifier// as **Any** ptr
Declare Sub //identifier// ( byref //identifier// as **Any** )
Declare Sub //identifier// ( [ byval | byref ] //identifier// as **Any** ptr )
Dim //identifier// As //datatype// = **Any**
##**Any**## can be used in three contexts: pointers, variable initializers, pointer arguments of functions and function declarations to indicate an unknown data type.
A pointer defined as an ##**Any** Ptr## disables the compiler checking for the type of data it points to. It is useful as it can point to different types of data. Before dereferencing it (accessing to the data it points to) it must be ##[[KeyPgCast Cast]]## to a known data type.
This should not be confused with ##Variant##, a Visual Basic data type which can contain any type of variable, which is not intrinsically supported by FreeBASIC.
##**Any**## can be used as a fake initializer to disable the default initialization to 0 of the variables. This may save time in critical sections of the programs. Is up to the program to fill the variables with significant data.
**##Any##** can be used in function parameter lists with ##[[KeyPgPtr Ptr]]## arguments to allow the passing of any type of pointers. In this case the function must ##[[KeyPgCast Cast]]## the pointer argument to a known data type before accessing it.
**##Any##** can be used in function prototypes (in a ##[[KeyPgDeclare Declare]]## statement) with ##[[KeyPgByref ByRef]]## arguments to disable the compiler checking for the correct type of the variable passed. This use of ##**Any**## is deprecated and it is only there for compatibility with QB, where it was the only way of passing arrays as arguments.


Revision [14258]

Edited on 2009-08-29 21:51:07 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- Pointers and initializers are new to ""FreeBASIC"".
Deletions:
- Pointers and initializers are new to FreeBASIC.


Revision [12856]

The oldest known version of this page was created on 2008-04-01 15:48:33 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode