trouble with array containing mixed-length strings with a data byte
pidzero
Posts: 23
in Propeller 1
Hello,
I'm having trouble figuring out what I'm doing wrong.
OBJECTIVE:
The .SPIN file containing the code above was extracted from a larger program. The larger program was copied into a new file and code unnecessary to help bring focus to the problem was removed. All necessary files for execution are included in the archive attached.
This code is being developed for a Propeller Activity Board. A 4x20 Serial LCD Display is connected at P12.
Thanks, in advance, for your help.
pidzero
I'm having trouble figuring out what I'm doing wrong.
OBJECTIVE:
Repeat the following for all entries in @Files
Read a filename(string), null-terminated. Read a byte of data associated with said filename.
DAT Files byte { "filename" , 0, byte, } "temp1" , 0, $31, { } "temp23" , 0, $32, { } "temp456" , 0, $34, { } $FF
PUB MAIN InitializeFiles(@Files) PRI InitializeFiles(FilesPointer) | pointer, entry, dataoffset, datasize datasize:=1 pointer~ repeat until byte[FilesPointer][pointer]==$FF ' DisplayCLS ' files = "temp1,temp23,temp456" ' DisplayHex(0,0,byte[FilesPointer][pointer],2) ' first pass = $74 second pass = $74 third pass = $6D entry :=FilesPointer[pointer] ' dataoffset:=strsize(entry)+1 ' DisplayStr(1, 0,entry ) ' first pass = "temp1" second pass = unprintable third pass = unprintable DisplayDec(2, 5,pointer ) ' first pass = 0 second pass = 7 third pass = 9 DisplayDec(2,10,dataoffset ) ' first pass = 6 second pass = 1 third pass = 1 DisplayHex(1,18,byte[entry][dataoffset],2) ' first pass = $31 second pass = $B4 third pass = $B4 ' DisplayPage ' pause(32) ' pointer+=dataoffset+datasize ' advance pointer to next filename (or $FF)
The .SPIN file containing the code above was extracted from a larger program. The larger program was copied into a new file and code unnecessary to help bring focus to the problem was removed. All necessary files for execution are included in the archive attached.
This code is being developed for a Propeller Activity Board. A 4x20 Serial LCD Display is connected at P12.
Thanks, in advance, for your help.
pidzero
Comments
What is happening unexpected?
My apologies for not indicating this in the OP.
The results I'm getting are documented in the PRIvate method InitializeFiles of the code in the OP.
The "first pass" results are as expected. The "second pass" and "third pass" results are unexpected.
On execution, the first pass produces this text on the LCD. The data produced is as expected.
On second pass, I expect the following:
On third pass, I expect the following:
Instead, on the second pass I get:
The third pass displays this:
Also, I failed to note in the OP that the faulty loop executes more than the 3 times necessary to produce the expected results.
Changing the code as suggested produced the results I expected.
Good to hear.
Thanks for letting us know what the problem was.
BTW, welcome to the forum.