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
United-TI Archives -> TI-Basic
 
    » Goto page Previous  1, 2, 3, 4 ... 29, 30, 31  Next
» View previous topic :: View next topic  
Author Message
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 07 Jun 2003 12:52:22 pm    Post subject:

i would use it like this (in a game) :
Text(0,0,"Score : ",S

get it? it would disp the score in the top left hand corner like so :
Score : 554
Back to top
Smasher
I'm a llama!


Newbie


Joined: 25 May 2003
Posts: 15

Posted: 07 Jun 2003 08:09:49 pm    Post subject:

If-then-command(s)-end statements take up a bit more space than If-command statements, but are significantly faster (about 2x).

The smallest and (almost) fastest way to shuffle a deck of cards is

Code:
:seq(X,X,1,52->L1
:rand(52->L2
:SortA(L2,L1

Okay, it's not a trick, but it's nifty... admit it :D

While loops and Repeat loops take exactly the same amount of time (despite claims to the contrary).

If you want the flexibility of calling subroutines but don't want to bundle a bunch of subprograms with your main program, use internal subroutines. At the beginning of your program put something like

Code:
:If Q=2.351 // or any random number
:Then
:0->Q // prevents the program from messing up if the user breaks during execution
:Return
:End
... and when you want to call the subroutine:
Code:
:2.351->Q
:progGAME
You can even have multiple subroutines by using different numbers for Q. Unlike Goto's, the If-then statement in the subroutine is automatically terminated when it hits return, so you won't get any memory errors. It's also a lot faster than goto, especially in large programs.
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 08 Jun 2003 02:26:56 am    Post subject:

You can use internal subs too; almost.

While 1
;do something

Goto A ;A is the sub


End

Lbl A
;do sub stuff
End ;returns to the top of the whlile loop not exactly where we left off, but to the top of the main sub providing the While codition is still true which it will be becasue we used While 1.

Also note that repeat and while are not exactly the opposite.

e.g.

Repeat A=7
A+1->A
End

While A(not equal)7
A+1->A
End

They are indeed different!

The difference is that a repeat loop always executes at lest once.

e.g.

Repeat 1
disp "HELLO
End

You will see exactly one HELLO

While 0
disp "HELLO
End

HELLO will not be displayed.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 09 Jun 2003 03:55:35 am    Post subject:

Jbirk wrote:
Repeat 1
disp "HELLO
End

You will see exactly one HELLO

While 0
disp "HELLO
End

HELLO will not be displayed.

I take it you ment Repeat 0, otherwise you'll see many hello's.
Back to top
gorchy


Newbie


Joined: 30 May 2003
Posts: 19

Posted: 09 Jun 2003 04:10:37 am    Post subject:

another way to make subroutines is to call a prgm e. g. (theta)subrout and store into A the number of the subrout you want to execute.
it would look like this:

:if A=1
:then
\
\ subroutine
\
:return
:if A=2
:then
...

this method has the advantige that you donīt need a bunch of labels in your prgm and you can use the subroutes in different prgms
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 09 Jun 2003 12:47:33 pm    Post subject:

Arcane Wizard wrote:
Jbirk wrote:
Repeat 1
disp "HELLO
End

You will see exactly one HELLO

While 0
disp "HELLO
End

HELLO will not be displayed.

I take it you ment Repeat 0, otherwise you'll see many hello's.

actually:
while (condition is true)
repeat (until condition is true)
so:
repeat 1 would run once because 1 is true
repeat 0 would run forever bcuz 0 is never true
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 09 Jun 2003 01:34:15 pm    Post subject:

I had the feeling you'd come round and say I was wrong, argh last time I post while making my homework.
Back to top
gorchy


Newbie


Joined: 30 May 2003
Posts: 19

Posted: 09 Jun 2003 03:15:37 pm    Post subject:

Laughing Oops, I forgot to log in...
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 10 Jun 2003 11:26:07 am    Post subject:

i dont do it to show off or anything. im just making sure someone who has never touched or seen a calculator can understand it correctly Rolling Eyes
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 10 Jun 2003 04:36:25 pm    Post subject:

Arcane Wizard wrote:
Jbirk wrote:
Repeat 1
disp "HELLO
End

You will see exactly one HELLO

While 0
disp "HELLO
End

HELLO will not be displayed.

I take it you ment Repeat 0, otherwise you'll see many hello's.

No, I meant exactly what I said!

You see, Repeat 1 is the opposite of Repeat 0, so instad of executing forever as in the case of repeat 0, repeat 1 will cause the condition to run exactly once.

repeat (non Zero) will cause the contents of the loop to run exactly once!


If you are familiar with other languages, you probably know what a do while exucutes once no matter what, and then continues to execute while true.

You may have heard of the Until condition is true as in other languages.

I emplore you to think of repeat as a Do Untill loop :wacko:


Last edited by Guest on 10 Jun 2003 04:39:03 pm; edited 1 time in total
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 10 Jun 2003 07:07:04 pm    Post subject:

more precise, a repeat until... like this snippet of C++ code :

Code:
#include <iostream.h>
int main()
{
int a=0;
repeat {
cout<<"Hello"<<endl;
} until (a==1);
}
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 11 Jun 2003 03:15:25 am    Post subject:

How do you use a do_nothing loop?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 11 Jun 2003 04:55:38 am    Post subject:

Yeah, yeah, yeah, I got the point, sometimes I'm just not paying attention or something and make a couple of stupid posts. Neutral
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 11 Jun 2003 07:28:58 am    Post subject:

we're just playing with u! Razz we all realized u got the point. but some of us *cough* JBirk adm. wiggin*cough* like 2 rub it in.

*note: jbirk, i have nothing against u or adm. wiggin and really appreciate all the help through the pm. it just so happens yall were the second and third people to answer his question.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 11 Jun 2003 08:33:51 am    Post subject:

Yeah, I know, it's pretty funny :)

It's just annoying to know you're making a stupid post or asking a stupid question but you can't seem to figure out what it is, then just leave it be and hear from someone you missed the most obvious thing ever.

hehe :lol:

____

Please delete this and the previous post, I figure you guys know who wrote the one after android's post.
____

I deleted the last, and merged this one with the one before


Last edited by Guest on 11 Jun 2003 02:12:16 pm; edited 1 time in total
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 11 Jun 2003 12:51:24 pm    Post subject:

srry if i was being redundant, but if we all give the same answer in a different way, then he is more likely to understand then if just one of us gives him one answer in a confusing way... Wink
Back to top
62 52 53 53
Formerly known as 62 52 53 53


Active Member


Joined: 30 May 2003
Posts: 607

Posted: 11 Jun 2003 01:51:21 pm    Post subject:

but if we all answer and he could understand 1 separately, that can sometimes be even more confusing.
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 11 Jun 2003 02:56:40 pm    Post subject:

ya, ur probably right Laughing it could get pretty confusing :wacko:
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 11 Jun 2003 04:55:56 pm    Post subject:

What happened to tricks in BASIC? Very Happy

Spyderbyte
Back to top
yugniht


Member


Joined: 29 May 2003
Posts: 167

Posted: 11 Jun 2003 05:15:52 pm    Post subject:

good point Smile
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
    » Goto page Previous  1, 2, 3, 4 ... 29, 30, 31  Next
» View previous topic :: View next topic  
Page 3 of 31 » All times are GMT - 5 Hours

 

Advertisement