A pfth puzzle -- passing a variable from one cog to another
LoopyByteloose
Posts: 12,537
Hi.
I am looking for help with this as I just can't seem to make it work.
In pfth, I am attempting to start an infinite loop that generates a change in a variable created in the hubram dictionary. And then I want a second cog to monitor the change in order to take action according to its status.
I am looking for help with this as I just can't seem to make it work.
In pfth, I am attempting to start an infinite loop that generates a change in a variable created in the hubram dictionary. And then I want a second cog to monitor the change in order to take action according to its status.
txt
802B
Comments
This line gives me pause:
you delay...ok
you set your variable...ok
at this point there isn't anything on the stack - what is 1f - puts hex 1F on the stack?
then you put 100 on the stack
then you unset your variable
and loop to do it all again.
Unless I'm missing something or need more coffee, I just see this overflowing the stack after a few loops.
Some of the code needs to be re-ordered so that words are defined before they are used.
I also removed the "1f". I'm not sure what that was for. I added a " ms" after the second 100, which I think is what you intended.
Well, I seemed to have loaded an incorrect file. The 1F was the delay interval in one version where I tried using Hex and then reverted to decimal. But I intended removing it and providing an all decimal solution herein.
It seems the the crux of the problem was Tabs included in the file. The rest appears to be an editting error on my part.
I have had trouble with Tabs before as pfth doesn't recognize them as whitespace.
Thanks, I will try the revision.
Thanks for the tested code.
You had it your original word definition:
Dave said he just created a dummy crset just because he couldn't find it and was testing.
"You started it!!!"
TAB inserted in .fth code causes a failure to compile correctly. And I seem to hit the TAB key regardless on knowing that.
SO, in my preferred test editor - Gedit; I have located a feature that provides SPACES whenever I use the TAB key.
And, I have found an add-on feature for Gedit that shows me my white space info with spaces as grey dots and tabs as grey arrows.
Now that the white space items are visible, I suspect that the issue will not arrise again.
GEDIT is available in Windows and LInux, and much better for creating Forth code as it is a traditional text editor for programmers, rather than a fancy GUI document creator. I just needed to learn how to tweak it to be optimal for pfth.
++++
The test for passing a variable between two cogs is working just fine.
And a larger project that depends on this has had all the hidden TABs finally located and removed. It has been rather frustrating to get a good work method, but it seems all resolved.