Need some help with code. Trying to store data in buffer.
Don M
Posts: 1,652
I have this method where I'm trying to enter numbers into a buffer. They can be stored as characters and then be read out like a string.
Here's a video of what I'm trying to do:
https://youtu.be/736Rfc8orn0
Here's my method. I get mixed up trying to write characters to a buffer. Don'y know whether I need to add "0" or not. Tried several different ways. The SerNum buffer is a byte buffer declared as byte SerNum[20]
When I go to read it out such as term.str(@SerNum) I get nothing.
Thanks.
Here's a video of what I'm trying to do:
https://youtu.be/736Rfc8orn0
Here's my method. I get mixed up trying to write characters to a buffer. Don'y know whether I need to add "0" or not. Tried several different ways. The SerNum buffer is a byte buffer declared as byte SerNum[20]
pub EnterSerial | idx, c, e, x, y oled.cmd(oled#CLS) oled.moveto(1, 1) oled.str(string("Enter Serial Number:")) oled.moveto(1, 2) oled.str(string("SIM")) byte[SerNum][0] := "S" byte[SerNum][1] := "I" byte[SerNum][2] := "M" idx := 0 x := 4 y := 2 repeat 13 oled.moveto(x++, y) ' X, Y oled.out($FF) ' Show placeholders x := 4 idx := 3 repeat e := encdr.read // 10 oled.moveto(x, y) oled.dec(e) if encdr.ispushed == 1 release byte[SerNum][idx++] := (e + "0") x++ if x == 17 ' If end of spaces then quit byte[SerNum][idx] := 0 ' Store end of string quit oled.cmd(oled#CLS)
When I go to read it out such as term.str(@SerNum) I get nothing.
Thanks.
Comments
You don't need to use the "byte" operator designator.
As Mike Green mentioned, if you do use the byte operator designator you need to include the "@" symbol.
Edit: "byte" is a designator not an operator.