Announcement

Collapse
No announcement yet.

ARRAYWRITE and ARRAYREAD Issues

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ARRAYWRITE and ARRAYREAD Issues

    I would like to know if this code is possible:

    OUTARRAY VAR BYTE(80) 'serial string output array
    BYTEIN VAR BYTE
    character VAR BYTE

    ARRAYWRITE OUTARRAY,["NEW_K22_APA102C.bas(07/20/2018)",10,13,0]
    BYTEIN = 0
    WHILE OUTARRAY(BYTEIN)
    LOOKUP BYTEIN,[OUTARRAY],CHARACTER
    ' TX_BYTES2(TX_OUTPUT2) = CHARACTER 'This should be the printed character
    BYTEIN = BYTEIN + 1
    ' GOSUB SNDCHAR2 'INCREMENT BUFFER POINTERS 'this routine is called for printing the character
    WEND


    I get the error: Expected '['

    If I use lookup2 I dont get the errors but garbage data:

    OUTARRAY VAR BYTE(80) 'serial string output array
    BYTEIN VAR BYTE
    character VAR BYTE

    ARRAYWRITE OUTARRAY,["NEW_K22_APA102C.bas(07/20/2018)",10,13,0]

    BYTEIN = 0
    WHILE OUTARRAY(BYTEIN)
    LOOKUP2 BYTEIN,[OUTARRAY],CHARACTER
    ' TX_BYTES2(TX_OUTPUT2) = CHARACTER 'This should be the printed character
    BYTEIN = BYTEIN + 1
    ' GOSUB SNDCHAR2 'INCREMENT BUFFER POINTERS 'this routine is called for printing the character
    WEND

    This code is being run on an 18F26K22 @ 64 Mhz.



    Dave Purola,
    N8NTA
    EN82fn

  • #2
    Perhaps like so:

    Code:
    OUTARRAY VAR BYTE(80) 'serial string output array
    BYTEIN VAR BYTE
    character VAR BYTE
    ARRAYWRITE OUTARRAY,["NEW_K22_APA102C.bas(07/20/2018)",10,13,0]
    FOR BYTEIN = 0 TO 79    ' limit scan to length of array
        character = OUTARRAY[BYTEIN]    ' get the next character
        IF character = 0 THEN EXIT      ' if end of string, exit without printing
        ' TX_BYTES2(TX_OUTPUT2) = CHARACTER 'This should be the printed character
        ' GOSUB SNDCHAR2 'INCREMENT BUFFER POINTERS 'this routine is called for printing the character
    NEXT BYTEIN
    Charles Leo
    ME Labs, Inc.
    http://melabs.com

    Comment


    • #3
      Charles, I got rid of the "lookup2" statement and now just passing the array value to the serial output variable and all is working now. Thanks for the advice. Here is the code:

      '*********************************************************************
      SERIALOUT2: 'OUTPUT SERIAL STRING TO PORT 2
      '*********************************************************************
      BYTEIN = 0
      WHILE OUTARRAY(BYTEIN)
      TX_BYTES2(TX_OUTPUT2) = OUTARRAY(BYTEIN)
      BYTEIN = BYTEIN + 1
      GOSUB SNDCHAR2 'INCREMENT BUFFER POINTERS
      WEND
      RETURN
      Dave Purola,
      N8NTA
      EN82fn

      Comment

      Working...
      X