ticalc.org
Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Archives :: News :: The Complete BASIC Optimization Guide

The Complete BASIC Optimization Guide
Posted by Michael on 12 July 2006, 04:47 GMT

Arthur O'Dwyer has recently updated his classic TI-83 BASIC programming optimization guide, The Complete TI-83 Basic Optimization Guide. Version 2 features a wealth of new information regarding all facets of BASIC optimization. After perusing through this latest version for this news article, I would highly recommend it to all serious BASIC programmers. It is certain to mention an optimization trick that you've never thought of.

  Reply to this article


The comments below are written by ticalc.org visitors. Their views are not necessarily those of ticalc.org, and ticalc.org takes no responsibility for their content.


Re: The Complete BASIC Optimization Guide
burntfuse  Account Info
(Web Page)

I'm an assembly programmer (and a sort of inactive one at the moment), but these BASIC optimization guides are still interesting to read, and I hope to see these techniques in many new programs.

Reply to this comment    12 July 2006, 22:04 GMT

Re: The Complete BASIC Optimization Guide
tifreak8x  Account Info
(Web Page)

This tutorial was actually submitted to me to make into html for my tutorials archive... (Click link above)

Give me a few days, and I should have them both completed. I am almost done with the first.

Reply to this comment    13 July 2006, 00:27 GMT

Re: The Complete BASIC Optimization Guide
ericva1992 Account Info
(Web Page)

This guide is nice! I knew some of the stuff, but learned a lot. I'm trying to get away from basic, but right now it's still the best choice. Just wanted to point out some things I saw:

1. You can put the \->\ character in a string, although it's sorta hard: type \->\ on the homescreen, hit enter, you'll get an error, just clear it out. Go into your Y=, in Y1 push 2nd-Entries to recall the last entry, which is \->\. Then just use str>equ. Doesn't cause any crashes, i think...

There is a more efficient way to do num>string using the linear regression, but i can't remember it right now

There is some bug in the 83+ OS that screws up using lowercase letters in inString(. Can't really figure it out.

Reply to this comment    13 July 2006, 19:53 GMT


Re: Re: The Complete BASIC Optimization Guide
calkfreak83  Account Info
(Web Page)

Hmm.. I didn't know that about getting the store symbol into a string like that.. of course I can't think of a way to be able to do that from a program, but still, nonetheless, it can be done. However, if you do have the -> token in a string and you try to do an expr() function, it will give you an ERR: SYNTAX.. and of course you cant graph the equation.. the only way you could use this in a program is for the string to exist on the calculator before execution of the program.. and all you could do with it was display it..

I made up my own Number to String algorithm a while back, but it only worked as long as there were no Es or decimals in the number.. the LinReg method works with both of these, and they are they only 2 ways that I know of unless you want to get into ASM libs..

Also, I've never encountered a bug with InString() and lowercase letters.. I use them together all the time..

Reply to this comment    14 July 2006, 02:19 GMT

Re: Re: Re: The Complete BASIC Optimization Guide
yellowPig Account Info

>it only worked as long as there were no Es or decimals in the number

You /could/ use if/then.... ;)

Reply to this comment    14 July 2006, 04:09 GMT


Re: Re: Re: Re: The Complete BASIC Optimization Guide
ericva1992  Account Info
(Web Page)

:Ans->\theta\
:{0,\theta\->LĀ1
:{\theta\,0->L2
:LinReg(ax+b) \u\
:Equ>String(\u\,Str0
:sub(Str0,5,length(Str0)-4

It's hard to get smaller than that.
Handles decimals, Es, and negatives
But, for example, if you type 1E12 it will return 1000000000000 (equivalent). 1E15 and higher will return the number with the E in it.

The \u\ is the weird lowercase u equation variable you get by hitting second-7

Reply to this comment    16 July 2006, 00:30 GMT


Re: Re: Re: Re: Re: The Complete BASIC Optimization Guide
StarSoft  Account Info
(Web Page)

That's pretty creative, I never thought to use the built in math functions to convert it in that way. I have a whole complicated program using logarithms to go digit-by-digit (and still never built in provisions for decimals or Es).

Reply to this comment    17 July 2006, 13:00 GMT


Re: Re: Re: The Complete BASIC Optimization Guide
Arthur_ODwyer Account Info
(Web Page)

"However, if you do have the -> token in a string and you try to do an expr() function, it will give you an ERR: SYNTAX.."

That's just because you can't evaluate statements with expr(, period. expr( only works on expressions.

One thing I don't think it's possible to do in Basic, for example, is to ask the user for a variable or list name and then store new data into it. That's a pity; the most obvious application is "Enter a list name for your saved game..." Please, somebody, prove me wrong.

Also on the topic of expr(string), I just noticed that if Str1 contains "ABC" (including the quotes, via Equ>String or Input), then expr(Str1) gives an error, instead of returning the string ABC. That's odd.

One erratum to the Guide so far: In Section 5, the line "0\->\Xmin: 94\->\Xmax" should be replaced with "0\->\Xmin: 1\->\\DeltaX\". I plan to update the Guide in a couple of months, once I've had a chance to collect any more errata.

Thanks for all the comments (and praise :) !

Final blatant plug: Play and port my games! (Hold'em, World Empire, Dark Mage, Castle Adventure, and a new version of Hunt the Wumpus coming soon.)

Reply to this comment    14 July 2006, 21:37 GMT

Re: Re: Re: Re: The Complete BASIC Optimization Guide
ericva1992  Account Info
(Web Page)

Hey I'm just making a point! You can get -> into a string and that's that. And there is a bug with lowercase letters, but it rarely happens (only in one of my programs) and I can't seem to duplicate it. Whenever the archivers get around to uploading JukeBox 2, try out OLDJBCONV and enter a lowercase title. It'll return 0, even if the lowercase letter is in the InString string.

Reply to this comment    16 July 2006, 00:07 GMT


Re: Re: Re: Re: Re: The Complete BASIC Optimization Guide
ericva1992  Account Info
(Web Page)

I dunno if someone has found this out before, but it seems really weird to me. There are two ways of storing the "a" token (lowercase a), both are 2 bytes.

BB B0 <Normal way, you get this when you type Alpha-Alpha-a

62 16 <Weird way, no clue how I got it, probably from sending/recieving to my computer

Download JukeBox 2 (83+ BASIC Programs) and look at the hex for STR2LIST (DevTools). You'll see that in my InString string I use 62 16 for a, 62 17 for b, etc. But InString only cares about hex values, and since BB B0 is not the same as 62 16, it doesn't find it. This makes it possible to type
InString("a","a
and have it return 0.

Reply to this comment    18 July 2006, 22:00 GMT


Re: The Complete BASIC Optimization Guide
Arthur_ODwyer Account Info
(Web Page)

The "BB B0" small 'a' is specific to the TI-83+ and higher models; the TI-83 can't do lowercase letters with Alpha-Alpha.

The "62 16" small 'a' is the 'a' used by LinReg and the other regressions; it's accessed through VARS->Statistics...->EQ on the TI-83.

HTH,
-Arthur

Reply to this comment    19 July 2006, 18:09 GMT


Re: Re: The Complete BASIC Optimization Guide
ericva1992  Account Info
(Web Page)

OOOOoh

Yea I've seen those little letters before without alpha-alpha, but never thought of them a different token value. I thought all 2-byte tokens started with BB.

Reply to this comment    19 July 2006, 19:59 GMT

Re: Re: Re: Re: The Complete BASIC Optimization Guide
ericva1992  Account Info
(Web Page)

Maybe somebody nice will make an ASM program that does that :) or at least a string of hex codes for Omnicalc's ExecAsm(

Reply to this comment    17 July 2006, 02:13 GMT

Re: Re: Re: Re: The Complete BASIC Optimization Guide
StarSoft  Account Info
(Web Page)

Another error, I noticed that in section 4 you say:
"You can create a new user-defined list, such as \L\A or
\L\MYPROG, and use the list elements as temporary storage."

MYPROG would be an invalid list name, as the limit is 5 characters for list names.

Great guide. Personally, I'd like if the programs used as demonstrations were also given in a more readable form. I usually don't focus on optimization until once a program is finished (since it would be VERY hard to debug code that is optimized for space). Having to mentally think through all the uses of Ans, etc is a little difficult when trying to follow a program.

Reply to this comment    17 July 2006, 14:35 GMT


Re: Re: Re: Re: The Complete BASIC Optimization Guide
Snave2000  Account Info

> One thing I don't think it's possible to do in Basic, for example, is to ask the user for a variable or list name and then store new data into it. That's a pity; the most obvious application is "Enter a list name for your saved game..." Please, somebody, prove me wrong.

I think you're right. When I first read your comment, I immediately whipped out my 84+ SE...only to prove that it can't work. You can enter the name of the list as a string, but there's no way to actually store data to it (since the name is a string). What a pity indeed!

Reply to this comment    17 July 2006, 15:55 GMT

Re: The Complete BASIC Optimization Guide
Weregoose Account Info
(Web Page)

The article is indeed brilliant. I insist that anyone who already calls himself competent in TI-Basic WILL learn from this guide. Read through it twice at least, and experiment always. It's ultimately one of the better paths to become the more advanced TI-Basic programmer you seek in yourself. Go at itóread the darned thing. No one's holding you back but the person sitting down in your chair. :)

ĖGoose

Reply to this comment    13 July 2006, 20:31 GMT

Re: Re: The Complete BASIC Optimization Guide
Matt M Account Info

I have to agree -- I thought I knew almost every trick of use and I found that most of it was new to me

Reply to this comment    13 July 2006, 20:47 GMT


Re: Re: The Complete BASIC Optimization Guide
Kevin Ouellet Account Info
(Web Page)

I have been coding TI-83+ BASIC for more than 5 years and kalan_vod is optimising metroid II right now >.<

Reply to this comment    14 July 2006, 00:27 GMT


Re: Re: Re: The Complete BASIC Optimization Guide
kalan_vod  Account Info
(Web Page)

I am? O.O!

Yeah, without Kenny I would not have learned what I have in basic. I appreciate the guide, and the times are very helpful.

Reply to this comment    14 July 2006, 06:41 GMT

Re: The Complete BASIC Optimization Guide
Lewk Of Serthic  Account Info

I've seen optimization guides before, but none as comprehensive as this, great job!

Reply to this comment    14 July 2006, 14:16 GMT

Re: The Complete BASIC Optimization Guide
Jonathan Pezzino  Account Info
(Web Page)

It's great to see ticalc.org giving attention to BASIC Optimization! Many novice programmers have never even heard of the concept, and I think everybody benefits when these members improve their skills. It's also a stimulating read for those of us who are convinced we mastered BASIC long ago ;-).

This should be a good incentive to update the 1337 Guide!

Reply to this comment    15 July 2006, 17:36 GMT

1  2  3  

You can change the number of comments per page in Account Preferences.

  Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer