0

Not sure why but my program keeps terminating. I removed all Stop functions. Here's the code:

    :Lbl A
    :ClrHome
    :Prompt A
    :ClrHome
    :Prompt B
    :ClrHome
    :Prompt C
    :Disp "B^2-4AC=" (Program stops here for some reason)
    :If D<0
    :Then
    :ClrHome
    :Disp "Nonreal answer"
    :"..."
    :Pause
    :ClrHome
    :Menu("Menu", "Restart", D"
    :Lbl prgmQUADSTE3
    :Lbl A
    :...
theK_S
  • 45
  • 2
  • 12
  • How do you know your program is stopping **right** there? – eboix Apr 24 '13 at 20:34
  • 3
    I'm no expert but this line -> :Menu("Menu", "Restart", D" <- sure looks syntactically bad – Jonesopolis Apr 24 '13 at 20:34
  • Also, you have a bug. You are writing "B^2-4AC" to the screen, but you never store its value in D. In addition, you ClrHome before you write whether or not it is real. – eboix Apr 24 '13 at 20:35
  • Right after the program displays "B^2-4AC=" and the answer, it displays "Done" and terminates the program. Also, forgot to put the value for D in the code up there. – theK_S Apr 25 '13 at 00:51
  • It seems like D ends up not being less than 0 – dgund May 18 '13 at 16:45

1 Answers1

1

I suspect that your program is exiting because you never use "End" to end your if statement. Unless the var D is less than zero, the program WILL EXIT on that If statement, because every line after that is considered part of the If statement and is therefore ignored. Use the "End" token to specify what lines are part of the If statement and what lines are not. I suspect you want:

:If D<0
:Then
:ClrHome
:Disp "Nonreal answer"
:"..."
:Pause
:ClrHome
:Menu("Menu", "Restart", D"
:End
:...

Or something similar to that. I am 99% certain that this is your problem.

The other things to note is that you declare Lbl A twice. In TI-BASIC, when you use Goto A, the calculator starts at the beginning of the program and looks for the first "Lbl A", which is in this case, the first line. Secondly, in your menu, by putting that argument "D" after your one and only option, once the user clicks on that, you're going to label D, which does not exist, therefore, the program will exit with the error Lbl.

This line: Lbl prgmQUADSTE3

Is not a valid line. I'm assuming you want the program to either call itself or call a seperate program. If the program is calling itself, I suggest you instead use a Goto statement, as your method will cause something similar to a stack overflow/memory leak.

Roguebantha
  • 814
  • 4
  • 19