# TI-BASIC - Strings



## OnePostWonder (Mar 23, 2012)

Programming has been an on-and-off interest of mine for a while, so I've begun playing with it a bit recently.  I wanted something that I could just jump right into and so I grabbed my TI-83+.

My question is this:  Why does having the user input a string to be stored in variable "A" result in an improper function IF/THEN/ELSE?

Input: "Are you sitting?",A
If A=No
Then
Disp "Please stand"
Else
Disp "Okay"

When written like this, "Please stand" is still displayed when something other than "No" is input.

If I make use of Str0-Str9 under VARS, there is no issue.

Input: "Are you sitting?",Str0
If Str0="No"
Then
Disp "Please stand"
Else
Disp "Okay"

Is this simply a matter of how variables work with TI-BASIC?


----------



## Kreij (Mar 23, 2012)

Looks like there are 10 built in string variables in TI-Basic 83. Str0 through Str9

This site looks pretty good as a reference


----------



## OnePostWonder (Mar 23, 2012)

Kreij said:


> Looks like there are 10 built in string variables in TI-Basic 83. Str0 through Str9
> 
> This site looks pretty good as a reference



Yeah, I visited several websites (including that one) and none gave me the answer I'm looking for.

What you're implying is that the input to variables A-Z can not function the same as input to variables Str0-9?


----------



## Kreij (Mar 23, 2012)

Quite possible. Since it's a calculator, those may be reserved for numbers.
I'm no expert on TI-Basic as I just quick googled it too. lol


----------



## OnePostWonder (Mar 23, 2012)

Kreij said:


> Quite possible. Since it's a calculator, those may be reserved for numbers.
> I'm no expert on TI-Basic as I just quick googled it too. lol



Sounds good to me, chief.  Actually, one of the things you said there gave me another way to search Google for it.

Thanks.


----------



## Kreij (Mar 23, 2012)

I did some programming on TI calculators, but that was 30 years ago when the little printer for it cost like $300 or more. lol


----------



## OnePostWonder (Mar 23, 2012)

Kreij said:


> I did some programming on TI calculators, but that was 30 years ago when the little printer for it cost like $300 or more. lol



Hehe...

So I used a different search phrases on Google that led me to the one you listed:

TI-BASIC - Variable Types

That pretty much concurs with what you said and what I've been suspecting.


----------



## Kreij (Mar 23, 2012)

Yeah, it looks like ALL of the variables names (numeric, string, lists, etc.) are predefined and you can't just make them up on your own.


----------



## FordGT90Concept (Mar 23, 2012)

In my TI-89 manual, it looks like you should be using InputStr and not Input.  I quote: "*Note:* The difference between *Input* and *InputStr* is that *InputStr* always stores the result as a string so that "" are not required."


----------



## OnePostWonder (Mar 24, 2012)

FordGT90Concept said:


> In my TI-89 manual, it looks like you should be using InputStr and not Input.  I quote: "*Note:* The difference between *Input* and *InputStr* is that *InputStr* always stores the result as a string so that "" are not required."



I checked the catalog on the TI-83 Plus and it does have *inString*, so I'll have to give that a try.


----------



## FordGT90Concept (Mar 24, 2012)

inString is the same as strpos in many languages or String.IndexOf() in .NET.  That is, it returns the index of a string inside a string (-1 if not found).  For example inString("Hello World!", "World") would return 6.


----------



## OnePostWonder (Mar 24, 2012)

If that's the case, then TI-83 Plus doesn't have *InputStr*.


----------



## FordGT90Concept (Mar 24, 2012)

Then I have to assume Kreij was correct that the variable types on TI-83/84 are limited.  TI-89 may be more flexible.


----------



## Kreij (Mar 24, 2012)

Yes, inString( for the TI-83 is as you describe Ford ...

inString("Kreij", "K
returns a value of 1 (strings are not zero based character arrays).

There is no "inputString" function

If you want, OPW, put away the calculator, load up C# Express on your rig and we'll be happy to teach you to program in that.


----------



## OnePostWonder (Mar 24, 2012)

Oh my...can I get a rain check on that?  I know you're an experienced programmer and I'd love the opportunity, but right now I've got myself going down other avenues.

Anyway, thank you very much for the offer.

I do have a quick question though; I've heard it said a number of places that in order to be good at programming C (possibly C++), you need to be good with Calculus.  Do you agree with that?


----------



## Kreij (Mar 24, 2012)

Only if the program(s) you are writing requires you to use calculus. If not, you don't need to know calculus at all.

The reason I suggested C# is that it's not as esoteric as C++ and easier to learn (but not great if you are doing really low level stuff).

One rain check sent. 
If you ever want to give any language a try, just start a thread and we'll be happy to assist.
There are a lot of good coders here on TPU that are very willing to help out.


----------

