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, 3  Next
» View previous topic :: View next topic  
Author Message
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 09 Jan 2004 01:12:21 am    Post subject:

Ok I have an idea of what boolean logic is and I think I may have used some in past programs. But can someone explain to me it's exact use in BASIC progs, and what you would use it for? Thanks.
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 09 Jan 2004 02:30:13 am    Post subject:

You would use it to test conditions

ClrHome
Input A
If A=2
Disp "A IS 2

or

ClrHome
Disp "YOUR NAME?
Input "NAME",Str1
if Str1="JEDD"
Then
Disp "I AM JEDD TOO
Else
Disp "YOU ARE NOT JEDD
End

or

ClrHome
0->A
RandInt(1,1000)->B
input C
If C=B
Then
Disp "YOU WON IN
Disp A+1,"GUESSES
Stop
Else
If B>C
Then
Disp "BIGGER
Else
Disp "SMALLER
End
A+1->A
End

A stupid guessing game above
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 09 Jan 2004 02:39:33 am    Post subject:

Err I think you left out a loop that should have been before the Input C (but I didn't run the code so I dunno). So is B.L. just If/Then/Else statements? Cuz if so then, hehe, yeah I've used 'em a few times.
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 09 Jan 2004 02:54:01 am    Post subject:

Yeah, I think you are right :)

Insert a line before input C and put While 1 on it

Add a line to the end of the file and make the line say End

... enjoy
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 09 Jan 2004 03:07:10 am    Post subject:

ClrHome
Disp "BETWEEN 1 AND"
Input C
randint(1,C)->B
0->A
1->D
Repeat (A=B)+(D=10)
D+1->D
Input "GUESS?",A
If A<B
Disp "HIGHER"
If A>B
Disp "LOWER"
End
If D<10
Disp "CORRECT!'
Disp "YOU WIN!"
Else
Disp "RAN OUT OF GUESSES!"
Disp "YOU LOSE!"
End
Output(1,1,""

I think this will work. The reason I'm completing "parenthesis" and such is because I just began programming C. The above program won't work if you pick a number below 1.

Edit: hahaha. I would change the B) but I like it too much. Just change it to [Capitol B][Curly Brace].

For those of you that are confused, there was a in place of B).

...Thanks Arcane.


Last edited by Guest on 09 Jan 2004 07:42:14 pm; edited 1 time in total
Back to top
Bryan Thomas
Outer Limit Software


Advanced Member


Joined: 20 May 2003
Posts: 298

Posted: 09 Jan 2004 01:41:43 pm    Post subject:

Yeah boolean logic is probably one of the best things to know when programming BASIC. It shortens up code and speeds things up alot more.

I used it alot in Contra, Agility, and Dotz. Very Happy

Basically this is how it works:

It test the giving statement and if it is true it returns a 1, and if it isnt it returns a 0. So basically it has digital output.

I used it alot when I want to make things move. Because I cand do it much easier then using if statement: here is an example of a pxl moving around the screen that will not go outta the boundaries.

this means not equal to:
/=

Delvar A
Delvar B
Repeat Z=105
Pxl-on(A,B
getkey->Z
A+(Z=34 and A/=62)-(Z=25 and A/=0)->A
B+(Z=26 and B/=94)-(Z=24 and B/=0)->B
End

See how much easier it is?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 09 Jan 2004 04:55:07 pm    Post subject:

I think it is also faster to use +, -, and * for or, not equal to (put /=, !=, or <> according to your preferences), and and.
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 09 Jan 2004 05:53:47 pm    Post subject:

Quote:
Delvar A
Delvar B
Repeat Z=105
Pxl-on(A,B
getkey->Z
A+(Z=34 and A/=62)-(Z=25 and A/=0)->A
B+(Z=26 and B/=94)-(Z=24 and B/=0)->B
End


Delvar A
Delvar B
Repeat Z=105
Pxl-on(A,B
getkey->Z
A+(Z=34)(A/=62)-(Z=25)(A/=0)->A
B+(Z=26)(B/=94)-(Z=24)(B/=0)->B
End

Notice I took out "and"
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 10 Jan 2004 12:37:14 pm    Post subject:

You could also replace (A/=0) and (B/=0) with just A and B
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 10 Jan 2004 01:34:38 pm    Post subject:

Good point. Unless you made it so the game moved more than 1 pixel.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 10 Jan 2004 02:28:48 pm    Post subject:

Jedd wrote:
Delvar A
Delvar B
Repeat Z=105
Pxl-on(A,B
getkey->Z
A+(Z=34)(A/=62)-(Z=25)(A/=0)->A
B+(Z=26)(B/=94)-(Z=24)(B/=0t)->B
End

Notice I took out "and"


Code:
Delvar ADelvarBWhile Z-105
Pxl-ON(A,B
getKey -> Z
A+ (Ans=34)(A<>62)-(Ans=25)not(not(A -> A
B+(Z=26)(B<>94)-(Z=24)not(not(B->B
End

Assumes Z isn't 105 at beginning.
Back to top
anduril66
Anduril is the Flame of the West!


Member


Joined: 25 May 2003
Posts: 129

Posted: 12 Jan 2004 05:49:44 pm    Post subject:

Isn't not(not(A the same as A? (what X1011 said)

So you could use:
B+(Z=26)(B<>94)-B(Z=24->B instead, for example.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 12 Jan 2004 05:57:52 pm    Post subject:

anduril66 wrote:
Isn't not(not(A the same as A? (what X1011 said)

not(not(A always has a value of either 0 or 1.

Quote:
B+(Z=26)(B<>94)-B(Z=24->B


If B were let's say 60 and you pressd left, B would decrease 60 and become 0 which is definitely not what you want.
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 12 Jan 2004 06:06:03 pm    Post subject:

B+(Z=26)(B!=94)-(B and Z=24->B

Would that be faster than not(not(?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 13 Jan 2004 05:30:37 am    Post subject:

Don't know if it's faster(probably is), but it sure is smaller and easyer to read.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 13 Jan 2004 05:19:10 pm    Post subject:

X1011 wrote:
B+(Z=26)(B!=94)-(B and Z=24->B

Would that be faster than not(not(?

I always do something like

B+(Z=24)-(Z=26
Ans+95((Ans<0)-(Ans>94 -> B

because it allows you to jump to the other side of the screen if you hit an edge. Actually, I use R, C, and K instead of A, B, and Z.
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 13 Jan 2004 06:07:07 pm    Post subject:

Everyone seems to leave off the last curly brace after a statement. I used to too, but it looks cleaner if it's there. But aside from looking clean, does taking it off really make it go any faster? I know it saves space, but that's not what im asking.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 13 Jan 2004 06:08:46 pm    Post subject:

It doesn't make it go much faster but the parser doesn't have to check as many bytes for the line so yes it does make the program a tiny bit faster.
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 13 Jan 2004 06:21:49 pm    Post subject:

Because that's what I though about IfStatement-Action, but it turns out IfStatement-Then-Action-End is a little faster.

Last edited by Guest on 13 Jan 2004 06:22:35 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 14 Jan 2004 11:35:54 am    Post subject:

Yeah, the if then end thing is faster if you include the then end part, but with curly braces it should be slower (to close them) since we only remove them if they are at the end of the line, which comes several bytes sooner if there are less closing curly braces. And it doesn't have to check for several if you just use : it closes all of them that happened to be open.

Last edited by Guest on 14 Jan 2004 11:36:23 am; 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
    » Goto page 1, 2, 3  Next
» View previous topic :: View next topic  
Page 1 of 3 » All times are UTC - 5 Hours

 

Advertisement