Page 1 of 1

READ Command problems

Posted: Fri Jul 27, 2018 1:40 pm
by blueb
I read about an issue that the READ command can return unexpected results if not used properly...

see: viewtopic.php?p=525159#p525159

Command: Read[.<type>] <variable>
.<type> should not be optional as the 'default' (.i) can lead to unexpected results.
skywalk wrote:This happens enough that the compiler should throw an error for naked Read's.

Code: Select all

Read.i  <-- Allowed
Read    <-- Error
I agree with Skywalk, even if PB just issued a warning, it would alert the programmer of unexpected results. Besides, with Data.TypeName statement, the Typename is required.

Re: READ Command problems

Posted: Fri Jul 27, 2018 3:02 pm
by #NULL
Is there a use case where the Read-type would be different than the variable type? Otherwise it could just be inferred.

Re: READ Command problems

Posted: Fri Jul 27, 2018 3:33 pm
by Fred
I agree it would be safer to always specify the Read type, like for Data. You can read double data into long variable without any issue for example.