The documentation of the new version is not ready yet, so I will use this thread to explain the new features.
- Regular variables can be declared with a specific data type.
Unlike previous versions where regular variables (not arrays / structures) were always stored with the default data type (string), and converted to number as required, it is now possible to declare regular variables with the Dim keyword and specify their data type. Both local and global variables.
The two main data types are String which is the default and Number. Number is a syntactic sugar and actually maps to .Net double.
Using Number variables in numeric calculations is much (10x) more efficient than using untyped variables or strings.
Note that you will only see the performance improvement in the compiled application.
Usage example:
You can also use the other data types that are already available for Arrays (and Number can be used with Arrays as well).
Another new data type name is Integer which maps to Int32. Note that currently Number (or double) will yield the best performance.
- Subs declaration - It is also possible to declare the type of subs parameters and return type.
- Passing variables by reference - Variables can be passed by reference which can used to return more than one result from a sub.
So the Sub declaration syntax is:
ByVal which stands for passing a variable by value is the default behavior.
See this link for more information about passing by value vs passing by reference: Evaluation strategy - Wikipedia, the free encyclopedia
Note that it is still not possible to pass or return arrays and structures.
This feature was initially planned but it will not be ready for this version.
Correctly typing your variables can significantly boost the performance of numeric calculations.
- Better support for dynamic controls and objects.
A new set of keywords for handling dynamic controls and objects is now available.
The new set of keywords can be used as a replacement for the Control keyword.
You can now write the control (or object) type followed by the specific control name as string and then the property or method.
Easier to explain with an example:
The main advantage of the new syntax is that it is recognized by the IDE. Therefore when you type '.' you will get the list of properties and methods available for a Form (or any other control).
The same thing is true for objects:
Note that the old syntax is still supported.
- Scroll bar indicators - This feature is an improvement in the desktop IDE that is more useful than it may seem at first look.
In previous versions when you selected a word in the IDE (like a variable name), all occurrences of this word were highlighted in the editor. The new feature is that now in addition to the highlighting the vertical scroll bar will be marked with small indicators that indicate the positions which you should scroll to in order to find all the occurrences.
This can be very handy if you want to immediately see where in the code some variable or control is used.
The scroll bar indicators will also show for breakpoints, current debugging line and bookmarks.
- Other improvements include more accurate error messages and bug fixes.
The final version will include some additional minor improvements and bug fixes.
- Backwards compatibility issues
* Up until now it was possible for an array to change its type in runtime. This feature was problematic and was not always handled correctly by the optimized compiler. Arrays can no longer change their types.
It is still possible to redeclare an array and change its size.
* The legacy compiler will not be available in the next version. The optimized compiler is significantly better than the legacy compiler and almost all devices available are supported by .Net CF 2.0.
Removing support for the legacy compiled makes it much more simpler to maintain and improve several core components of Basic4ppc (like the variables handling for example).
- Regular variables can be declared with a specific data type.
Unlike previous versions where regular variables (not arrays / structures) were always stored with the default data type (string), and converted to number as required, it is now possible to declare regular variables with the Dim keyword and specify their data type. Both local and global variables.
The two main data types are String which is the default and Number. Number is a syntactic sugar and actually maps to .Net double.
Using Number variables in numeric calculations is much (10x) more efficient than using untyped variables or strings.
Note that you will only see the performance improvement in the compiled application.
Usage example:
B4X:
Sub SomeSub
Dim x As Number
x = 234
msgbox (x * 2)
End Sub
Another new data type name is Integer which maps to Int32. Note that currently Number (or double) will yield the best performance.
- Subs declaration - It is also possible to declare the type of subs parameters and return type.
- Passing variables by reference - Variables can be passed by reference which can used to return more than one result from a sub.
So the Sub declaration syntax is:
B4X:
[Public | Private] Sub SubName [([ByVal | ByRef] parameter [As Datatype], ...)][As DataType]
See this link for more information about passing by value vs passing by reference: Evaluation strategy - Wikipedia, the free encyclopedia
Note that it is still not possible to pass or return arrays and structures.
This feature was initially planned but it will not be ready for this version.
Correctly typing your variables can significantly boost the performance of numeric calculations.
- Better support for dynamic controls and objects.
A new set of keywords for handling dynamic controls and objects is now available.
The new set of keywords can be used as a replacement for the Control keyword.
You can now write the control (or object) type followed by the specific control name as string and then the property or method.
Easier to explain with an example:
B4X:
i = 1
Control ("Form" & i, Form).Circle(...) 'old syntax
Form ("Form"& i).Circle (...) 'new syntax
The same thing is true for objects:
B4X:
Control ("MyBList", bList).AddFromString(...) 'old syntax
bList ("MyBList").AddFromString(...) 'new syntax
- Scroll bar indicators - This feature is an improvement in the desktop IDE that is more useful than it may seem at first look.
In previous versions when you selected a word in the IDE (like a variable name), all occurrences of this word were highlighted in the editor. The new feature is that now in addition to the highlighting the vertical scroll bar will be marked with small indicators that indicate the positions which you should scroll to in order to find all the occurrences.
This can be very handy if you want to immediately see where in the code some variable or control is used.
The scroll bar indicators will also show for breakpoints, current debugging line and bookmarks.
- Other improvements include more accurate error messages and bug fixes.
The final version will include some additional minor improvements and bug fixes.
- Backwards compatibility issues
* Up until now it was possible for an array to change its type in runtime. This feature was problematic and was not always handled correctly by the optimized compiler. Arrays can no longer change their types.
It is still possible to redeclare an array and change its size.
* The legacy compiler will not be available in the next version. The optimized compiler is significantly better than the legacy compiler and almost all devices available are supported by .Net CF 2.0.
Removing support for the legacy compiled makes it much more simpler to maintain and improve several core components of Basic4ppc (like the variables handling for example).