Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 24 Mar 2012 11:48:51 am    Post subject:

Hi. I've been writing some programs in TI-basic on my TI-84 and i find it really annoying that those functions are missing. Im going to give the code examples in c++, and some explanations for those who didnt program in c++.


Code:
for(int i = 0;i<5;++i) {
   if (var == 1){
      //...
   }
   if (var == 2){
      //...
      continue;  //if var equals to 2 the loop will skip everything, and continue with incemented i as if it has done everything.
   }
   if (var == 3){
      //...
      break; // if var equals to 3 we jump out of the loop to the first instruction after the loop(in this case var=5;)
   }
}
var = 5;

I didnt find those commands in TI, and since the counters are global i make a label before the loop and jump there(continue) or after it(break).

TI code:

Code:
Label B
For(I,0,4)
If A=2
Goto B
If A=3
Goto E
End
Label E


Last edited by Guest on 24 Mar 2012 11:50:27 am; edited 1 time in total
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 24 Mar 2012 12:58:21 pm    Post subject:

I don't really get what is being accomplished here .___. I would do:

Code:

If A≠3
Then
For(I,0,4
If A=2
5→I
End
If I=5
Goto B
End
Back to top
tiuser1010


Member


Joined: 23 Apr 2009
Posts: 100

Posted: 26 Mar 2012 02:35:25 pm    Post subject:

Alright! 100th post. Happy Birthday to me.

There's a couple of ways I thought of doing this, but this is my best one

If you already tried this way then I'm sorry, But if you haven't well...

There is a command called Return in the prgm menu
And there are a couple of things to note about it

if used in a program outside of a loop it will stop the program completely
so ...

Code:
Disp X
Return
Disp Y


Will only display X

And if used if encountered in a subprogram the subprogram will stop and "return" execution to the calling program

Since you program in C++, You can see that the return statement is basically the same in TI-BASIC as in C++

Now according to http://tibasicdev.wikidot.com/return if used in a loop, the loop will stop

So in theory

Code:
:For(I,1,10)
:Disp I
:If I=5
:Return
:End
:Disp "HELLO"


Should Display
1
2
3
4
5
HELLO

But it only displays 1-5 on my TI-83 Plus Sliver Edition v. 1.14 and my TI-84 Plus Sliver Edition v. 2.55

The only way I see to do what your doing in TI-BASIC is to put your for loop in a subprogram or


Code:
PROGRAM:LOOP
:For(I,0,5)
:If A=1
:Then
:(Some stuff)
:End
:If A=3
:Then
:(Some stuff)
:Return
:End
:If A=2
:Then
:(Some stuff)
:End
:End



Code:
PROGRAM:MAIN
:prgmLOOP
:(Whatever else your trying to do)


This the only way I see to do it
Now I do see problems if (Some stuff) modifies A which could make the code more complex

Perhaps if you posted more of your code up or even just tell us what you want to do specifically
Then maybe someone could give you an idea on how to do what your doing better

Also when you say "those functions" in the quote

Quote:
Hi. I've been writing some programs in TI-basic on my TI-84 and i find it really annoying that those functions are missing. Im going to give the code examples in c++, and some explanations for those who didnt program in c++


What do you mean by "those functions"?
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 26 Mar 2012 08:00:59 pm    Post subject:

Wow, excellent post, tiuser1010 o.o There are a few parts in there that are very useful (like with the Return command). Also, you joined on my birthday >.>

Last edited by Guest on 26 Mar 2012 08:01:35 pm; edited 1 time in total
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement