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 1, 2  Next
» View previous topic :: View next topic  
Author Message
omni


Member


Joined: 14 Jun 2003
Posts: 115

Posted: 21 Jul 2003 10:14:40 am    Post subject:

For 'if then' statements I know that you need an 'end' statement like this:

If B=9
Then
Disp "hi
Disp "bye
End

But what if I just had an If statement:

If B=9:Disp "hi

would I require an 'end statement as well?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 21 Jul 2003 10:41:17 am    Post subject:

Nope.

But without an End it's slower,

If B=9
Then
Disp "Hi"
End

is faster than

If B=9
Disp "Hi"

This is caused by the basic interpreter which has to look for an end.


Last edited by Guest on 21 Jul 2003 10:44:01 am; edited 1 time in total
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 21 Jul 2003 10:42:23 am    Post subject:

no, it would just execute the next code...
this :

Code:
If A=1:Disp "hello"
is equal to
Code:
If A=1:Then:Disp "hello":End
except, one of them is faster, think it is the first one, but not sure completely
Back to top
omni


Member


Joined: 14 Jun 2003
Posts: 115

Posted: 21 Jul 2003 10:47:42 am    Post subject:

If I had something like this would I encounter a memory problem?

If 4=A
Then
Disp "hii
Disp "bye
prgmOTHER
End
Back to top
IntrnalDsK


Member


Joined: 23 Jun 2003
Posts: 103

Posted: 21 Jul 2003 10:57:13 am    Post subject:

Not unless prgmOTHER was a fairly large program, or prgmOTHER had something like this:


-99999999999999999999999999->A
Repeat A=1
A+1->A
End

Which would take a long time to run through, and would cause a memory problem itself.


Last edited by Guest on 21 Jul 2003 10:57:50 am; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 21 Jul 2003 10:58:35 am    Post subject:

Ie, the end won't cause the memory problem.

And:

-99999999999999999999999999->A
Repeat A=1
A+1->A
End

Shouldn't cause a memory problem either

And prmgOTHER would only cause memory problems if it had those problems in it's code or take a lot of memory itself.


Last edited by Guest on 21 Jul 2003 11:02:33 am; edited 1 time in total
Back to top
omni


Member


Joined: 14 Jun 2003
Posts: 115

Posted: 21 Jul 2003 11:09:06 am    Post subject:

alright because I remember reading a tutorial that said that if you write an if then statement and your program is large and has a lot of loops and what not, then you'll encounter a memory problem because it can never find the 'end' statement, which has happened to me. Before my code looked something like this:

While 1
getkey->A
If A=21:Goto SE
If A=24:Goto LF
If A=26:Goto RT
End
and so on

Then I changed it
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 21 Jul 2003 01:34:03 pm    Post subject:

try not to use gotos, cuz they're slow
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 21 Jul 2003 01:35:01 pm    Post subject:

Adm.Wiggin wrote:
no, it would just execute the next code...
this :
Code:
If A=1:Disp "hello"
is equal to
Code:
If A=1:Then:Disp "hello":End
  except, one of them is faster, think it is the first one, but not sure completely

if:then:commands:ends are about 2x faster than if:commands
Back to top
JesusFreak
JesusFreak


Active Member


Joined: 17 Jun 2003
Posts: 537

Posted: 21 Jul 2003 02:00:41 pm    Post subject:

then what would he use if not Goto s?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 21 Jul 2003 02:01:10 pm    Post subject:

Darth Android wrote:
if:then:commands:ends are about 2x faster than if:commands

Nope, I think, Maarten had clocked it all once, think if:then:commands:else:end was faster because it didn't have to look very far for the end.

Maybe I'm remembering it wrong.


Last edited by Guest on 21 Jul 2003 02:04:28 pm; edited 1 time in total
Back to top
JesusFreak
JesusFreak


Active Member


Joined: 17 Jun 2003
Posts: 537

Posted: 21 Jul 2003 02:06:13 pm    Post subject:

Quote:
Nope, I think, Maarten had clocked it all once, think if:then:commands:else:end was faster because it didn't have to look very far for the end.


It was faster but not 2x, it was some thing like
If:command was something liek 8
It:Then:command:end is like 6

i don't remember what is was he was clocking in (ie. what time or how fast)
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 21 Jul 2003 03:09:23 pm    Post subject:

JesusFreak wrote:
It was faster but not 2x, it was some thing like
If:command  was something liek 8
It:Then:command:end is like 6

i don't remember what is was he was clocking in (ie. what time or how fast)

Clockcycles?
Back to top
JesusFreak
JesusFreak


Active Member


Joined: 17 Jun 2003
Posts: 537

Posted: 21 Jul 2003 05:23:08 pm    Post subject:

maybe

most likely
Back to top
omni


Member


Joined: 14 Jun 2003
Posts: 115

Posted: 22 Jul 2003 08:27:43 am    Post subject:

Jesusfreak instead of using gotos I am using a repeat loop .
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 22 Jul 2003 09:06:39 am    Post subject:

very good. goto's are always just plain slow. u have to have a good reason to use them.
Back to top
omni


Member


Joined: 14 Jun 2003
Posts: 115

Posted: 24 Jul 2003 11:04:17 am    Post subject:

If my repeat loop looked like this:

54->Y
Repeat Q
Line(37,Y,46,Y
Line(37,Y,40,Y+2
Line(37,Y,40,Y-2
Repeat getKey
End
Ans->X
Line(37,Y,46,Y,0
Line(37,Y,40,Y+2,0
Line(37,Y,40,Y-2,0
Y-18(X=35)+18(X=26->Y
Y-18(Y>54->Y
Y+18(Y<18->Y
End


And I wanted it to stop whe the user pressed enter or 2nd would I put a
"X=105 or X=21->Q "
somewhere in my loop?
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 24 Jul 2003 11:11:47 am    Post subject:

yes, if it is at the end, then it would be a faster exit im thinking...
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 24 Jul 2003 12:38:26 pm    Post subject:

omni wrote:
And I wanted it to stop whe the user pressed enter or 2nd would I put a
"X=105 or X=21->Q "
somewhere in my loop?

not quite...
u have to do this:
(X=105 or X=21)->Q
Back to top
IntrnalDsK


Member


Joined: 23 Jun 2003
Posts: 103

Posted: 24 Jul 2003 02:06:07 pm    Post subject:

Doesn't it work without the parenthasis?
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 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement