Welcome to the Parallax Discussion Forums, sign-up to participate.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ pst : "Parallax Serial Terminal" var long value, x Pub Main pst.Start(115_200) waitcnt(clkfreq * 2 + cnt) pst.Clear pst.Str(String("press any key")) value := pst.CharIn pst.Chars(pst#NL,1) x:=1 repeat while x < 16 pst.Char(@three[x]) x++ pst.Char(@three[x]) x++ pst.Char(@three[x]) x++ pst.Chars(pst#NL,1) pst.Chars(pst#NL,1) pst.Str(String("done")) repeat Dat 'Three letter words Three byte "theandforarebutnotyouallanycanherwasoneouroutday",0
Comments
Changes are:
* Reference the variable 'Three' directly, instead of its address
* The index 'x' is initialized with 0 (that's the first element of your variable 'Three' - it started with 1 before, which would be the 'h' in the word 'the')
* The repeat block now loops as long as the value of three isn't 0/NUL (which was used but not tested for in your original example)
Cheers,
Jesse
WIP Spin/PASM drivers: (P1) (P2) P1 & P2: LSM9DS1, US2066, MLX90621, SHT3x, SSD1306, TCS347x, MAX31856, nRF24L01+, MLX90614, DS28CM00, TSL2591, INA219, SX1276/LoRa, VEML6075 | P1 only: TMC2130, MAX9744, CC1101, SX1231, LM75, DS18B20, Si7021, BT81x, MB85RC | P2 only: W25Qxxx, INA260 | WIP: L3G4200D, IL3820, MPU9250, MLX90640 | Stalled: SI446x, BMP280, BME680, BNO055
I tested with this snippet and it works fine. Note that I use my own version of FDS, not PST.
Hollywood, CA
It's Jon or JonnyMac -- please do not call me Jonny.
BTW, when you see repeated code in your listing you can use condense it with... repeat. For example, from your original listing you could do this:
Hollywood, CA
It's Jon or JonnyMac -- please do not call me Jonny.
P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
Website: www.clusos.com
P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
P2: Tools & Code , Tricks & Traps
Is this the one?
http://obex.parallax.com/object/579
http://paypal.me/parallaxitems
You guys are the best!
I fixed it by subtracting 1 from the extraction index. I just want to know why I needed to do this.
here is the word extraction subroutine
Thanks.
You were right, thanks.
Two things: 1) Use bytemove, not wordmove, and 2) Use strsize() so that you don't have to count the length of the string -- this will let you update the string without having to go back in and fix the code. The reason for the +1 is that it will copy the terminating 0 from the source to the destination.
Hollywood, CA
It's Jon or JonnyMac -- please do not call me Jonny.
Yes, that's it.
Kye has a very nice way of commenting his code, especially tuned for beginners.
To me, the names of the routines and variables are quite long, but they do exactly what the name says.
P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
Website: www.clusos.com
P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
P2: Tools & Code , Tricks & Traps