Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Halifax on September 12, 2006, 11:38:00 am

Title: [TI-83+ BASIC] routine help
Post by: Halifax on September 12, 2006, 11:38:00 am
I need help because this routine doesn't work i need a routine the returns zero if C or D or E or F not equal to zero and return zero if G!=8 or 80 or H!=8 or 48. Heres my code that doesnt work. I need it to return one only when both are right

(((G=8 or G=80) or (H=8 or H=48)) and (C or D or E or F=12))
Title: [TI-83+ BASIC] routine help
Post by: kalan_vod on September 12, 2006, 08:11:00 pm
QuoteBegin-Killerplayer+12 Sep, 2006, 17:38-->
QUOTE (Killerplayer @ 12 Sep, 2006, 17:38)
I need help because this routine doesn't work i need a routine the returns zero if C or D or E or F not equal to zero and return zero if G!=8 or 80 or H!=8 or 48. Heres my code that doesnt work. I need it to return one only when both are right

(((G=8 or G=80) or (H=8 or H=48)) and (C or D or E or F=12))


0 if c or d or e or f !=0
0 if g!=8 or 80 or H!=8 or 48  

 I thought you posted this in your Glatic thread, but I thought it over and found a simple solution:
c1
-->
CODE
ec1(G=8 or G=80 or H=8 or H=48) and max(0={C,D,E,Fc2
ec2
Title: [TI-83+ BASIC] routine help
Post by: Halifax on September 13, 2006, 11:09:00 am
o sweet thanks and yes i did but no one answered :(sad.gif
Title: [TI-83+ BASIC] routine help
Post by: kalan_vod on September 13, 2006, 11:26:00 am
QuoteBegin-Killerplayer+13 Sep, 2006, 17:09-->
QUOTE (Killerplayer @ 13 Sep, 2006, 17:09)
o sweet thanks and yes i did but no one answered :(sad.gif

 I was going to back then, but couldn't figure it out...the way you said it seems odd, but I got it now :Ptongue.gif.
Title: [TI-83+ BASIC] routine help
Post by: DJ Omnimaga on September 13, 2006, 02:25:00 pm
sometimes i think asking help in your project thread is a bad idea since all ppl care about is the game progress and screenies
Title: [TI-83+ BASIC] routine help
Post by: Halifax on October 14, 2006, 07:03:00 am
Dies anyone know how you can type If Str1="A" or "B" without iit saying a syntax error occured
Title: [TI-83+ BASIC] routine help
Post by: Spellshaper on October 14, 2006, 08:10:00 am
how about:

If Str1="A" or Str1="B
Title: [TI-83+ BASIC] routine help
Post by: Halifax on October 14, 2006, 02:59:00 pm
yea I knew of that way but I'm rele going to be doing it for about 50 chars(i should have told you that) so that would take up mucho space
Title: [TI-83+ BASIC] routine help
Post by: kalan_vod on October 14, 2006, 05:20:00 pm
Well if you are looking for speed vs. size, that would be the fastest. Now if you want size vs. speed, then you could do this:
c1-->
CODE
ec1DelVar XRepeat Ans
X+1->X
inString("AB..etc",Str1,X
Endc2
ec2
Amazingly it is even faster >.>, or at least not any bit noticable..Go with the code I posted, it is just as fast (if not faster) and smaller.
Title: [TI-83+ BASIC] routine help
Post by: Halifax on October 15, 2006, 04:20:00 am
I don't follow that cause I actualy need something like
If Str1="A" or "B" or "C" or "D" or "E" or "F" or ...:Then
code
End
Title: [TI-83+ BASIC] routine help
Post by: Radical Pi on October 15, 2006, 04:26:00 am
If inString(Str1,"A B C D E F"
Then
XXX
End

Separate the A's and B's with spaces.
Title: [TI-83+ BASIC] routine help
Post by: kalan_vod on October 15, 2006, 07:29:00 am
c1-->
CODE
ec1DelVar XRepeat Ans or X=26;If inString works or it reaches the end quit loop
X+1->X;advance the pointer
inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Str1,X->O;testing, store into O
End;hope you know this
If O:then;if inString contain what Str1 did, then excute this code. if it didnt find it, it continues onward
...
End
c2
ec2
This will work, try it for yourself.
Title: [TI-83+ BASIC] routine help
Post by: Halifax on October 15, 2006, 09:08:00 am
kk thanks kalan_vod
Title: [TI-83+ BASIC] routine help
Post by: kalan_vod on October 15, 2006, 11:57:00 am
QuoteBegin-Killerplayer+15 Oct, 2006, 15:08-->
QUOTE (Killerplayer @ 15 Oct, 2006, 15:08)
kk thanks kalan_vod  

 Np, if you don't understand any of it let me know as I know it is difficult to understand others code. Also, this is rather interesting as it would help me also :Ptongue.gif. Strings are faster as we all know, but seeing this it makes it prove it (if you did the same thing but with a list).
Title: [TI-83+ BASIC] routine help
Post by: burr on October 16, 2006, 06:07:00 am
QuoteBegin-kalan_vod+13 Sep, 2006, 2:11-->
QUOTE (kalan_vod @ 13 Sep, 2006, 2:11)
c1-->
CODE
ec1(G=8 or G=80 or H=8 or H=48) and max(0={C,D,E,Fc2
ec2

You did a good job optimizing, but you forgot to do some http://tibasicdev.wikidot.com/optimize. I'm surprised PiMan didn't say anything, because I know he knows them :Dbiggrin.gif

c1
-->
CODE
ec1(36=abs(G-44) or 20=abs(H-28))max(0={C,D,E,Fc2
ec2
Title: [TI-83+ BASIC] routine help
Post by: DJ Omnimaga on October 16, 2006, 06:33:00 am
yea he prbly wanted to make the code still understandable, or prbly radical_pi didnt checked this topic after his reply, interesting guide tho you posted here, tifreak8x should add it to his link section if not done alerady. Welcome here btw :)smile.gif
Title: [TI-83+ BASIC] routine help
Post by: burr on October 16, 2006, 07:47:00 am
QuoteBegin-xlibman+16 Oct, 2006, 12:33-->
QUOTE (xlibman @ 16 Oct, 2006, 12:33)
yea he prbly wanted to make the code still understandable, or prbly radical_pi didnt checked this topic after his reply, interesting guide tho you posted here, tifreak8x should add it to his link section if not done alerady. Welcome here btw :)smile.gif

kalan_vod wanted to make the code understandable? I think you're talking about a different kalan_vod, because the kalan_vod I know loves hard to  read code :Ptongue.gif

The optimization guide I linked to is part of the http://tibasicdev.wikidot.com wiki I started a couple months ago. The wiki has lots of other good TI-Basic information (including a pretty good http://tibasicdev.wikidot.com/resources page :Dbiggrin.gif) and is open to every TI-Basic programmer to contribute to. Hopefully it can keep growing and become a valuable resource for the TI-Basic community.
Title: [TI-83+ BASIC] routine help
Post by: Halifax on October 16, 2006, 10:46:00 am
thanks burr I like that code better and also kalan_vod there is nothing I dont understand about your code it is very fast and easy
Title: [TI-83+ BASIC] routine help
Post by: burr on October 16, 2006, 09:58:00 pm
QuoteBegin-Killerplayer+16 Oct, 2006, 16:46-->
QUOTE (Killerplayer @ 16 Oct, 2006, 16:46)
thanks burr I like that code better and also kalan_vod there is nothing I dont understand about your code it is very fast and easy

I don't think kalan_vod left off those optimizations because he thought you didn't understand them. Most likely he just forgot about them; there's lots of optimizations to remember.
Title: [TI-83+ BASIC] routine help
Post by: burr on October 16, 2006, 10:15:00 pm
QuoteBegin-kalan_vod+15 Oct, 2006, 13:29-->
QUOTE (kalan_vod @ 15 Oct, 2006, 13:29)
c1-->
CODE
ec1DelVar XRepeat Ans or X=26;If inString works or it reaches the end quit loop
X+1->X;advance the pointer
inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Str1,X->O;testing, store into O
End;hope you know this
If O:then;if inString contain what Str1 did, then excute this code. if it didnt find it, it continues onward
...
End
c2
ec2

I might be missing something, but why not use the code PiMan posted? The inString( command starts with the first character in the string and moves to the right by default, so there really is no need to introduce another variable or even use a loop; a simple conditional will do.
Title: [TI-83+ BASIC] routine help
Post by: DJ Omnimaga on October 17, 2006, 03:08:00 am
its the same kalan I think, he prbly forgot some of them, as well as radical Pi, no one is perfect x.x plus they may have been in a hurry at that time

personally I write hard to understand code as well, only problem is that it's not as optimised as it would be with some other ppl :(sad.gif
Title: [TI-83+ BASIC] routine help
Post by: Halifax on October 17, 2006, 09:33:00 am
@burr: I think Kalan's code is better and very fast(33 chars per second) also I am testing anywhere from 6-120 types of chars and 200 chars at a time so I think his is the best for me and also I did not quite understand Radical Pi's code
Title: [TI-83+ BASIC] routine help
Post by: Radical Pi on October 17, 2006, 09:59:00 am
My code was the bare minimum. It is basically kalan's without a loop, which WILL work. Faster and Smaller, right? I'd expect so, but I'm only good with this in theory. :)smile.gif
Title: [TI-83+ BASIC] routine help
Post by: kalan_vod on October 17, 2006, 04:23:00 pm
Hey burr, and this isn't my territory anymore since I just came back and am working on Asm >.>...sorry
Title: [TI-83+ BASIC] routine help
Post by: DJ Omnimaga on October 18, 2006, 09:46:00 am
w00t I want to see a 8 level grayscale first person shooter now kalan!!!

I hope you arent leaving us tho O_Oshocked2.gif i would hate to see you go because you now program asm :(sad.gif because you are a nice member in this community and on top of that we dont have enough asm programmers x.x