Posted 30 May 2016 - 08:34 AM
Okay, I'm having a problem in my code…and it's probably something simple, but I've tried tweaking this many times, troubleshooting and debugging everything I can think of, and I think it just needs a fresh set of eyes. The following are the pastebins for my code (and the Touchpoint API, made by Lyqyd plus a small section added by me for making boxes that aren't buttons): Main Code and API.
The problem? When I call nextPage(str) (line 60) or prevPage(str) (line 70), the program behaves as expected, and I flip to the next or previous page. tp=pages[currPage] works. In searchCows(str) (line 80), the tp=pages[currPage] does not seem to set the tp variable, and the new page fails to display. I know the search page/keyboard needs some graphical/alignment tweaking, but it DOES display if I set line 282 to "tp = pages["search"]" before my first tp:draw(). I'm not understanding why it's setting the variable and displaying the correct page when the variable is a number, but not when that variable is a string. I even tried changing line 84 to "tp = pages["search"] like what worked on line 282 while testing, and that didn't seem to fix the problem. The reason I think it's not setting the variable properly because during my troubleshooting/debugging, in the searchCows function I set a test variable and verified that it was the value I set while within the function, but then when I printed it in my while loop (a few lines of code later, execution-wise), that variable was nil.
Please point out the probably trivial thing I'm missing and pulling my hair out trying to find.
The problem? When I call nextPage(str) (line 60) or prevPage(str) (line 70), the program behaves as expected, and I flip to the next or previous page. tp=pages[currPage] works. In searchCows(str) (line 80), the tp=pages[currPage] does not seem to set the tp variable, and the new page fails to display. I know the search page/keyboard needs some graphical/alignment tweaking, but it DOES display if I set line 282 to "tp = pages["search"]" before my first tp:draw(). I'm not understanding why it's setting the variable and displaying the correct page when the variable is a number, but not when that variable is a string. I even tried changing line 84 to "tp = pages["search"] like what worked on line 282 while testing, and that didn't seem to fix the problem. The reason I think it's not setting the variable properly because during my troubleshooting/debugging, in the searchCows function I set a test variable and verified that it was the value I set while within the function, but then when I printed it in my while loop (a few lines of code later, execution-wise), that variable was nil.
Please point out the probably trivial thing I'm missing and pulling my hair out trying to find.