Would you be interested in a terminal based program?
Yes
 57%  [ 4 ]
Maybe
 28%  [ 2 ]
No
 14%  [ 1 ]
Total Votes : 7

Hi guys! I'm new to the forums and I have a TI Basic problem.
I currently trying to program a terminal, and I'm using an if then checking
system that works like so:


Code:
Lbl A
Input ">",Str0
If Str0="PHRASE"
Commands here
If Str0="Exit"
ClrHome
Return
End:Goto A


The problem is that whenever I enter a command, it skips overall the code after the input and ends itself. can anyone help me? I have a CSE calc, if that helps.

Also, is there anything i could add later in Doors that would make this a useful program?
Use a While loop
Ephriam, can you explain how a While loop will be beneficial here?

Str0 is being matched to the string PHRASE. If Str0 equals "sudo" it won't equal PHRASE and thus, won't execute any of the commands. Don't forget that you also need Then statements if you plan to execute more than one line of code after an IF.
comicIDIOT wrote:
Ephriam, can you explain how a While loop will be beneficial here?

Str0 is being matched to the string PHRASE. If Str0 equals "sudo" it won't equal PHRASE and thus, won't execute any of the commands. Don't forget that you also need Then statements if you plan to execute more than one line of code after an IF.


I thought ByteStorm was trying to make a loop
Hello ByteStorm, and welcome to Cemetech! It looks like you have the return within your main loop, which is always causing it to exit. Here's a fixed version.

Also notice that a while loop is used instead. A while loop continues until the while conditional is true, so when you enter in an EXIT, it exits the loop.


Code:
" ->Str0
While Str0!="EXIT
Input ">",Str0
If Str0="PHRASE
Then
Commands here
End:End
ClrHome
comicIDIOT wrote:
Ephriam, can you explain how a While loop will be beneficial here?

Str0 is being matched to the string PHRASE. If Str0 equals "sudo" it won't equal PHRASE and thus, won't execute any of the commands. Don't forget that you also need Then statements if you plan to execute more than one line of code after an IF.


can you give me an example of how this would be coded? Also, thanks for the tip with the then statement, i though you only needed it with else.
also, would checking the string be a case sensitive operation? i'm guessing it would be
I unfortunately can't provide an example at this point in time other than that you'll need an IF conditional for every command you wish to have. IF Str0="sudo", ="cd", ="update", etc etc.

Ephraim B wrote:
So I was right about the While loop


I never said you were wrong, I was trying to get at the reasoning behind your suggestion.
ByteStorm wrote:
also, would checking the string be a case sensitive operation? i'm guessing it would be


Yes, it would have to be, but that is not necessarily an issue, as many programming languages and *I think* some console commands are also case sensative. You could also set up a chain, sort of like if someone enters "SAVE Str1 Hello", the first 4 characters are read and compared to "SAVE", then the second argument "Str1" is checked, and then "Hello" is stored to Str1. This is not a great example, but it's an idea. Smile
Is this supposed to be like the Linux Terminal?
Ephraim B wrote:
Is this supposed to be like the Linux Terminal?


I don't think that it is possible to get anywhere near that advanced, Wink, but I think that this might be the goal. Sort of like a command-line interface. Pretty neat. By the way, how goes progress on this?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement