The Artima Developer Community
Sponsored Link

Java Answers Forum
Jump and Skip Program(Does Not Work)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
DAYO

Posts: 22
Nickname: done
Registered: Jun, 2002

Jump and Skip Program(Does Not Work) Posted: Jun 12, 2002 5:58 PM
Reply to this message Reply
Advertisement
I am sorry if i was not too clear the first time.I hope my problem is clearer now.
I have written a program that executes certain instructions.It reads these instruction from an array of Textfield.I have a for loop to go through the Textfield.I am unable to implement a JUMP instruction that will jump to a specified Textfield as well as the SKIP instruction that will skip the next Textfield based on some condition.
I tried the code below but it does not work
private class Executionionhandler implements ActionListener
{ public void actionPerformed(ActionEvent event)
{ int StartLocation=(int)(Integer.parseInt(start2.getText()));
//start1.setVisible(fa lse);
//start2.setVisible(false);
//r, StartLocation, End, Stop are global
for(int r=StartLocation;r<End && Stop==false;r++)
{//content[r] is a Textfield
String read=Content[r].getText();
String com1=read.substring(0,2);
int com11=(int)(Integer.parseInt(com1));
String com2=read.substring(2,4);
instruction(com11,com2);
}
}
}

public void instruction(int IN1,String IN2)
{ switch(IN1)
{ case 1:
//do something
break;
case 3:
//do something break;
case 7://the JUMP INSTRUCTION
int JmpLoc7=(int)(Integer.parseInt(IN2));
r=JmpLoc7;
//StartLocation=JmpLoc7;
break ;
case 8://the SKIP INSTRUCTION
int copy81=(int)(Integer.parseInt(BUTTON.getText()));
if(((copy81<0) && (IN2.equals("00"))) ||
((copy81==0) && (IN2.equals("01"))) ||
((copy81>0) && IN2.equals("02")))
)
r++;
case 11:
error1.setText("End of command");
Stop=true;
break;
default:
error1.setText("BAD COMMAND");
Stop=true;
}
}
Any idea why or how can I achieve this?

Topic: Polymorphism Problem Previous Topic   Next Topic Topic: Singleton

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use