[Gambas-user] Release of gambas2 1.9.11
Benoit Minisini
gambas at ...1...
Wed Jul 6 19:24:19 CEST 2005
Hi,
Here is a big important release of the development version.
Many new syntaxes and features were added to the compiler and the interpreter,
the bytecode has changes, and so ALL PROJECTS MUST BE *ENTIRELY* RECOMPILED!
I apologize for the inconvenience, but I think it's worth it :-)
Here are the changes, with some explanations when needed:
* You can instanciate objects at variable declaration with any expression now.
Now you can type things like:
DIM Matrix AS NEW Float[3, 3]
PUBLIC MyObject AS NEW MyObject(GetParam(), Len(TheName))
...
* Functions can take a variable number of arguments now.
Just use three points at the end of the argument list:
SUB MyPrintf(sFormat AS String, ...)
...
END
Use the Param class to access additional arguments (see below).
* You can use the '_unknown' special method now.
Declare it this way:
PUBLIC FUNCTION _unknown(...) AS Variant
...
END
Use the Param class to get the name of the called method.
*A new syntax 'IF ... AND IF ...'. The second test is not done if the first is
false.
You can type now:
IF Test1 AND IF Test2 THEN ...
The Test2 is never evaluated if Test1 is FALSE, contrary to 'IF Test1 AND
Test2'
You can use more than two AND IF of course.
* A new syntax 'IF ... OR IF ...'. The second test is not done if the first is
true.
The same syntax than previously, but with OR.
* A new syntax 'CASE ... TO ...', to test the match to an interval of values.
You can type now:
SELECT Value
CASE 1 TO 10
PRINT "1 TO 10"
CASE 11 TO 20, 25
PRINT "11 TO 20 or 25"
END SELECT
* New C-style assignment operators: +=, -=, *=, /=, \=, &=, &/=.
Now you can type:
i += 1 instead of i = i + 1
And so on...
* The DIRECT keyword has been removed. Now use 'OPEN ... FOR INPUT | OUTPUT'
to open a file in buffered mode and 'OPEN ... FOR READ | WRITE' to open a
file in direct mode.
* The BIG and LITTLE keywords have been removed. Now use the new ByteOrder
property of the Strem class.
* A new syntax for EXEC or SHELL: 'EXEC|SHELL ... TO aString' executes the
command, waits for its termination, and returns the process output to the
specified string. The syntax defined in 1.9.10 has been removed.
* WAIT is not implicite anymore in the EXEC or SHELL command.
* Now ambiguous expressions are detected, and raise an error.
* A new operator '==', to compare strings by ignoring their case.
Interpreter
PRINT "Gambas" == "gambas" returns TRUE
* System.Home was definitely replaced by User.Home.
* System.User was definitely replaced by User.Name.
* The class ".Stream" has been renamed as "Stream".
Be careful component developers! :-)
* A new class, Param, to get extra arguments, and information about a call to
the _unknown method.
Param.Count returns the number of extra arguments.
Param[i] returns the i-th argument as a variant.
Param.Unknown returns the name of the unknown method.
* A new property, Stream.ByteOrder, to set the byte order of a stream.
Now, instead of using BIG or LITTLE with OPEN, you must write:
hStream.ByteOrder = gb.LittleEndian / gb.BigEndian.
Note that you can do that for any type of stream!
* A new property, User.Id, returns the user id of the current process.
* Application.Args is now enumerable.
Now you can type:
FOR EACH sArg in Application.Args
...
NEXT
* Formatting currency is possible now, by specifying gb.Currency (or
gb.International to use the international currency symbol) as second argument
of Format$().
In France:
PRINT Format$(10000.50, gb.Currency)
10 000,50 €
PRINT Format$(10000.50, gb.International)
10 000,50 FRF
In US: (tell me if I am wrong)
PRINT Format$(10000.50, gb.Currency)
$ 10,000.50
PRINT Format$(10000.50, gb.International)
USD 10,000.50
* New mathematical functions: Exp2, Exp10, Log2, Cbr, Expm, Logm, Atan2, Ang,
Hyp, Mag.
Exp2(x) = 2 ^ x
Exp10(x) = 10 ^ x
Log2(x) = Log(x) / Log(2)
Cbr(x) = x ^ (1/3)
Expm(x) = Exp(x) - 1 with good precision when x -> 1
Logp(x) = Log(x + 1) with good precision when x -> 0
Atan2(x, y) = Atan(y / x)
Ang(x, y) = Atan(x / y)
Hyp(x, y) = Sqr(x^2 + y^2)
Mag(x, y) = Hyp(x, y)
* New conversion functions: DConv$(), for converting from system charset to
desktop charset, and SConv$() for doing the contrary.
* New date functions: DateAdd() and DateDiff(). They were backported from the
vb component and the syntax was modified.
DateAdd(Date AS Date, Period AS Integer, Interval AS Integer)
adds to Date a specified number (Interval) of Period.
Period can be:
- gb.Second
- gb.Minute
- gb.Hour
- gb.Day
- gb.WeekDay
- gb.Week
- gb.Month
- gb.Quarter
- gb.Year
DateDiff(Date1 AS Date, Date2 AS Date, Period AS Integer)
returns the number of Period that leads from Date1 to Date2, Date2 being
excluded.
* A new function, RDir(), to read the contents of a directory recursively.
It has the same syntax than Dir(). Try it!
* A new storage class, List.
Here is a little chart for comparing Array, List and Collection.
Array Collection List
Indexed by integer string integer
Inserting can be slow (1) slow immediate
Deleting can be slow (1) slow immediate
Accessing immediate fast can be slow (2)
(1) The array is shrinked or expanded as needed, every 16 insertion or
deletion.
(2) The list of elements must be traversed. Accessing the next or previous
element is immediate.
* Adding or substracting little integers is now optimized: about 5 times
faster.
* Calling functions with a fixed number of arguments, without needing to
convert the arguments is optimized: about 4 times faster.
* A new drawing method in the QT component, Draw.Zoom, for drawing a zoomed
version of an Image.
* A new video capture component named 'gb.v4l' made by Daniel Campos. It is
based on Video4Linux.
* The CGI Gambas program that manages the new documentation is distributed
with the source so that people can translate it.
That's all :-) Please read the changelog for a list of bug fixes and other
changes.
ENJOY IT!
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list