Revision history for KeyPgOpNew


Revision [22678]

Last edited on 2019-05-06 03:22:56 by fxm [Added of test if null pointer return, in 1st example]
Additions:

' test if null return pointer
if (p = 0) then
print "Error: unable to allocate memory, quitting."
end -1
end if
' test if null return pointer
if (p = 0) then
print "Error: unable to allocate memory, quitting."
end -1
end if


Revision [22669]

Edited on 2019-05-03 04:23:27 by fxm [Added example of nested New [] to get a 2-dimentional object array]
Additions:
Output example:
%%
Constructor Constructor Constructor Constructor Constructor
Constructor Constructor Constructor Constructor Constructor
Constructor Constructor Constructor Constructor Constructor
Constructor Constructor Constructor Constructor Constructor
0 1 2 3 4
10 11 12 13 14
20 21 22 23 24
30 31 32 33 34
Destructor Destructor Destructor Destructor Destructor
Destructor Destructor Destructor Destructor Destructor
Destructor Destructor Destructor Destructor Destructor
Destructor Destructor Destructor Destructor Destructor%%


Revision [22668]

Edited on 2019-05-03 04:17:33 by fxm [Added example of nested New [] to get a 2-dimentional object array]
Additions:
sleep
{{fbdoc item="filename" value="examples/manual/operator/nested_new.bas"}}%%(freebasic)
'' Example of nested New [] to get a 2-dimentional object array (4*3)
type UDT
dim as integer N
declare constructor ()
declare destructor ()
constructor UDT ()
print "Constructor",
end constructor
destructor UDT ()
print "Destructor",
end destructor
dim as UDT ptr ptr p = new UDT ptr [4] '' New [] allocation for the first dimension:
'' no internal allocation of extra uinteger because
'' allocation of array of pointers (to UDT objects with destructor)
for I as integer = 0 to 3
p[I] = new UDT [5] '' New [] allocations for the last dimension:
'' internal allocation of an extra uinteger for each New [],
'' because allocation of an array of UDT objects with destructor
print
next I
for I as integer = 0 to 3
for J as integer = 0 to 4
p[I][J].N = I * 10 + J '' assignment of each object array element
next J
next I
print
for I as integer = 0 to 3
for J as integer = 0 to 4
print p[I][J].N, '' display of each object array element
next J
print
next I
print
for I as integer = 0 to 3
delete [] p[I] '' Delete [] deallocations for the last dimension
print
next I
delete [] p '' Delete [] deallocation for the first dimension)
print
sleep


Revision [22665]

Edited on 2019-05-03 01:38:14 by fxm [Clarified that New [] is one-dimensional]
Additions:
##**New[] Expression**## operator is the (one-dimensional) array-version of the ##**New Expression**## operator and allocates enough memory for the specified number of objects. The default constructor for the type will be used to set the initial values for each item.
Deletions:
##**New[] Expression**## operator is the array-version of the ##**New Expression**## operator and allocates enough memory for the specified number of objects. The default constructor for the type will be used to set the initial values for each item.


Revision [22503]

Edited on 2018-09-23 00:29:51 by fxm [Tried to add a LF for the .chm file]
Deletions:


Revision [22500]

Edited on 2018-09-22 10:16:52 by JeffMarshall [uinteger count is allocated only if there is a destructor]
Additions:

The total memory, in bytes, to be allocated with ##**New** //datatype//[//count//]## expression is calculated as ##//sizeof(datatype) * count//##, plus ##//sizeof(uinteger)//## if there is an implicit or explicit ##[[KeyPgDestructor|Destructor]]##. The total memory requested in bytes to be allocated must not overflow the value that can be held by a ##[[KeyPgUinteger|Uinteger]]##. The extra ##//uinteger//##, if allocated, stores the number of elements as part of the allocation, so that ##[[KeyPgOpDelete|Delete Statement]]## can determine the count of destructors to call.
If the memory allocation fails, a null pointer is returned and no constructors are called.
Deletions:
The total memory, in bytes, to be allocated with ##**New** //datatype//[//count//]## is calculated as ##//sizeof(datatype) * count + sizeof(uinteger)//##. ##//count//## specifies the number of elements to be allocated, and the total memory requested to be allocated must not overflow the value that can be held by a ##[[KeyPgUinteger|Uinteger]]##. The extra ##//uinteger//## stores the number of elements allocated as part of the allocation.


Revision [22498]

Edited on 2018-09-22 00:00:26 by fxm [Tried to add LF for .chm]

No Differences

Revision [22497]

Edited on 2018-09-21 23:56:32 by fxm [Added LF for .chm]
Deletions:


Revision [22496]

Edited on 2018-09-20 21:21:35 by JeffMarshall [new can return null poniter, allocation must not exceed uinteger]
Additions:
A pointer of type [[DataType|datatype]] to the newly allocated data, or null pointer if the memory allocation failed.
The total memory, in bytes, to be allocated with ##**New** //datatype//[//count//]## is calculated as ##//sizeof(datatype) * count + sizeof(uinteger)//##. ##//count//## specifies the number of elements to be allocated, and the total memory requested to be allocated must not overflow the value that can be held by a ##[[KeyPgUinteger|Uinteger]]##. The extra ##//uinteger//## stores the number of elements allocated as part of the allocation.
Deletions:
A pointer of type [[DataType|datatype]] to the newly allocated data.


Revision [22449]

Edited on 2018-08-30 03:24:38 by fxm [Page updated while 'Operator New Overload' page creation]
Additions:
**Note:** Using ##//pointer// = **New** //datatype//[//count//]## may be unsafe if ##//pointer//## was declared with a type different from ##//datatype//## (for sub-type polymorphism purpose for example), because the pointer arithmetic fails to access the elements if the pointer type size is different from the size of ##//datatype//## (when using ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|Operator [] (Pointer index)"}}## or adding an offset (element number) to the pointer, or even when ##**Delete[] Statement**## itself (the array-version of ##[[KeyPgOpDelete|Delete Statement]]##) must destroy the elements).
Deletions:
**Note:** Using ##//pointer// = **New** //datatype//[//count//]## may be unsafe if ##//pointer//## was declared with a type different from ##//datatype//## (for sub-type polymorphism purpose for example), because the pointer arithmetic fails to access the elements if the pointer type size is different from the size of ##//datatype//## (when using ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|Operator [] (Pointer index)"}}## or adding an offset (element number) to the pointer, or even when ##**Delete[]**## itself (the array-version of ##[[KeyPgOpDelete|Delete]]##) must destroy the elements).


Revision [22446]

Edited on 2018-08-30 02:25:48 by fxm [Page updated while 'Operator New Overload' page creation]
Additions:
The dynamic memory allocation process part provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpNewOverload|New Overload]]##. The following process part for data construction can never be modified.
Deletions:
The dynamic memory allocation process provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpNewOverload|New Overload]]##. The following process of data construction can never be modified.


Revision [22432]

Edited on 2018-08-29 13:13:20 by fxm [Page updated while 'Operator New Overload' page creation]
Additions:
The dynamic memory allocation process provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpNewOverload|New Overload]]##. The following process of data construction can never be modified.
Deletions:
The dynamic memory allocation process provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpNewOverload|New Overload]]##.


Revision [22420]

Edited on 2018-08-29 08:16:49 by fxm [Page updated while 'Operator New Overload' page creation]
Deletions:
==={{color text="Update in progress (@fxm)." c="red"}}===


Revision [22412]

Edited on 2018-08-29 07:28:59 by fxm [Update in progress]
Additions:
The dynamic memory allocation process provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpNewOverload|New Overload]]##.
Deletions:
The dynamic memory allocation process provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member ##[[KeyPgOpNewOverload|New Overload]]## operator.


Revision [22389]

Edited on 2018-08-29 03:37:31 by fxm [Update in progress]
Additions:
##**New[] Expression**## operator is the array-version of the ##**New Expression**## operator and allocates enough memory for the specified number of objects. The default constructor for the type will be used to set the initial values for each item.
Objects created with ##**New Expression**## operator must be freed with ##[[KeyPgOpDelete|Delete Statement]]## operator. Object array created with ##**New[] Expression**## operator must be freed with ##**Delete[] Statement**## operator, the array-version of ##[[KeyPgOpDelete|Delete Statement]]## operator. You cannot mix and match the different versions of the operators.
The dynamic memory allocation process provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member ##[[KeyPgOpNewOverload|New Overload]]## operator.
- ##[[KeyPgOpDelete|Delete Statement]]##
- ##[[KeyPgOpNewOverload|New Overload]]##
Deletions:
##**New[]**## is the array-version of the ##**New**## operator and allocates enough memory for the specified number of objects. The default constructor for the type will be used to set the initial values for each item.
Objects created with ##**New**## must be freed with ##[[KeyPgOpDelete|Delete]]##. Memory allocated with ##**New[]**## must be freed with ##**Delete[]**##, the array-version of ##[[KeyPgOpDelete|Delete]]##. You cannot mix and match the different versions of the operators.
This operator can be overloaded for user-defined types as a member ##[[KeyPgOperator|Operator]]##.
- ##[[KeyPgOpDelete|Delete]]##


Revision [22383]

Edited on 2018-08-29 01:03:38 by fxm [Update in progress]
Additions:
==={{color text="Update in progress (@fxm)." c="red"}}===
Deletions:
==={{color text="Update in progress (@fxm)" c="red"}}===


Revision [22382]

Edited on 2018-08-29 01:02:19 by fxm [Update in progress]
Additions:
The ##**New Expression**## operator dynamically allocates memory and constructs a specified data type.
Deletions:
{{fbdoc item="syntax"}}##
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **new** ( //size// [[KeyPgAs|as]] [[KeyPgUinteger|uinteger]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **new[]** ( //size// [[KeyPgAs|as]] [[KeyPgUinteger|uinteger]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
##//size//##
Number of bytes to allocate.
The ##**New**## operator dynamically allocates memory and constructs a specified data type.


Revision [22379]

Edited on 2018-08-29 00:23:18 by fxm [Update in progress]
Additions:
==={{color text="Update in progress (@fxm)" c="red"}}===
Deletions:
==={{color text="Update in progress (@fxm)." c="red"}}===


Revision [22378]

Edited on 2018-08-29 00:21:30 by fxm [Update in progress]
Additions:
{{fbdoc item="title" value="Operator New Expression"}}----
Deletions:
{{fbdoc item="title" value="Operator New"}}----


Revision [22376]

Edited on 2018-08-29 00:19:04 by fxm [Update in progress]
Additions:
==={{color text="Update in progress (@fxm)." c="red"}}===


Revision [22370]

Edited on 2018-08-25 07:59:43 by fxm [Added note highlighting the risk to use NEW[] ... DELETE[] in some cases]
Additions:
**Note:** Using ##//pointer// = **New** //datatype//[//count//]## may be unsafe if ##//pointer//## was declared with a type different from ##//datatype//## (for sub-type polymorphism purpose for example), because the pointer arithmetic fails to access the elements if the pointer type size is different from the size of ##//datatype//## (when using ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|Operator [] (Pointer index)"}}## or adding an offset (element number) to the pointer, or even when ##**Delete[]**## itself (the array-version of ##[[KeyPgOpDelete|Delete]]##) must destroy the elements).
Deletions:
**Note:** Using ##//pointer// = **New** //datatype//[//count//]## may be unsafe if ##//pointer//## was declared with a type different from ##//datatype//## because the pointer arithmetic fails to access the elements if the pointer type size is different from the size of ##//datatype//## (when using ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|Operator [] (Pointer index)"}}## or adding an offset (element number) to the pointer, or even when ##**Delete[]**## itself (the array-version of ##[[KeyPgOpDelete|Delete]]##) must destroy the elements).


Revision [22366]

Edited on 2018-08-25 04:25:16 by fxm [Added note highlighting the risk to use NEW[] ... DELETE[] in some cases]
Additions:
**Note:** Using ##//pointer// = **New** //datatype//[//count//]## may be unsafe if ##//pointer//## was declared with a type different from ##//datatype//## because the pointer arithmetic fails to access the elements if the pointer type size is different from the size of ##//datatype//## (when using ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|Operator [] (Pointer index)"}}## or adding an offset (element number) to the pointer, or even when ##**Delete[]**## itself (the array-version of ##[[KeyPgOpDelete|Delete]]##) must destroy the elements).


Revision [22322]

Edited on 2018-05-28 05:54:51 by fxm [Wording]
Additions:
For simple types, like integers, an initial value can be given. For types without constructors, initial values can be specified for each field (either with default initializer at data-field declaration, or with initializer list as in ##**New** //datatype// (**initializers, ..**)## if all type data-fields are numeric primitives only and without any default initializers). For types with at least one constructor, the initialize list (if any) must match an existing constructor. If no initializers are given, the default values for those types will be set.
Deletions:
For simple types, like integers, an initial value can be given. For types without constructors, initial values can be specified for each field (either with default initializer at data-field declaration, or with initializer list as in ##**New** //datatype// (**initializers, ..**)## if all type data-fields are numeric primitives only and without any default initializers). Types that have constructors can have their constructors called by ##**New**## as well. If no initializers are given, the default values for those types will be set.


Revision [21442]

Edited on 2016-04-30 11:09:46 by fxm [Reworded in description]
Additions:
The ##**New**## operator dynamically allocates memory and constructs a specified data type.
For simple types, like integers, an initial value can be given. For types without constructors, initial values can be specified for each field (either with default initializer at data-field declaration, or with initializer list as in ##**New** //datatype// (**initializers, ..**)## if all type data-fields are numeric primitives only and without any default initializers). Types that have constructors can have their constructors called by ##**New**## as well. If no initializers are given, the default values for those types will be set.
Deletions:
The ##**New**## operator dynamically allocates memory and constructs a specified data type. For simple types, like integers, an initial value can be given. For types without constructors, initial values can be specified for each field (either with default initializer at data-field declaration, or with initializer list as in ##**New** //datatype// (**initializers, ..**)## if all type data-fields are numeric primitives only and without any default initializers). Types that have constructors can have their constructors called by ##**New**## as well. If no initializers are given, the default values for those types will be set.


Revision [21440]

Edited on 2016-04-30 11:05:45 by fxm [Reworded in description]
Additions:
The ##**New**## operator dynamically allocates memory and constructs a specified data type. For simple types, like integers, an initial value can be given. For types without constructors, initial values can be specified for each field (either with default initializer at data-field declaration, or with initializer list as in ##**New** //datatype// (**initializers, ..**)## if all type data-fields are numeric primitives only and without any default initializers). Types that have constructors can have their constructors called by ##**New**## as well. If no initializers are given, the default values for those types will be set.
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New** //datatype// (**Any**)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New** //datatype//[//count//] {**Any**}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(count * Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
Deletions:
The ##**New**## operator dynamically allocates memory and constructs a specified data type. For simple types, like integers, an initial value can be given. For types without constructors, initial values can be specified for each field. Types that have constructors can have their constructors called by ##**New**## as well. If no initializers are given, the default values for those types will be set.
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New** //datatype//(**Any**)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New** //datatype//[//count//]{**Any**}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(count * Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).


Revision [21346]

Edited on 2016-04-15 03:30:32 by fxm [Added reference to KeyPgOperator when overloaded as member operator]
Additions:
This operator can be overloaded for user-defined types as a member ##[[KeyPgOperator|Operator]]##.


Revision [21047]

Edited on 2016-03-13 07:12:27 by fxm [Formatting]
Additions:





Revision [20397]

Edited on 2016-02-10 16:05:06 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **new** ( //size// [[KeyPgAs|as]] [[KeyPgUinteger|uinteger]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **new[]** ( //size// [[KeyPgAs|as]] [[KeyPgUinteger|uinteger]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
//result// = **New** //[[DataType|datatype]]//
//result// = **New** //[[DataType|datatype]]// ( //initializers//, ... )
//result// = **New** //[[DataType|datatype]]//**[** //count// **]**
A pointer of type [[DataType|datatype]] to the newly allocated data.
Objects created with ##**New**## must be freed with ##[[KeyPgOpDelete|Delete]]##. Memory allocated with ##**New[]**## must be freed with ##**Delete[]**##, the array-version of ##[[KeyPgOpDelete|Delete]]##. You cannot mix and match the different versions of the operators.
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New** //datatype//(**Any**)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New** //datatype//[//count//]{**Any**}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(count * Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
- Only available in the //[[CompilerOptlang|-lang fb]]// dialect.
- ##[[KeyPgOpDelete|Delete]]##
- ##[[KeyPgOpPlacementNew|Placement New]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new[]** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
//result// = **New** //[[DataType datatype]]//
//result// = **New** //[[DataType datatype]]// ( //initializers//, ... )
//result// = **New** //[[DataType datatype]]//**[** //count// **]**
A pointer of type [[DataType datatype]] to the newly allocated data.
Objects created with ##**New**## must be freed with ##[[KeyPgOpDelete Delete]]##. Memory allocated with ##**New[]**## must be freed with ##**Delete[]**##, the array-version of ##[[KeyPgOpDelete Delete]]##. You cannot mix and match the different versions of the operators.
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##**New** //datatype//(**Any**)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##**New** //datatype//[//count//]{**Any**}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(count * Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
- Only available in the //[[CompilerOptlang -lang fb]]// dialect.
- ##[[KeyPgOpDelete Delete]]##
- ##[[KeyPgOpPlacementNew Placement New]]##


Revision [17101]

Edited on 2014-06-22 05:28:40 by FxMwikki [Go back before the previous changes]
Additions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new[]** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new[]** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]]


Revision [17096]

Edited on 2014-06-21 13:31:40 by FxMwikki [The 'New' operator returns a typed pointer]
Additions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new[]** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[DataType datatype]] [[KeyPgPtr ptr]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **new[]** ( //size// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]


Revision [17057]

Edited on 2014-04-27 07:41:06 by FxMwikki [NEW/DELETE and NEW[]/DELETE[] can now be used with the dynamic STRING data type]
Deletions:
The ##**New**## and ##**New[]**## operators cannot be directly used with ##[[KeyPgString String]]##, but work with ##[[KeyPgType UDT]]##s containing strings.


Revision [16989]

Edited on 2014-01-10 03:56:17 by FxMwikki [Added substitutive syntax for "New...Any" invalid when types with constructors]
Additions:
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##**New** //datatype//(**Any**)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##**New** //datatype//[//count//]{**Any**}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(count * Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
Deletions:
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##new //datatype//(any)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors.
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##new //datatype//[//count//]{any}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors.


Revision [16371]

Edited on 2012-10-13 20:36:37 by CountingPine [Minor sentence change]
Additions:
The ##**New**## and ##**New[]**## operators cannot be directly used with ##[[KeyPgString String]]##, but work with ##[[KeyPgType UDT]]##s containing strings.
Deletions:
The ##**New**## or ##**New[]**## operator cannot be directly used with ##[[KeyPgString String]]##, but works with ##[[KeyPgType UDT]]## containing string.


Revision [16359]

Edited on 2012-10-05 14:17:39 by CountingPine [Formatting]
Additions:
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##new //datatype//(any)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors.
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##new //datatype//[//count//]{any}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors.
Deletions:
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##new datatype(any)## will allocate memory for the type, but not initialize the data. This is only valid on data types that do not have constructors.
Specifying an initial value of ##[[KeyPgAny Any]]##, as in ##new datatype[count]{any}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors.


Revision [15573]

Edited on 2011-12-19 17:51:30 by AgAmemnus [Formatting]
Additions:
Operator to dynamically allocate memory and construct data of a specified type.
' Create and initialize a "rational" and store its address.
' Allocate memory for 100 integers and store the address of the first one.
Deletions:
Operator to dynamically allocate memory and construct data of a specified type
' Create and initialize a Rational, and store it's address.
' Allocate memory for 100 integers, store the address of the first one.


Revision [15183]

Edited on 2011-08-17 05:32:31 by FxMwikki [Formatting]
Additions:
The ##**New**## or ##**New[]**## operator cannot be directly used with ##[[KeyPgString String]]##, but works with ##[[KeyPgType UDT]]## containing string.
Deletions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##, but can be used with ##[[KeyPgType UDT]]## containing string.


Revision [15181]

Edited on 2011-08-17 03:34:31 by FxMwikki [Formatting]
Additions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##, but can be used with ##[[KeyPgType UDT]]## containing string.
Deletions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##, but can be used with ##[[KeyPgType UDT]]## containing ##[[KeyPgString String]]##.


Revision [15179]

Edited on 2011-08-17 01:58:53 by FxMwikki [Formatting]
Additions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##, but can be used with ##[[KeyPgType UDT]]## containing ##[[KeyPgString String]]##.
Deletions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##, but can be used with UDT containing ##[[KeyPgString String]]##.


Revision [15177]

Edited on 2011-08-17 01:48:42 by FxMwikki [Formatting]
Additions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##, but can be used with UDT containing ##[[KeyPgString String]]##.
Deletions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##.


Revision [15175]

Edited on 2011-08-11 11:58:07 by FxMwikki [Formatting]
Additions:
The ##**New**## or ##**New[]**## operator cannot be used with ##[[KeyPgString String]]##.


Revision [14394]

Edited on 2009-08-29 21:55:35 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [13702]

Edited on 2008-09-07 09:18:19 by EcLipzer [Remove CamelCase links in "New to FreeBASIC"]
Additions:
Number of bytes to allocate.
Name of the data type to create.
Exact number of elements to allocate.
Deletions:
number of bytes to allocate.
name of the data type to create.
Number of elements to allocate.


Revision [12666]

The oldest known version of this page was created on 2008-03-02 11:07:22 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode