Shop OBEX P1 Docs P2 Docs Learn Events
Explain WDATA and READINC statements ? — Parallax Forums

Explain WDATA and READINC statements ?

T&E EngineerT&E Engineer Posts: 1,396
edited 2007-03-15 12:42 in General Discussion
Can someone better explain WDATA statements and how they are used. I understand that they have to be incremented by 2 but need info why this is so (2 bytes?). I am using an SX52 and using·(2) 16 bit port RBC and RDE as PIN outputs.

Also I can't find any information on READINC statements. Is this a valid statement and how does it differ from a READ statement?

Comments

  • BeanBean Posts: 8,129
    edited 2007-03-15 12:25
    Yep you are correct, WDATA elements are 2 bytes long.

    WDATA is used to create data elements that are WORDs, each word element takes two bytes. The regular DATA statement will automatically create WORD elements only if the value is > 255. This causes problems when some of the values are < 256. WDATA will always use 2 bytes even if the value is < 256.

    READINC works like READ but will automatically increaments the pointer variable so you can read the next element in the data table.

    cnt = 0
    READINC myData + cnt, wordvar
    ' Now cnt is 2

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A problem well defined is a problem half solved"

    "Just because you're approved, doesn't mean you can afford it."
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Cheap used 4-digit LED display with driver IC·www.hc4led.com
    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-03-15 12:38
    Bean,

    I just found a·brief sentence on the READINC in the WhatsnewAll doc under in the Beta testers section. I also saw that Jon Williams used it in the March Issue of N&V for·his CGoL program.

    What's New In SX/B 1.51.01
    New Command:

    · READINC
    ··· Exactly the same syntax as READ, but also automatically increments the offset variable to point to the next item in the DATA list.

    This information needs to be in a help file with "example" code. I understand this is in the works but it would·be nice to have this available in the HELP file everytime·SX code is officially released.

    I will be patient and do appreciate your very knowledgable help and others like JonnyMac.

    Thanks again!
  • BeanBean Posts: 8,129
    edited 2007-03-15 12:42
    I agree the help file needs updating, but it will probably wait until the next version is released.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A problem well defined is a problem half solved"

    "Just because you're approved, doesn't mean you can afford it."
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Cheap used 4-digit LED display with driver IC·www.hc4led.com
    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
Sign In or Register to comment.