TIB: Re: Re: TI-Basic Digest V1 #508


[Prev][Next][Index][Thread]

TIB: Re: Re: TI-Basic Digest V1 #508




> >>Philipp Keller said:
> And, you sould try to avoid 'Goto's alltogether!
>
> How, and why? What sorts of spped increases can be found? I
willadmit,
> GOTO's are awful, and in C++, I wouldn't be caught dead with one.
But
> what are the alternatives in BASIC?

You can usually get around it by using different types of loops. The
only time I use gotos is for programs that don't require speed (I have
big progs that are really a bunch of small ones accessed by a menu
system) Besides, it's often a lot simpler just to use a few
if/then/else/end loops than go back and forth to write code for the
two parts of the program.

The speed difference can be neglectible or disastrous, depending on
how much space is between the "Goto" and the label. When a goto is
encountered, the calc searches for the label starting at that point by
reading every line in the program.

> Now then, is there anyway to store a matrix WITHIN a program?
Basically
> so the high scores part of a game does not need a separate matrix
"file"
> as well?

On the '86, I just do the following:

[[1,2,3][4,5,6][7,8,9]]  ->  MATRIX

or

randM(3,3)  ->  MATRIX    (this is obviously very slow because it has
to generate the random numbers)

What calc do you have?

Anyway, hope that helped,

Philipp Keller






Follow-Ups: References: