PDA

View Full Version : ArrayRead question



Charles Linquis
- 20th August 2011, 19:31
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



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?

mister_e
- 21st August 2011, 00:30
From the .LIB


;************************************************* ***************
;* 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. *
;************************************************* ***************
\

Charles Linquis
- 21st August 2011, 03:20
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!

readitaloud
- 21st August 2011, 04:42
Can someone inform me of the full name of the .LIB file being referred to.

- Martin

Charles Linquis
- 21st August 2011, 04:49
pbppic18.lib
pbppi18L.lib

Modify at your own risk.

mister_e
- 21st August 2011, 09:13
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 ;)

amgen
- 21st August 2011, 13:25
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

Charles Linquis
- 21st August 2011, 16:25
I can probably issue CHK?RP and see where the first element is, then subtract that.

Charles Linquis
- 21st August 2011, 16:57
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 Linquis
- 24th August 2011, 14:12
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.



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"

amgen
- 24th August 2011, 17:28
HI,
doesn't your R5 have something like ,27 or 28 or 29 plus mem location in ram ?
don

Charles Linquis
- 24th August 2011, 17:32
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.

mister_e
- 24th August 2011, 18:32
It isn't beautiful when we have access to the library code huh? ;)

Good job Charles