Terminating eeprom read early

russbow

Senior Member
At this point, just proof of concept.

I need to read strings of numbers from EEPROM

I know where in the eeprom the string starts but will not know how long the string is.

I wondered if terminating each string with a dummy character, say @, I could use this to jump out of the read routine. Suggested coding being

Code:
symbol index=b10

for b0=index to 255

	read b0,b1
	
	if b1="@" then let b0=255
	goto jump
	endif
	
	serout b.4,N2400,(b1)
        pause 50
	
	jump:
	next b0
Will this jump out of the for/next at the right time, or will it corrupt operation.
 
Last edited:

hippy

Technical Support
Staff member
It should work. The way FOR-NEXT works on a PICAXE is FOR is the initialisation, NEXT does the increment of the control variable and determines whether to repeat the loop or not ..

FOR var = start TO end STEP step
:
NEXT

var = start
Do
:
var = var +/- step
Loop While var >= start And var <= end

It might be more elegant and clearer to use a DO-LOOP and/or IF-THEN-ELSE construct ...

Code:
b0 = index
Do
  Read b0, b1
  If b1 = "@" Then
    b0 = 0
  Else
    Serout ... ( b1 )
    b0 = b0 + 1
  End If
Loop Until b0 = 0
 
Top