I am making a program that helps make other programs. Programception. Anyways...

1. GetKey
I want a key to be pressed when the user is done with a certain part of the program I am making. Will this work?

Code:

GetKey->K
If K=11
Then
Goto N


2. Have the calculator automatically press buttons?
I want this so the Pen tool for graphing can automatically be selected.

I think I had other questions but I forgot them.
Answer away.
Don't use Goto like that, it will cause a memory leak. Actually, don't use labels and gotos at all if you can, try to avoid them. If you want to use the Pen tool in your program, you'll have to implement it yourself using getKey and the other drawing commands.
souvik1997 wrote:
Don't use Goto like that, it will cause a memory leak. Actually, don't use labels and gotos at all if you can, try to avoid them. If you want to use the Pen tool in your program, you'll have to implement it yourself using getKey and the other drawing commands.

1. What do you mean by implementing it myself?
2. What would be a good substitute for labels and gotos?
While/Repeat/For loops (more of the former 2). For instance, to wait for Y= to be pressed (Keycode 11), you could do
Code:
Repeat Ans=11
GetKey
End
You have to implement Pen yourself because TI-Basic doesn't let you use it in a program. To implement it, you have to: remember the X/Y coordinates, Remember if the pen is down or not, and check the keys yourself for Up/Down/Left/Right/Enter and act accordingly.
Giggybyte wrote:
souvik1997 wrote:
Don't use Goto like that, it will cause a memory leak. Actually, don't use labels and gotos at all if you can, try to avoid them. If you want to use the Pen tool in your program, you'll have to implement it yourself using getKey and the other drawing commands.

1. What do you mean by implementing it myself?
2. What would be a good substitute for labels and gotos?

1) I mean that you can't send keypressed to the OS using TI BASIC, and you can't use the Pen tool inside your program.
2) If-Then statements
some code that could work for the pen tool, (note: i havent dont any ti-basic coding in about a year and havent tested this code) (also note that this dosent draw a cursor)


Code:

:47->a
:31->b
:0->c
:repeat k=45
:getKey->K
:a+(k=26)-(k=24)->a
:b+(k=34)-(k=25)->b
:c+abs(c-(k=105->c
:if c
:pxl-on(a,b)
:End
My contribution to the Pen question, not a perfect solution:

Code:
:While 1
:Input
:Pxl-Change(X,Y
:End
There's no substitute to knowing the commands like the back of your hand and experimenting with them frequently. To each puzzle, a solution is obvious once it's known, but the intuition that gets you there has to be bred through experience – either yours or ours. We'll contribute some of the latter as it comes to that, but as you fine-tune your efforts and bring to light what you've tried along with each question, we can better identify what was missed and understand what nuggets to teach!
KermMartian wrote:
My contribution to the Pen question, not a perfect solution:

Code:
:While 1
:Input
:Pxl-Change(X,Y
:End



whoa wait what? am i missing something?
Try the code yourself, Rhombus. It works.
Input, without any arguments, displays a moveable cursor on the graphscreen and outputs the X and Y values of the curisor when the Enter button is pressed to the program.
*goes to find calc*

Quote:
Input, without any arguments, displays a moveable cursor on the graphscreen and outputs the X and Y values of the curisor when the Enter button is pressed to the program.


ohh ok i guess i did know that
Rhombus P. wrote:
*goes to find calc*

Quote:
Input, without any arguments, displays a moveable cursor on the graphscreen and outputs the X and Y values of the curisor when the Enter button is pressed to the program.


ohh ok i guess i did know that
That's why it's fun to experiment. Funnily enough, I used this trick in Civilization Simulator 1 for the purposes of placing town members.
KermMartian wrote:
Rhombus P. wrote:
*goes to find calc*

Quote:
Input, without any arguments, displays a moveable cursor on the graphscreen and outputs the X and Y values of the curisor when the Enter button is pressed to the program.


ohh ok i guess i did know that
That's why it's fun to experiment. Funnily enough, I used this trick in Civilization Simulator 1 for the purposes of placing town members.


The problem with that method is that it will be very tedious though because you will have to click every point.
Agreed. Here's an optimized form of your code, Rhombus:


Code:
:47->a
:Delvar C31->b
:Repeat K=45
:getKey->K
:A+(K=26)-(K=24->A
:B+(K=34)-(K=25->B
:C+(1-2C)(K=105->C
:If C:Pxl-On(a,b)
:End
I'm disappointed I couldn't find more to optimized. :/

Code:
C xor K=105->C
Daaamn, I can't believe I missed that one. Well done, _player! I was thinking of it too much in integer terms and not enough in boolean terms.
Need more help with GetKey. I am making a custom menu.


Code:

:Text(14,1,"1: Info")
:Text(21,1,"2: New")
:Text(28,1,"3: Open")
:Text(35,1,"4: Delete")


That's the layout.

If the user presses 1, I want the program to goto the info part of the program, and etc.

I've tried what I can think of but I can't seem to get it to work.

wat do
"What should I do?" Wink What did you try already?
KermMartian wrote:
"What should I do?" Wink What did you try already?

I remember trying this:

Code:

:Repeat Ans=92
:GetKey
:goto I
:Lbl I
:blablabla

Didn't work, went straight to I
Also tried:

Code:

GetKey->K
If K=92
Then
Goto I
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement