ArrayRead question


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default ArrayRead question

    I have a huge number of commands to parse, so I'm trying to get through my list as quickly as possible.

    In the line of code below


    Code:
     Parse01: Cmd=01 : ARRAYREAD Data_Array,32,Parse02,[WAIT("Status1?")]

    If Data_Array is dimensioned to be 100 bytes, will the parser always sort through the MAXLENGTH (32) number of elements, or will it stop at the first NUL?

    Also, is there any PBP variable (Rx, for example), that I can read immediately (like in the next line) to determine how many characters were read before the "Status1?" was matched?
    Charles Linquist

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    From the .LIB
    Code:
    ;****************************************************************
    ;* ARRAYREAD  : Read char from array                            *
    ;*                                                              *
    ;* Input      : R5 = pointer to next char in array              *
    ;*            : R6 = number of chars left in array (timeout)    *
    ;* Output     : W                                               *
    ;*                                                              *
    ;* Notes      : C clear if timed out.                           *
    ;****************************************************************
    \
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    Yes, I looked at that a long time ago, but forgot. I guess I could answer my own questions if I just did a little research!

    I guess that I'm going to have to start modifying the library again. I'll copy R5 to my own var so it doesn't get trashed.

    Thanks!
    Charles Linquist

  4. #4
    Join Date
    Jul 2011
    Location
    Hawaii
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    Can someone inform me of the full name of the .LIB file being referred to.

    - Martin

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    pbppic18.lib
    pbppi18L.lib

    Modify at your own risk.
    Charles Linquist

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    Yup, safe bet

    Seems some day, we may no longer need to do like such. Few days ago, Darrel told in another thread there's a kind of lib override on the ToDo list (or in testing). Sounds like a good idea
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    My initial testing with R5 (with arraywrite, but R5 is still pointer for that) is that it points to array ram location plus array position
    so to find position in array, you have to subtract the base value from R5. You can find that in LIST file or declare location for array:

    array1 var byte [100] $100 'start array1 at location $100, 256 dec in ram

    so you know base val to subtract ??

    don

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    I can probably issue CHK?RP and see where the first element is, then subtract that.
    Charles Linquist

  9. #9
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    Quote Originally Posted by mister_e View Post
    Yup, safe bet

    Seems some day, we may no longer need to do like such. Few days ago, Darrel told in another thread there's a kind of lib override on the ToDo list (or in testing). Sounds like a good idea

    Darrel, forget what I said a couple of weeks ago. You need to get back to work! We need to easily be able add functionality like I'm talking about and to add our own keywords (I see some advances there already), and to be able to create something that is a semblance of real functions- something that would translate vars by position going into, and out of, a routine.
    Charles Linquist

  10. #10
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    Using R5 does appear to work.

    If I have a bunch of different strings that I need to parse, and a variable exists
    right after the string - such as:

    "power -state -T system:blade[X]"

    Where "X" is a variable, the following always returns the right value.
    Code:
     
    CMD1:Command=1:ARRAYREAD  bigarray,30,CMD2,[WAIT ("power -on -T system:blade[")]:Goto GetNumber
     
     
    CMD2:Command=2:ARRAYREAD  bigarray,30,CMD3,[WAIT ("power -off -T system:blade[")]:goto GetNumber
     
     
    CMD3:Command=3:ARRAYREAD  bigarray,30,CMD4,[WAIT ("power -state -T 
    system:blade[")]:goto GetNumber
     
     
    CMD4:Command=4:ARRAYREAD  bigarray,30,ZeroOutAndRestart,[WAIT ("console -T 
    system:blade[")]:Goto GetNumber
     
     
     
     
     
    ...
     
     
    GetNumber:
     
     
    Peek R5,BladeNumber
    "BladeNumber" contains the value of "X"
    Charles Linquist

  11. #11


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    HI,
    doesn't your R5 have something like ,27 or 28 or 29 plus mem location in ram ?
    don

  12. #12
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    R5 has the RAM location of the NEXT item after the match. Which is the one I'm looking for. I don't care about the absolute address.
    Charles Linquist

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: ArrayRead question

    It isn't beautiful when we have access to the library code huh?

    Good job Charles
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 1

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