[Gambas-devel] New syntax for Read and Write
Benoît Minisini
gambas at ...1...
Sun Sep 20 20:05:01 CEST 2009
Hi,
In commit #2345, I finally decided to change the syntax of the Read and Write
instruction.
Before was:
1) Read a specific datatype inside a variable:
Read [ #Stream , ] Variable
2) Read <Length> bytes inside a string variable:
Read [ #Stream , ] StringVariable , Length
3) Write a value:
Write [ #Stream , ] Expression
4) Write <Length> bytes from a string value:
Write [ #Stream , ] StringExpression , Length
Now, the syntax is:
1) Read a specific datatype inside a variable:
Variable = Read [ #Stream ] As Datatype
2) Read <Length> bytes inside a string variable:
StringVariable = Read [ #Stream , ] Length
3) Write a value:
Write [ #Stream , ] Expression As Datatype
If Datatype is not specified, the datatype of the expression is used.
4) Write <Length> bytes from a string value:
Write [ #Stream , ] StringExpression [ , Length ]
If Length is ommitted, the length of the string expression is used.
Moreover, the Read instruction can be used inside an expression. Consequently,
you can write such things now:
Return Read As Byte
**** !!!! BEWARE !!!! *****
Write XXXX was writing the binary form of XXXX before. Now it writes XXXX as a
string. So you HAVE TO check all your WRITE instructions.
By default, the compiler supports the old Read syntax, and the old Write
syntax as it is compatible.
If you want to detect where you should rewrite your Read syntax, you can
compile your project by hand with the "--no-old-read-write-syntax" flag. Then
the Length argument of Write becomes mandatory if the syntax 4) is used.
Sorry for the inconvenience of having to rewrite things, but I find the new
syntax better.
Regards,
--
Benoît Minisini
More information about the Devel
mailing list