Question about ARRAYWRITE


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    One interesting thing...

    It seems that ARRAYWRITE does not work with indexed variables.

    ARRAYWRITE MSG ["VALUE: ",DEC TMR[X]]

    I'm just copying the value of TMR[X] to another variable first for now. Is this a bug, or just not accounted for or ??? Great command nonetheless.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by circuitpro View Post
    It seems that ARRAYWRITE does not work with indexed variables.
    ARRAYWRITE MSG ["VALUE: ",DEC TMR[X]]
    The statement is missing a comma after MSG, but otherwise ... it should work.
    ARRAYWRITE MSG, ["VALUE: ",DEC TMR[X]]
    DT

  3. #3
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    Sorry, I was 'winging it' by memory from work. The comma was there, and still no go. I'll keep trying things as I'd really like to use this command.

  4. #4
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Unhappy

    I've been looking at this all day, and it just doesn't work:



    Code:
    'PIC18F6722
    OSC 40
    ARRAYSIZE  CON  20
    DJAM      CON     %01110111
    ACK       CON     $06 
    COMMAND   VAR     BYTE[20]
    MESSAGE   VAR     BYTE[20]
    
    LOOP1:
    ARRAYWRITE MESSAGE,[HEX ACK," ",BIN DJAM]
    ARRAYREAD MESSAGE, [COMMAND]
    DEBUG STR COMMAND,10,13                                                     
    ARRAYWRITE MESSAGE,[REP 0\ARRAYSIZE]
    PAUSE 1000
    GOTO LOOP1
    
    OUTPUT:
    61110111
    If I just say "HEX ACK" it produces 61110111 (no space as I specified). If I try to use "HEX2 ACK", it doesn't show the first value OR the space, just the binary number! I need to write some rather complicated structured messages and store them, but I've found that

    1) IN NO CASE will ARRAYWRITE write more than two items... (if there is more, they just don't show). The exact same structure prints fine using DEBUG.

    For example: ARRAYWRITE MESSAGE, ["DJ_TMR",DEC X,":",DEC DJ_TMR[X]] will only show the first two values... DJ_TMR, and DEC X - nothing further.

    2) ARRAYWRITE won't work with indexed variables.

    All efforts done in PBP 2.60A. If anyone can tell me what I'm doing wrong, I would be most grateful!

    L.
    Last edited by circuitpro; - 30th July 2010 at 04:56.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Try it like this.

    Code:
    'pic18f6722
    osc 40
    arraysize  con  20
    djam      con     %01110111
    ack       con     $06 
    command   var     byte[20]
    message   var     byte[20]
    
    loop1:
      Arraywrite message,[hex ack," ",bin djam,0]
      debug str message,10,13                                                     
      arraywrite message,[rep 0\arraysize]
      pause 1000
    goto loop1
    DT

  6. #6
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    ok, but what is that doing? Once the array is written, and presumably saved for some time, don't I have to use ARRAYREAD to read it back into a variable to then use it? You are showing me that the message is proper, but I'm not proving a READ. WHAT IS THAT 0 FOR???????
    Last edited by circuitpro; - 30th July 2010 at 05:23.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by circuitpro View Post
    ok, but what is that doing?
    It's writing string data to an Array, then sending it out using DEBUG.

    Once the array is written, and presumably saved for some time, don't I have to use ARRAYREAD to read it back into a variable to then use it?
    No, once it's in the array it's ready to send.
    You would only need to use ARRAYREAD if string data had been received.

    WHAT IS THAT 0 FOR???????
    The 0 terminates the string.
    When using DEC, HEX, BIN etc. The length of the string is not constant, and you have to mark the end so PBP can find it.
    The STR operator in the DEBUG statement will stop sending data from the array when it encounters a 0.
    DT

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts