Hello, when creating labels in lines of programming while using the "menu" function where you have a choice of which label to go to, let's just say I have a choice of paths, and I chose path one, depending on the result of another future menu option, I may need to return to the second later. Is there a command that can tell the calculator to return to a previous label and I stress this, if and only if it has not been executed yet?
There is a command in the Program Catalog called Goto that will go to a specific label of your choice. However, it is the user's responsibility to know if a label has or hasn't been used, therefore, off the top of my head, I cannot think of a specific command that does this.
Right, I use Goto already. The problem is I have a menu with choices of "1 and 2" and although both are choices, they are both still needed for the final calculation. I have it programmed to go directly to 2 after 1 is satisfied, but incase I decided to do 2 first, I would like it to go back to 1 the same way. The reason why I can't do that with "goto' is because this specific field can possibly have a zero value after one is prompted. Being that the calculator gives every variable an automatic zero value until the user changes that specific one, there is no way to tell the calculator whether or not it's the zero value that I entered in, or the one that is assigned automatically, so the only other way is to check to see whether or not that line of code has already been executed or not.
I'm not sure I completely understand. After you have completed the second path, and you want to go back to the first path to enter things in, you say the calculator isn't sure if the zero you have entered is different from the one the calculator automatically assigns to it. This I understand. However, if you're worried that there will be a zero assigned to it, and you enter things in that are not zero, what seems to be the problem? I guess I don't understand why it matters that the calculator knows if the line of code has been accessed.
The problem is that zero is a possible answer, so I can't set it to repeat if there is a zero quantity already there. I need to skip to the next menu if the zero that is there is was entered by me, or go back the the previous menu if the zero value in that menu is the one automatically assigned.
Ahhh I see your dilemma. Thanks for being patient with me, now I get it. As far as I've seen throughout this wiki, there's no command/technique that allows you to do that. However, that doesn't mean there isn't. If someone like Xeda or Rogue get in on this, I think they may know.
Hmm that's a hard one since there's not a particularly elegant way to do this. However:
Menu("Options","Option 1",1,"Option 2",2
Disp "Already done!"
Code for option 1
Disp "Already done!"
Code for option 2
//Code to do after both options are executed
That is pretty similar to what I was going to suggest. It isn't the only way, but if you don't mind using a variable to figure out when a label has been tried, you could do something like:
DelVar A Menu("HEADER","Lbl 1",1,"Lbl 2",2 Lbl 1 If A=1 Goto Z If not(A ;check if A is 0, if it is, make it 1 1→A <<code>> Lbl 2 If A=2 ;A is only 2 if Lbl 2 was the first label to be visited (see a few lines below) Goto Z If not(A ;check if A is 0, if it is, make it 2 2→A <<code>> Goto 1 Lbl Z
So when it reaches that last Goto 1, A is either 1 or 2, depending on the which label was jumped to first. If it is 1, then it goes to Lbl 1 where the first two lines of code say, "Hey, you've already been here, so go to Lbl Z." If it is 2, then A stays 2 and the code for Lbl 1 is executed, then it moves through to Lbl 2, where the same check sends the code to Lbl Z.
47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2