Lost in arrays...
Hi all,
I'm still struggling with my datalogger project and trying to get a simple array to fill open spaces, so to speak.
I wrote this code to accept an input up to 20 characters and if one of those characters is a * to fill the rest of the spaces with # signs. In the final version, I will be reading words from a datalogger and looking for a space, when I see the space, I want to fill the rest of the 20 characters with spaces. I am guessing I am doing something so simply wrong that I can't find it. Help?
I'm still struggling with my datalogger project and trying to get a simple array to fill open spaces, so to speak.
I wrote this code to accept an input up to 20 characters and if one of those characters is a * to fill the rest of the spaces with # signs. In the final version, I will be reading words from a datalogger and looking for a space, when I see the space, I want to fill the rest of the 20 characters with spaces. I am guessing I am doing something so simply wrong that I can't find it. Help?
' {$STAMP BS2}
' {$PBASIC 2.5}
index VAR Nib
temp VAR Byte
ctr VAR Byte
ctr2 VAR Byte
userEntry VAR Byte(20)
DEBUG "enter word;"
FOR ctr=1 TO 20
DEBUG CR," ctr = ", DEC ctr
DEBUGIN STR userEntry\(ctr)
IF userEntry(ctr)<> "*" THEN
GOTO jumpone
ELSEIF userEntry (ctr)= "*" THEN
'user entry is a * so fill array with #'s
'increment from ctr to 20 to fill.
FOR ctr2 = ctr TO 20
userEntry(ctr)="#" ' filling array with #'s
DEBUG STR userEntry \(ctr)
NEXT
GOTO jumptwo
ENDIF
jumpone:
DEBUG CR,"jumpone", CR
NEXT
END
jumptwo:
DEBUG "jumptwo", CR
DEBUG STR userEntry \20
END

Comments
If userEntry is being filled a byte at a time you need to address each element in turn·and each time check for the "*"
Jeff T.