So I've been programming for a while now, but I have encountered a problem I've never seen before. I have a solve( command but it's giving me headaches. I've gazillion-checked it, but it gives me a Syntax Error. Unfortunately though, the 2: Goto option goes to the Home screen, showing prgmSOLVER (the program is named SOLVER). What does this mean and how can I fix it? Any help is greatly appreciated.

Is your program in Assembly? That's the only thing I can think of.

```
:ClrHome:Disp "HOW DOES A","MATHEMATICIAN","LOSE WEIGHT?
:Pause "
:Pause "BINOMIALS!
:Pause "(BUY NO MEALS)":ClrHome
```

No, it's written in pure TI-Basic.

I'll give some more details that may help.

I'm creating a sort of thingamabobber that executes commands that you input. So if you input "Solve 4x-2" it should show you the answer for X (I'll add the guess function later). So this input is saved to a string (Str9 in this case) and then I use the sub( command to find out what the command was. So I use sub(Str9,1,5)="Solve" to check if the command is Solve. Then, I do solve(expr(sub(Str9,6,length(Str9)-6)),X,0) to solve it. Unfortunately, when I try to solve it the program crashes with a Syntax Error and 2:Goto indicates that prgmSOLVER on the home screen contains a syntax error.

Maybe you could provide us some code? :)

Get futuristicOS 8 for your TI-84+

Learn more about futuristicOS 8

This is the piece of code I'm struggling with:

```
Input Str9
If length(Str9)>=5 //>= is obviously the is greater than or equal to sign.
Then
If sub(Str9,1,5)="Solve"
Then
solve(expr(sub(Str9,6,length(Str9)-6)),X,0)->A //-> is the Store command.
Disp A
End
End
```

So the idea is that when you input "Solve 4X-2", the sub( commands will sub the "Solve " part away and put the rest inside the solve(expr(…),X,0) construction. Then A will be displayed. The reason I'm checking for "Solve" to be present in the input is because I want to add more commands in the future.

No, this makes it so that you solve the actual VALUE of the string for 0.

Example: If Str9 is "Solve 4X+9", then the expr( result would be the actual variable value of X times 4 plus 9.

```
:ClrHome:Disp "HOW DOES A","MATHEMATICIAN","LOSE WEIGHT?
:Pause "
:Pause "BINOMIALS!
:Pause "(BUY NO MEALS)":ClrHome
```

so building off of josiah, you dont need the expr(, in fact that will hurt it since it is using the number stored in the variable x. here should be the the command:

`solve(sub(Str9,6,length(Str9)-6)),X, (an guess like 0 or 1 or -1(it'll find the closest number to it)), (your boundary, usually {-E99, E99})→ A`

just remember this will output only once so you would want to change the guess if you have multiple roots.

and if this is for yourself, the equation solver is built into the calculator under MATH at the very bottom.

*The Silver Phantom welcomes you*

Your problem(s) are rather basic.

1. Using solve as a command is a good idea. But you need to consider that you will need to type the above example as "SOLVE4X+9", or delete the space.

2. When trying out "SOLVEX+22" you will get X=-2. This means that you have to decrement length(Str9)-6 to length(Str9)-5. With the above example you get 4X+ to solve, which causes the error.

3. Look here what I found for you. When developing futuristicOS 8 I also wanted to include a solver. This is what came out in the futuristicOS 8 beta forum. You can add support for equations or auto detect whether there is a "=" char or not and thus handle input as expression or equation.

Get futuristicOS 8 for your TI-84+

Learn more about futuristicOS 8

that means your sub( should be if your having a space

`sub(Str9, 7, length(Str9)-6`

as for the "=", what you can do is simply make it equal to zero.

```
if inString(Str9, "="
then
inString(Str9,"="→B
sub(Str9,1, B-1) + "-(" + sub(Str9,B+1, length(Str9)-B-1→Str9
end
```

with that you would get "Solve " with an expression instead of an equation

so put it all together:

```
Input Str9
If length(Str9)≥5:Then //simple optimizations, no real purpose
If not(sub(Str9,1,6)="Solve "):Then
sub(Str9, 7, length(Str9)-6→Str9 //makes it much easier to deal with the expression itself instead of a "solve "
if inString(Str9, "="
then
inString(Str9,"="→B
sub(Str9,1, B-1) + "-(" + sub(Str9,B+1, length(Str9)-B-1→Str9 //turns it into an expression
end
solve(Str9,X, 0,{-E99, E99→ A
Disp A
End
End
```

of course change the length(Str9)-6 if you are not using a space

*The Silver Phantom welcomes you*

Problem solved! Thanks people! I was already thinking that I was messing up the expr( thingamabobber, but I was set on another track because the 2:Goto option showed prgmSOLVER was an error.

Alright, not quite there.

When doing

`solve(sub(Str9,7,length(Str9)-6),X,0)`

With Str9 being "Solve 2X-4"

It gives me ERR: BAD GUESS

As far as the documentation goes, this means that either on 0 there is no value or 0 isn't within bounds.

But since the bounds aren't specified, it should default to {-1E99,1E99}, which contains 0, and if we fill

in 0 in the equation we get

2X-4=

2*0-4=

0-4=

-4=

Which isn't exactly a nonexistant value.

How do I get this fixed up?

when you use the solve, it isnt doing this:

2(0) -4 =

its doing:

2(0) -4=0

its always equating to 0

and we all forgot a big problem, solve( doesnt take a string…

thankfully we can utilize the Y= button

so:

```
sub(Str9,7,length(Str9)-6→ Str9
Str9 → Y1
solve(Y1,X,0)
```

*The Silver Phantom welcomes you*

Okay, you lost me, can you explain?

*The Silver Phantom welcomes you*

Alright, this is getting confusing. You both agree that the Str9 is not accepted as an equation. But then futuristic says that using Expr( on Str9 will work, whilst Silver Phantom says that won't work, since it would then load the value of X instead of solving X.

Could you please agree on this? That'd be great.

Well, I told you to have a look at the other forum, so now I'll post all of the code.

```
ClrHome
Input Str9
If "SOLVE"=sub(Str9,1,5
Then
sub(Str9,7,length(Str9)-6→Str9
If inString(Str9,"=
Then
solve(expr(sub(Str9,1,inString(Str9,"=")-1)+"-("+sub(Str9,inString(Str9,"=")+1,length(Str9)-inString(Str9,"="))),X,1→A
Else
solve(expr(Str9→A
End
Disp "X=",A
End
```

Maybe something like this?

EDIT: For the expr, I think that it doesn't really solve the string but rather converts it into an expression with the variables remaining variables. Otherwise I wouldn't know how to explain why this code works (didn't test it so far).

Get futuristicOS 8 for your TI-84+

Learn more about futuristicOS 8

Ah, sorry, I skimmed through the previous posts so I probably missed it.

Ya that works, only thing I would look out for is the else part, I get a syntax error

As far as speed goes, I can't tell the difference. Only difference is bytes and method. So it comes down to saving space but using the functions or being clean but with the cost of space.

*The Silver Phantom welcomes you*

Alright, I got my version running now. Thanks everyone!