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 TI-BASIC 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. TI-Basic => TI-BASIC
Author Message
MrXuj


Newbie


Joined: 09 Jan 2010
Posts: 12

Posted: 19 Mar 2010 12:51:02 pm    Post subject:

Hi there everyone,

I was playing with some code and I ended up with two pieces of code in a program.
Both were part of a Repeat loop. So I wanted to try something out. It works so far, however, I don't know whether this will mess things up later on.

What I have, not the actual code, but a simple rendition of it:


If not(Ans
Repeat A=B
If 0<Ans
Repeat A=C
End


Is this an effective way to do something that's written the same way, in two loops? Or would this bring errors?


Last edited by Guest on 21 Jun 2010 11:39:53 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 19 Mar 2010 03:05:56 pm    Post subject:

This is actually not a good idea. It will screw up the Basic parser if it tries to skip over this bit of code, because the number of Repeats and Ends don't match.
Back to top
MrXuj


Newbie


Joined: 09 Jan 2010
Posts: 12

Posted: 19 Mar 2010 04:40:33 pm    Post subject:

Ah, I see. Well back to typing again then. Thanks for the answer.
Back to top
calcdude84se


Member


Joined: 09 Aug 2009
Posts: 207

Posted: 19 Mar 2010 06:40:14 pm    Post subject:

The BASIC parser can be strange (or fun, if that's what you think) like that. One of my favorite examples: (this is not an original idea, I am sure that this has been mentioned elsewhere)

Code:
...
For(X,-1,0
If X
Goto S
End
...
Lbl S
...
End

This is about the closest one can get to a subroutine. (I say subroutine, not function, for various reasons)
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 19 Mar 2010 08:06:02 pm    Post subject:

Repeat A=Bnot(Ans)+C(0<Ans

Again, a simple rendition, as Ans will likely need to be preserved better.

Should Ans always remain in the positives:

Repeat A=Bnot(Ans)+Cnot(not(Ans

or

Repeat A=C+(B-C)not(Ans

The two being of equal size, we should now test which one is faster:

startTmr→T
For(X,0,1)
For(A,0,16)
For(B,0,16)
For(C,0,16)
X
expr
End
End
End
End
checkTmr(T

expr = A=Bnot(Ans)+Cnot(not(Ans
116 seconds

expr = A=C+(B-C)not(Ans
121 seconds


Last edited by Guest on 21 Jun 2010 08:55:57 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