New syntax for Read and Write

View: New views
1 Messages — Rating Filter:   Alert me  

New syntax for Read and Write

by Bugzilla from gambas@users.sourceforge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Gambas-devel mailing list
Gambas-devel@...
https://lists.sourceforge.net/lists/listinfo/gambas-devel