11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler5.56. READSyntax :Overview :Operators :Example :READ VariableREAD the next value from a DATA table and place into variableVariable is a user defined variableDIM IDATA 5 , 8 , ”fred” , 12RESTOREREAD I‘ I will now contain the value 5READ I‘ I will now contain the value 8RESTORE 3‘ Pointer now placed at location 4 in our data table i.e. “r”READ I‘ I will now contain the value 114 i.e. the ‘r’ character in decimalThe data table is defined with the values 5,8,102,114,101,100,12 as“fred” equates to f:102,r:114,e:101,d:100 in decimal. The table pointeris immediately restored to the beginning of the table. This is not alwaysrequired but as a general rule, it is a good idea to prevent tablereading from overflowing.The first READ I takes the first item of data from the table and incrementsthe table pointer. The next READ I therefore takes the seconditem of data.RESTORE 3 moves the table pointer to the fourth location in the table,in this case where the letter ‘r’ is. READ I now retrieves the decimalequivalent of ‘r’ which is 114.Notes :If a WORD size variable is used in the READ command, then a 16-bitvalue is read from the data table. Consequently, if a BYTE size variableis used, then 8-bits are read. BIT sized variables also read 8-bitsfrom the table, but any value greater than 0 is treated as a 1.Attempts to read past the end of the table will result in errors and undeterminedresults.See also :CDATA, CREAD, CWRITE, DATA, LOOKUP, RESTORE108Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!