# Omnimaga

## Calculator Community => TI Calculators => TI-BASIC => Topic started by: necro on November 27, 2005, 01:29:00 pm

Title: Undocumented TI-BASIC tricks
Post by: necro on November 27, 2005, 01:29:00 pm
any one think this should be the big talked about command in basic?  It alows you to do all kinds of things, from self modifying code to very advanced optimisations.

Ok...this doesn't work...

Here, this one is a bit more complex example
You could store into String1 "1,16(A-1),16(B-1),2,16," and "0,0,0" into String3, and do an asm preproccess to take a matrix and make it into a string of "which pic to use, which row, and which column"
:For(A,0,4
:For(B,0,6
:real(String1+String2+String3
:End
:End

Fixed well...that would work...but it doens't use expr  :dang:
************************************************
Ok, if enemy had a defense of 40, and was weak to fire...
"(1st:weak to fire?,2nd:Def,3rd=Health

"1,040,H"->String1

And if attacked
"weilding the Fire Sword of Bonus Damage"
"100*2("+sub(String1,1,1)+")-"+sub(String1,3,3)
expr(H-Ans
Well, that would do a bunch of crap...but H would be -160 as a result of "100*2(1)-040"... :imbeciles:
ok...that example was :beurk:...but I hope you got the picture

well, discuss...
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on November 27, 2005, 02:06:00 pm
QuoteBegin-necro+27 November 2005, 19:29<table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td><b>QUOTE</b> (necro @ 27 November 2005, 19:29)</td></tr><tr><td id="QUOTE">QuoteEBegin any one think this should be the big talked about command in basic?
Title: Undocumented TI-BASIC tricks
Post by: necro on November 27, 2005, 02:14:00 pm
yes...you could optimise a 16X16 basic tile mapper that way.  (what I want help doing for LOZNA)  Prgm stuff won't work...my bad ):
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on November 27, 2005, 02:28:00 pm
still pretty cool stuff
Title: Undocumented TI-BASIC tricks
Post by: necro on November 27, 2005, 02:50:00 pm
some one needs to add that to ti-os...
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on November 28, 2005, 03:11:00 am
OMG I didn
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on November 28, 2005, 10:33:00 am
very nice necro, this should be really useful :)
Title: Undocumented TI-BASIC tricks
Post by: necro on November 28, 2005, 11:04:00 am
and I learned it just Friday...any ways, in rpg, this is a great way to add multipliers, resistances/weaknesses, etc...also, this could be quite useful in complex magic systems...all kinds of uses realy.

I am trying to find out what commands screw it up...so far,  prgm***** ,asm(***** ,and real(xlibstuff***** commands.

OH...NOTE: real(string1 does work as a xlib command set...but if real is in expr("____" it will work like the normal math command
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on November 28, 2005, 11:37:00 am
very nice, I should try this out :)
Title: Undocumented TI-BASIC tricks
Post by: KermMartian on November 28, 2005, 11:54:00 am
wow, this is cool! I never thought to do that...
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on November 28, 2005, 12:00:00 pm
seems like it might open a new door for self modifying code in BASIC :D
Title: Undocumented TI-BASIC tricks
Post by: necro on November 28, 2005, 12:12:00 pm
yep, I just hope it doesn't lead to overly complex/ unmanagable code
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on November 28, 2005, 12:55:00 pm
You guys figured this out just now? I've been using this for a year.
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on November 28, 2005, 01:09:00 pm
what? you should have posted about it :? maybe other ppl wanted to know a long time before :x

still cool  though because I  didnt knew about this
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on November 28, 2005, 04:08:00 pm
i actually knew about it, just didn't exploit it to its full potential yet. Go Necro!! anyways, i use it in my zelda text decoder, (inspired by spellshapers) the first number in the screen is how much collums down will display text. thus, u can set up a text box using expr(. :)
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on November 29, 2005, 02:03:00 am
I believe I did mention something about this in the Aura thread a while ago...
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on November 29, 2005, 02:24:00 am
I
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on November 29, 2005, 03:12:00 am
QuoteBegin-dysfunction+29 November 2005, 8:03-->
 QUOTE (dysfunction @ 29 November 2005, 8:03) I believe I did mention something about this in the Aura thread a while ago...

uh where? I guess that might be in a topic from last year in EPS forums or Maxcoderz or I might have missed some new posts here once
Title: Undocumented TI-BASIC tricks
Post by: CDI on November 29, 2005, 10:06:00 am
Okay, here's a REAL example :P

In an old project of mine (theta twelve) I used lists for loading, so I had a variable for the 4 char listname, but! it twas a lot of code to indivudaly load EACH list into L1, so I did this

:"L10AL11AL12AL13AL13A...->Str1

then I did

:expr("/L/"+sub(Str1,L4-4,4->L/1/

basically, I took the list (named in Str1) added "/L/" (the little L for lists) and exicuted it, then stored it to L1 :D yay space savers!
Title: Undocumented TI-BASIC tricks
Post by: alex10819 on December 03, 2005, 12:33:00 pm
wow... i gotta look into using this...
Title: Undocumented TI-BASIC tricks
Post by: katmaster on December 12, 2005, 03:24:00 pm
Wow, this is pretty cool. And I understand it!!! YAY FOR UNDERSTANDING!!!
Title: Undocumented TI-BASIC tricks
Post by: rivereye on December 13, 2005, 04:12:00 am
this is going into my new RPG
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 13, 2005, 04:13:00 am
^^
Title: Undocumented TI-BASIC tricks
Post by: necro on December 13, 2005, 06:25:00 am
"WOOT" owly says...
..~'~..
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 13, 2005, 06:39:00 am
I think your attempt at imitating blub icon failed litterally here
Title: Undocumented TI-BASIC tricks
Post by: rivereye on December 13, 2005, 07:20:00 am
>(<') go blub
Title: Undocumented TI-BASIC tricks
Post by: necro on December 13, 2005, 07:51:00 am
~~>(<.)~~ blub died...

just kiding (^>)<
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 13, 2005, 08:26:00 am
I wish there was a command to store real numbers into a string- expr( converts a string into numbers (or commands), but there is no equivalent command to store a number into a string. Of course,  to store the number in, say, variable A into Str1, you could do this:

c1-->
 CODE ec1sub(Str2,A+1,1) -> Str1c2
ec2

Where Str2 is "0123456789"

But this becomes rather slow, especially if you then have to deal with two-digit or larger numbers.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 13, 2005, 10:22:00 am
hmmmm, is it possible to have a compressed save file as a string, most games i kno use lists, but if u were to use a string...
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 13, 2005, 11:52:00 am
Sure you can use strings, but it would be a bit slower to save (no real speed difference for loading), and also you only have a limited number of strings, whereas lists can have custom names.
Title: Undocumented TI-BASIC tricks
Post by: necro on December 13, 2005, 03:42:00 pm
strings should not be used to save...period.  Play another game and you'd loose all progress...L1-L9 should also not be used...
Title: Undocumented TI-BASIC tricks
Post by: CDI on December 14, 2005, 12:09:00 am
Err... L1-L6

and you could say... use a string and use a method to compress it into a list (it's not that hard :D)
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 14, 2005, 02:07:00 am
Would expr( work for RecallPic X:

"0123456789
expr("RecallPic"+sub(Ans,X+1,1
Title: Undocumented TI-BASIC tricks
Post by: rivereye on December 14, 2005, 03:44:00 am
give it a shot
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 14, 2005, 04:28:00 am
QuoteBegin-tenniskid493+14 December 2005, 8:07-->
 QUOTE (tenniskid493 @ 14 December 2005, 8:07) Would expr( work for RecallPic X:"0123456789expr("RecallPic"+sub(Ans,X+1,1

no :(
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 14, 2005, 07:30:00 am
nope....oh well.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 14, 2005, 10:30:00 am
QuoteBegin-xlibman+14 December 2005, 11:28-->
QUOTE (xlibman @ 14 December 2005, 11:28)
QuoteBegin-tenniskid493+14 December 2005, 8:07-->
 QUOTE (tenniskid493 @ 14 December 2005, 8:07) Would expr( work for RecallPic X:"0123456789expr("RecallPic"+sub(Ans,X+1,1

no :(

i'm assuming it will work with xlib's recall pic function though, real(3,X,0,1) :)
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 14, 2005, 02:12:00 pm
Yeah that should be just fine. :) The reason it won't work with RecallPic is because RecallPic VAR doesn't work, it has to be a number.
Title: Undocumented TI-BASIC tricks
Post by: CDI on December 15, 2005, 12:09:00 am
yeah, it dosen't work with like 70%+ of the commands you want it to work with
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 15, 2005, 08:18:00 am
It doesn't work for storing, for one thing:

c1-->
 CODE ec1{1,2,3} -> expr("L"+"1")c2
ec2

Doesn't work.
Title: Undocumented TI-BASIC tricks
Post by: rivereye on December 15, 2005, 10:17:00 am
that may make things a bit interesting
Title: Undocumented TI-BASIC tricks
Post by: necro on December 15, 2005, 10:40:00 am
yep, it has problems with the -> command inside of strings, something the tios is finiky about

But expr("{1,2,3}->L1 one works...so sometimes things need to get very complicated to get the desired effect

Title: Undocumented TI-BASIC tricks
Post by: tifreak on December 15, 2005, 10:51:00 am
Maybe we should just go through and list the commands that expr( doesn't like...?
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 15, 2005, 02:06:00 pm
and make a tutorial for undocumented tricks with expr( :D

there are still lot of stuff I dont know about BASIC I think :D
Title: Undocumented TI-BASIC tricks
Post by: CDI on December 16, 2005, 12:12:00 am
Well...

StorePic
RclPic
UnArchive
Archive

those are the ones I really needed... but don't work
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 16, 2005, 07:17:00 am
And of course anything with a -> in it, since Sto automatically closes parentheses or quotation marks behind it.
Title: Undocumented TI-BASIC tricks
Post by: necro on December 16, 2005, 07:10:00 pm
xlib can use the ANS command, but there is currently a nasty bug if ANS is empty when you do it
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 17, 2005, 03:14:00 am
oh I see, I assume its better to store 0 to ans by default at game startup in case
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 17, 2005, 07:46:00 am
u guys think we should change this forum so its an overall BASIC tricks forum kinda like wat UTI has? thatd be useful :)
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 17, 2005, 10:48:00 am
hmm maybe that would be a good idea. It might become a mess after a while though if we make this topic general, people would post the same tricks over and over after a while. What do you guys think we should do?
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on December 17, 2005, 11:06:00 am
what about only letting staff and managers post stuff in this section? and submissions from members and RPG coders have to be approved?

or: make a thread for gathering ideas and tricks, then make a thread where only staff can post, where the useful information is put into and explained.
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 17, 2005, 11:28:00 am
I might create a section just for BASIC and one for ASM/C, its pretty hard to decide, since not much people ask help here yet. Or I will rename this topic. Members should be able to share their ideas as well
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 17, 2005, 02:21:00 pm
I like the renaming thing and letting people post submissions about everything.  Staff/Managers could just go through and make sure no one posts the same trick twice.  I wouldn't mind keeping track of that.
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 17, 2005, 02:49:00 pm
done
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on December 18, 2005, 01:14:00 pm
moved to programming help
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on December 26, 2005, 08:20:00 am
I got a question: what does instring( do? :???:
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 26, 2005, 08:42:00 am
from wat the book saids: itll return the character position in string of the first character of substring.
instring( string, substring(, where to start looking).
id ask tifreak8x, as i saw it used in his code :) , but my guess is u can use instring to find the location of specific characters and use that for hit detection.
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on December 26, 2005, 08:56:00 am
ah I see...
Title: Undocumented TI-BASIC tricks
Post by: tifreak on December 26, 2005, 10:25:00 am
InString("ABCDEFGHI","FG" will return 6, since that is where it starts at. If you take:

If not(InString("ABCDEFGHI",sub(Str1,T-1,1):Then:etc...

This is the basic syntax of hit detection when going left for strings. Look at my walking engine for more examples on the pokemon beta. :)
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on December 26, 2005, 10:48:00 am
I
Title: Undocumented TI-BASIC tricks
Post by: tifreak on December 26, 2005, 12:58:00 pm
No problem, I hope you understand it... :D
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on December 27, 2005, 12:36:00 am
yeah, now I do >D
Title: Undocumented TI-BASIC tricks
Post by: tifreak on December 27, 2005, 02:28:00 am
Glad I could be of help. :)
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 28, 2005, 10:21:00 am
now i've got a few questions, at the UnitedTi forum, there's a lot about max speed in basic. i'd like to know if they're true.
-are if-then statements faster than if statements?
-The more free ram, the faster the prgm will run?
-too much prgm in prgm menu, will run slower?
-does optimising improve speed, ex: not(A, A=0
-is while faster or repeat loops
Thanks if u can help...:)
Title: Undocumented TI-BASIC tricks
Post by: tifreak on December 28, 2005, 11:11:00 am
If statements are faster, here is why:

Everytime the calculator sees a Then statement, or a loop, it registers how many End statements it sees. This of course takes little processing power (I think) but over a long period, it can cause a slow down, hence the memory leaks. If you just use an If statement, it doesn't need to worry about an End statement... Using an If statement only allows 1 command to be used, though, so watch yourself.

If I remember correctly, the amount of RAM does not slow down or speed up a program.

Actually, this will slow a program down a little, because that means it has to search the VAT entries for more programs.

Some optimizing does, but others can actually slow down a game.

If K=25:Then is actually faster then A-((K=25)-(K=26))->A because it is looking for the K with an If statement, but with the equation, it actually keeps doing the equation over and over. If K does not =25, then it ignores what ever comes after it. :)

I honestly don't know of a speed difference between the two, but there could be, if someone else here knows...
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 28, 2005, 11:26:00 am
Both While and Repeat Loops are equal in speed.  I believe Arcane Wizard answered that at UnitedTi.  I'll try to find the link.

EDIT:  Fixed it.
Title: Undocumented TI-BASIC tricks
Post by: tifreak on December 28, 2005, 11:33:00 am
Don't you mean while and repeat?
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 28, 2005, 11:36:00 am
Yup, sorry about that.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 28, 2005, 11:41:00 am
another questions: which are faster: subroutines or if-then statements?
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 28, 2005, 11:44:00 am
If:Then's are faster than subroutines.  However, if you are doing the same thing inside the If:Then statement multiple times, you could save a lot of space by using subroutines.  Its sort of a trade off.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 28, 2005, 11:48:00 am
anyone kno some cool optimisations using boolean logic (xor, or, and, not). one that i kno that toggles the number would be:
:N(A=0)->A
this will toggle A from 0 to the number(N). anyone kno more?
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 28, 2005, 11:53:00 am
For my walking engine, I used:

X-8(K=24)+8(K=26)->X
Y-8(K=25)+8(K=34)->Y

EDIT:  Wait nvm, your the one who gave me that.
Title: Undocumented TI-BASIC tricks
Post by: Radical Pi on December 28, 2005, 12:35:00 pm
All sorts of (), +, and = combinations can replace and/or.

Someone should make a Boolean converter for long expressions.

---EDIT---
And subtraction might be able to replace xor.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 28, 2005, 02:46:00 pm
wat do u mean? and ive got another question, will variable inputs run slower, faster, or same speed, for instance,
real(3,0,0,1
or
real(3,A,A,1   where A=0
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 28, 2005, 03:17:00 pm
I believe they run the same, however I am not positive on that.

I belive what Radical Pi meant was that instead of doing

c1-->
 CODE ec1If X=1 and Y=3Z+15->Zc2
ec2

You can do
c1
-->
 CODE ec1Z+15(X=1)(Y=3)->Zc2
ec2

If thats not what you meant, post an example.
Title: Undocumented TI-BASIC tricks
Post by: tifreak on December 29, 2005, 02:45:00 am
Like I said in my earlier post, that can actually slow the game down, if you use a lot of them, since it has to do all the calculations every loop...
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 29, 2005, 12:54:00 pm
Yeah I tried to optimize my TBS engine with those, and it ended up running at almost exactly the same speed. Booleans are faster than If:Then only if you don't have extremely complicated movement routines.
Title: Undocumented TI-BASIC tricks
Post by: Radical Pi on December 29, 2005, 01:03:00 pm
Yes, I meant exactly that.
I don't think my games are slowed by it that much, I only use it for moving left/right/up/down.
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on December 29, 2005, 03:53:00 pm
Ok, good.  I had to try to guess at what you meant.  I have a few of those in my game but, like tifreak8x said, if you use to many of them, they can do more harm than good.
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 29, 2005, 07:50:00 pm
I would love for an assembly coder to go in CalcSys or a debugger and see exactly how many clock cycles each of these commands takes and make a table, then we could just add up the cpu time required by each command in a routine to see which is faster.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on December 30, 2005, 04:52:00 am
y don't we ask that over at MC forums, maybe one of those asm gurus will do it? :)
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on December 30, 2005, 07:21:00 am
Good idea, I think I will!
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on January 04, 2006, 02:31:00 pm
ok, today in math class, had a lot of time so did some testing on speed of stuff.here's wat i got
-(everyone except me probably knew this, but ANS work faster than the number)
-Using the real number instead of variable works faster, real(0 will work faster than real(A
Title: Undocumented TI-BASIC tricks
Post by: tenniskid493 on January 04, 2006, 02:35:00 pm
Sweet.  I never knew about the Ans thing.  For the number faster than variable, it makes sense.  Instead of having to search the VAT for the variable to get the value, it has the value provided for it immediately.  Still good to know though.
Title: Undocumented TI-BASIC tricks
Post by: tifreak on January 04, 2006, 02:45:00 pm
Using ans is alright, but if you are doing any other equations, ans will be messed up. :)

Basically, ans is good for simple things (I use it for a program that has multiple routines, I just store the number to ans, call the program, then the first line in the program is Ans->L :)

That makes things a little smaller and faster...
Title: Undocumented TI-BASIC tricks
Post by: necro on January 04, 2006, 03:36:00 pm
trick to test if xlib is installed

1
real(0
not(Ans
If Ans:Pause "Install Xlib!
If Ans:Return
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 04, 2006, 03:45:00 pm
QuoteBegin-necro+4 January 2006, 21:36-->
 QUOTE (necro @ 4 January 2006, 21:36) trick to test if xlib is installed1real(0not(AnsIf Ans:Pause "Install Xlib!If Ans:Return

If you want to save a byte do

c1
-->
 CODE ec11real(0If not(Ans:Pause "Install Xlib!If not(Ans:Returnc2
ec2
Doesn't save much but hey 1 byte is a byte!
Title: Undocumented TI-BASIC tricks
Post by: tifreak on January 04, 2006, 04:02:00 pm
Check the code, it produces different results. Necro's produces 1, where yours produces 0.
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 04, 2006, 04:05:00 pm
QuoteBegin-tifreak8x+4 January 2006, 22:02-->
 QUOTE (tifreak8x @ 4 January 2006, 22:02) Check the code, it produces different results. Necro's produces 1, where yours produces 0.

Yes but it has the same effect....
Title: Undocumented TI-BASIC tricks
Post by: necro on January 04, 2006, 04:21:00 pm
yes, you unrapped a line break and as such, "not(...:not(..." is better than an "not(Ans:"...if I had a third line of conditionals in there, it would be better my way though
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 04, 2006, 04:27:00 pm
QuoteBegin-necro+4 January 2006, 22:21-->
 QUOTE (necro @ 4 January 2006, 22:21) yes, you unrapped a line break and as such, "not(...:not(..." is better than an "not(Ans:"...if I had a third line of conditionals in there, it would be better my way though

But there is a problem with both of ours, when you run it if xlib isn't installed then it says "Install Xlib!" but now the Ans is "Install Xlib!" so it receives a DATA TYPE error. So in order to stop that just place the first1 in a If Then
c1
-->
 CODE ec11real(0If not(Ans:ThenPause "Install Xlib!ReturnEndc2
ec2
Then just place the rest of the code after End (The rest of the program).
Title: Undocumented TI-BASIC tricks
Post by: necro on January 04, 2006, 04:58:00 pm
Indeed...but what about the whole Kitten-kaboodale (sp?)

:1
:real(0
:If not(Ans
:Then
:ClrHome
:Disp "PLEASE INSTAL XLIB BEFORE TRYING TO RUN THIS GAME
:Pause
:End
:If not(Ans
:Stop
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 04, 2006, 05:51:00 pm
QuoteBegin-necro+4 January 2006, 22:58-->
 QUOTE (necro @ 4 January 2006, 22:58) Indeed...but what about the whole Kitten-kaboodale (sp?):1 :real(0 :If not(Ans :Then :ClrHome :Disp "PLEASE INSTAL XLIB BEFORE TRYING TO RUN THIS GAME :Pause:End :If not(Ans :Stop

One thing disp doesn't wrap :P.

c1
-->
 CODE ec1:1 :real(0 :If not(Ans :Then :ClrHome :Output(1,1,"PLEASE INSTAL XLIB BEFORE TRYING TO RUN THIS GAME :Pause:stop:Endc2
ec2
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on January 05, 2006, 07:39:00 am
Also, you misspelled Install.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on January 06, 2006, 05:43:00 pm
that's nice to know, Tr1pl1ea should include that peice of code in the readme so all games with xlib uses it :)
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 06, 2006, 05:47:00 pm
QuoteBegin-dragon__lance+6 January 2006, 23:43-->
 QUOTE (dragon__lance @ 6 January 2006, 23:43) that's nice to know, Tr1pl1ea should include that peice of code in the readme so all games with xlib uses it :)

Well if xlib gets turned into a basic xlib game app it will not need the code above.
Title: Undocumented TI-BASIC tricks
Post by: necro on January 06, 2006, 05:59:00 pm
I guess that is a vote for my proposal of making an xlib shell?
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 06, 2006, 06:26:00 pm
QuoteBegin-necro+6 January 2006, 23:59-->
 QUOTE (necro @ 6 January 2006, 23:59) I guess that is a vote for my proposal of making an xlib shell?

Oh well I have been for it just didn't want Pat getting tired of working on it.
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on January 12, 2006, 03:52:00 pm
Apparently expr( doesn't work with the Goto command either, that's a shame.
Title: Undocumented TI-BASIC tricks
Post by: DJ Omnimaga on January 12, 2006, 04:17:00 pm
too bad :(

at least does it work with useful commands?
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on January 12, 2006, 04:22:00 pm
It does work with many useful commands.

On a slightly different topic, does anyone know a way in which I can jump to a section of program according to the number stored in a variable? Say variable A=5, is there a way to then Goto 5, or Goto 27 if A=27, etc?
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 12, 2006, 05:05:00 pm
No but you could do

c1-->
 CODE ec1AIf Ans=1:Goto 1If Ans=2:Goto 2If Ans=3:Goto 3....etcc2
ec2
Title: Undocumented TI-BASIC tricks
Post by: tifreak on January 12, 2006, 05:09:00 pm
Depends on what you are doing, but you can use While statments like goto/lbl commands, by manipulating the variable values... :)

Just keep everything in one big loop, say like this:

While W>0
All your fancy While commands go here
End
Return

And if you want out of the loops, just delvar W... :)

Make sense?
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 12, 2006, 06:24:00 pm
QuoteBegin-tifreak8x+12 January 2006, 23:09-->
 QUOTE (tifreak8x @ 12 January 2006, 23:09) Depends on what you are doing, but you can use While statments like goto/lbl commands, by manipulating the variable values... :)Just keep everything in one big loop, say like this:While W>0All your fancy While commands go hereEndReturnAnd if you want out of the loops, just delvar W... :)Make sense?

Yeah and no memory leaks :P.
Title: Undocumented TI-BASIC tricks
Post by: CDI on January 13, 2006, 12:04:00 am
my 2 cents...

int(log(#)+1 = How many digits the number is

example

Text(0,0,sub(" 00000000",1,8-int(log(S)+1)),S

will return an 8 digit number at 0,0 on the GS no matter what (if S's digits are less than 8)
Title: Undocumented TI-BASIC tricks
Post by: dysfunction on January 13, 2006, 12:38:00 pm
That's very useful, thanks! I remember I was looking for something that would do that a while ago, but I don't remember exactly what for... but I'll remember that.
Title: Undocumented TI-BASIC tricks
Post by: dragon__lance on January 13, 2006, 04:05:00 pm
QuoteBegin-CDI+13 January 2006, 7:04-->
 QUOTE (CDI @ 13 January 2006, 7:04) my 2 cents...int(log(#)+1 = How many digits the number isexampleText(0,0,sub(" 00000000",1,8-int(log(S)+1)),Swill return an 8 digit number at 0,0 on the GS no matter what (if S's digits are less than 8)

nice trick, i'll probably use it sometime  >D i may sound so noobish for asking this, but wat exactly is a memory leak? just when u use lables/ gotos and amount of free mem goes down?
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 13, 2006, 04:59:00 pm
QuoteBegin-dragon__lance+13 January 2006, 22:05-->
QUOTE (dragon__lance @ 13 January 2006, 22:05)
QuoteBegin-CDI+13 January 2006, 7:04-->
 QUOTE (CDI @ 13 January 2006, 7:04) my 2 cents...int(log(#)+1 = How many digits the number isexampleText(0,0,sub(" 00000000",1,8-int(log(S)+1)),Swill return an 8 digit number at 0,0 on the GS no matter what (if S's digits are less than 8)

nice trick, i'll probably use it sometime  >D i may sound so noobish for asking this, but wat exactly is a memory leak? just when u use lables/ gotos and amount of free mem goes down?

I seen this on maxcoderz before and is nice, a memory leak I believe is when you use a loop of some kind like while or repeat, then within the loop use an exit which isn't from the main loop.
c1
-->
 CODE ec1Lbl 1While K!=105getkey->Kif Ans=21:Goto 1endc2
ec2
This would give a bad memory leak (take up ram space I believe) if 2nd is pressed within the loop.
Title: Undocumented TI-BASIC tricks
Post by: tifreak on January 13, 2006, 05:32:00 pm
A memory leak is when the calc encounters a command that requires an End statement, but never reaches it. The reason is it keeps track of how many Ends there should be, and that eats up memory...
Title: Undocumented TI-BASIC tricks
Post by: Spellshaper on January 14, 2006, 01:19:00 am
got a question:

Is there a difference between int( and iPart( ?

cause it seems to me that they give the same reults...
Title: Undocumented TI-BASIC tricks
Post by: CDI on January 14, 2006, 02:16:00 am
hmm... isn't int( for positive numbers? and iPart( for anything?
Title: Undocumented TI-BASIC tricks
Post by: BCTurk on January 14, 2006, 03:16:00 am
CDI is correct.
Title: Undocumented TI-BASIC tricks
Post by: MathStuf on January 14, 2006, 06:56:00 am
With the bases, here's one for the maximum number of digits in any base from any base (b is old base, n is old number, c is new base):
c1-->
 CODE ec1iPart(dim(n)*ln(b)/ln(c)+1)c2
ec2

QuoteBegin-Spellshaper+14 January 2006, 7:19
-->
 QUOTE (Spellshaper @ 14 January 2006, 7:19) got a question:Is there a difference between int( and iPart( ?cause it seems to me that they give the same reults...

iPart( goes towards 0, int( goes to the next lowest integer.
Title: Undocumented TI-BASIC tricks
Post by: CDI on January 14, 2006, 09:41:00 am
QuoteBegin-MathStuf+14 January 2006, 13:56-->
QUOTE (MathStuf @ 14 January 2006, 13:56)
With the bases, here's one for the maximum number of digits in any base from any base (b is old base, n is old number, c is new base):
c1-->
 CODE ec1iPart(dim(n)*ln(b)/ln(c)+1)c2
ec2

so if I do iPart(dim(42)*ln(13)/ln(10)+1) what will that do again?
Title: Undocumented TI-BASIC tricks
Post by: MathStuf on January 14, 2006, 11:32:00 am
QuoteBegin-CDI+14 January 2006, 15:41-->
QUOTE (CDI @ 14 January 2006, 15:41)
QuoteBegin-MathStuf+14 January 2006, 13:56-->
QUOTE (MathStuf @ 14 January 2006, 13:56)
With the bases, here's one for the maximum number of digits in any base from any base (b is old base, n is old number, c is new base):
c1-->
 CODE ec1iPart(dim(n)*ln(b)/ln(c)+1)c2
ec2

so if I do iPart(dim(42)*ln(13)/ln(10)+1) what will that do again?

That will return the maximum amount of digits in base 10 that a 42 digit number in base 13 can take up (which is 47). But n should be either a string (change to length( in that case) or a list for dim( to work properly).
Title: Undocumented TI-BASIC tricks
Post by: kalan_vod on January 31, 2006, 08:07:00 am
Thanks for the "please install xLIB first thing" I just used it in my MS clone.