Module Design - Loop Object

Last update April 29 at 7:53 p.m.

This object was designed by Dave Sager

Object Overview:

This object handles the displaying of the Loop window. The main functions of the object are the displaying of the "loop window" with the appropriate format and text displayed. It makes calls to the command line object with the information that is needed to be parsed and executed.

Private Data:

Consist of a boolean type that stores either True for a "For" loop or false otherwise. The string[7] is where the actually code of the loop is to be stored for passing around. The boolean logged is used to decide if the commands of the loop have been sent to the StringBuffer InProgress. The string command stores the current command being considered. The int focus is used to the store the current focus of the loop window. Focus is the way of saying what line the cursor is currently at. The boolean stepThrough is how we checked if the user has stepped through the loop yet.

Methods:

public void SetLoopType(boolean type)
Overview: Sets the type of loop either to "For Loop" or "While Loop".
Parameters: None.
Pre-conditions: Some sort of loop has been entered.
Post-conditions: Loop type is "true" for "For" loop's and "false" otherwise.
Algorithm: Manipulation of internal data.
Interaction with other objects: None.
Error Conditions: None
Return Value: None

public boolean GetLoopType()
Overview: Returns the type of loop either to "For Loop" or "While Loop".
Parameters: None.
Pre-conditions: Some sort of loop has been entered.
Post-conditions: Loop type is "true" for "For" loop's and "false" otherwise.
Algorithm: Manipulation of internal data.
Interaction with other objects: None.
Error Conditions: None
Return Value: boolean type.

public void DrawMe()
Overview: Used to draw the loop window.
Parameters: A boolean variable that contains the type of loop.
Pre-conditions: Loop has been invoked for operation.
Post-conditions:Opens a pop-up window for loop text entry.
Algorithm: If loopType is "True" draw "ForLoop" otherwise "WhileLoop".
Interaction with other objects: None.
Error Conditions: None
Return Value: None

public array GetText()
Overview: Returns the array string which has all of the command that the user has entered into the loop text boxes.
Parameters: None.
Pre-conditions: Lop pop-up is active.
Post-conditions: Returns the array string containing the statements from the loop texty boxes.
Algorithm: Calls the SetFocus with a 0 to set the focus to the first line of the loop. Then it takes the information on that line and stores it into the string[0]. Then the focus is set to 1 and the same procedure is repeated. This is done until all the lines in the loop have been entered into the string.
Interaction with other objects: None.
Error Conditions: None
Return Value: The array string[] containing all of the loop commands.

public void Run()
Overview: Runs the loop entered by the user.
Parameters: None.
Pre-conditions: Run has been seee from the loop window.
Post-conditions: The entire loop has been executed.

Algorithm: Calls the function GetStep and if it returns True we make a call to the ExecutionStatus method and let it deal with things. If it returns False we call SetFocus with 0. We make a call to the GetLoopType command and if it returns True then we have a For loop and we must break it down by taking the controlling line of the loop and break it up into three parts with the code before the first semicolon becoming part A, the code after the first semicolon and before the second semicolon will be part B, and the code after the second semicolon will be called part C. We will need to then take the information that is contained in part A and ship it off to the parser. The stuff that is contained in the controlling line of the loop (A, B, and C) will be put into string[0]. Then part B will be put into string[1]. The code that is on line 1 of the loop body will be put into string[2]. This will continue down to the end of the loop. Then we will take part C of the controlling line and put it into string[7]. This way we can treat the loop as a while loop and repeat while part A of the controlling statement is still valid. Now we make a call to GetLog() and if it returns false than we need to put the strings contained in the string[0], string[2] through string[6] into one string and call the command from the CommandLine Object called GetTextInProgress and then we have to call the function SetTextExecuted with the string returned from GetTextInProgress. Now we must call the function SetTextInProgress with the string of loop commands. Then we will call the SetLog() function. To set the boolean logged to True.

If the call to GetLog() would have returned False then we would not need to do the steps that are concerned with updating the command log. Since GetStep returned True we need to start running the loop from the currnet focus which can be obtained by a call to GetFocus(). Now that we have decided where to start we can make a call to the Parser with the appropriate item of string[]. After that is done we must take the focus that we currently have and if it is less than less than 6 we can add one to it but if it is equal to 6 then we must roll the focus back over to 0 and call focus with the integer for the new focus to be set to. Then the GetFocus() will be called again and the same process will be repeated until the parser decides that the controlling line of the loop is no longer valid and then the loop will be terminated.

Now if both the calls to GetStep() and boolean type return False then we have a while loop that has not yet been executed so we must take the controlling line of the loop and put it into the string[0]. We will then ship that off to the Parser. Now we will have to put the rest of the loop in the string[ ] in the same manner as we did above. We will have to follow the same set of things for entry of Commands into the log file and the focus checks as we have done above. The only thing that is different for while loops is that we dont need to worry about breaking the loop down.

Interaction with other objects: None.
Error Conditions: None
Return Value: ForLoopText string.

public void Step()
Overview: Steps through the loop one line at a time. Taking the line of code that it is currently at and sends it off to the Parser Object.
Parameters: None.
Pre-conditions: Step has been selected.
Post-conditions: Has stepped to the next line of code in the loop and the has sent the previous line of code to the parser.
Algorithm: Take the code string from the currnet line and sends it to the parser object. Then set the "focus" to the next line of code. And calls the GetLog method if it returns False then it must do the same procedure as in the Run method for updating the StringBuffer's.
Interaction with other objects:Parser Object.
Error Conditions: None
Return Value: None.

private void SetLog()
Overview: Sets a bollean that tells us if the loop has been entered into the StringBuffer InProgress
Parameters: The boolena logged.
Pre-conditions: none.
Post-conditions: Sets the value of the boolean logged to True.
Algorithm: Set the boolean logged to True.
Interaction with other objects:None.
Error Conditions: None
Return Value: None.

private boolean GetLog()
Overview: Returns a boolean that tell us if the loop has been entered into the StringBuffer InProgress.
Parameters: None.
Pre-conditions: None.
Post-conditions: The boolean logged has ben returned.
Algorithm: Return boolean logged.
Interaction with other objects:Parser Object.
Error Conditions: None
Return Value: None.

private void ExecutionStatus()
Overview: Sets a bollean that tells us if the loop has been entered into the StringBuffer InProgress
Parameters: The boolean logged.
Pre-conditions: none.
Post-conditions: Sets the value of the boolean logged to True.

Algorithm: Call the function GetStep(). If the value returned is True then we need to call get focus so that we can execute the code from the current focus position. Becuase if this value is True then the user has already began to step through the loop on their own and now wants to run it to completion. Now that we have the current focus we can begin to do the loop code. The Loop will need to be broken up into segments if the boolean Type is True. If this is the case then the controlling line at the start of the loop must be broken down into the three sections. The code that is before the first semicolon will be part A, the code after the first semicolon and before the second semicolon will be part B, and the code after the second semicolon will be called part C. We will need to then take the information that is contained in part A and ship it off to the parser. The stuff that is contained in the controlling line of the loop (A, B, and C) will be put into string[0]. Then part B will be put into string[1]. The code that is on line 1 of the loop body will be put into string[2]. This will continue down to the end of the loop. Then we will take part C of the controlling line and put it into string[7]. This way we can treat the loop as a while loop and repeat while part A of the controlling statement is still valid. Now we make a call to GetLog() and if it returns false than we need to put the strings contained in the string[0], string[2] through string[6] into one string and call the command from the CommandLine Object called GetTextInProgress and then we have to call the function SetTextExecuted with the string returned from GetTextInProgress. Now we must call the function SetTextInProgress with the string of loop commands. Then we will call the SetLog() function. To set the boolean logged to True.

If the call to GetLog() would have returned False then we would not need to do the steps that are concerned with updating the command log. Since GetStep returned True we need to start running the loop from the currnet focus which can be obtained by a call to GetFocus(). Now that we have decided where to start we can make a call to the Parser with the appropriate item of string[]. After that is done we must take the focus that we currently have and if it is less than less than 6 we can add one to it but if it is equal to 6 then we must roll the focus back over to 0 and call focus with the integer for the new focus to be set to. Then the GetFocus() will be called again and the same process will be repeated until the parser decides that the controlling line of the loop is no longer valid and then the loop will be terminated.

Now if both the calls to GetStep() and boolean type return False then we have a while loop that has not yet been executed so we must take the controlling line of the loop and put it into the string[0]. We will then ship that off to the Parser. Now we will have to put the rest of the loop in the string[ ] in the same manner as we did above. We will have to follow the same set of things for entry of Commands into the log file and the focus checks as we have done above. The only thing that is different for while loops is that we dont need to worry about breaking the loop down. .

Interaction with other objects:None.
Error Conditions: None
Return Value: None.

public void DisplayCommand(string command)
Overview: This takes the text from the loop window and calls the command to draw the command in the Command to be Executed field in the main window.
Parameters: The command to be displayed.
Pre-conditions: The DisplayCommand function has been called with a string.
Post-conditions: The string is displayed in the Command to be Executed field.
Algorithm: Calls GetFocus and then takes that number and pulls the text out of that line. Calls the fucntion DisplayText from the Command Line Object with the string that it wants to display. Then calls the function SetFocus with the appropriate integer (ie Focus plus 1).
Interaction with other objects: Command Line Object.
Error Conditions: None
Return Value: None.

public void SetFocus(int focus)
Overview: Sets the focus in the loop window so it can be called later.
Parameters: An Integer to set the focus to.
Pre-conditions: The input is an integer between 0 and 7.
Post-conditions: Focus has been upadated and all changes made appropriately.
Algorithm: Manipulation of internal data.
Interaction with other objects: None.
Error Conditions: None
Return Value: None.

public void GetFocus()
Overview: Gets the current focus the loop window.
Parameters: None.
Pre-conditions: None.
Post-conditions: Returns an integer between 0 and 7.
Algorithm: Manipulation of internal data.
Interaction with other objects: None.
Error Conditions: None
Return Value: An interger between 0 and 7.

public void SetStep(boolean stepThrough)
Overview: The boolean stepThrough is used so that we know if the user has begun to step through the loop yet. For if they have and they choose to run than we need to treat this as a special case.
Parameters: The boolean stepThrough.
Pre-conditions: The boolean is set correctly.
Post-conditions: Set the boolean to true.
Algorithm: Manipulation of internal data.
Interaction with other objects: None.
Error Conditions: None
Return Value: None.

public boolean GetStep()
Overview: Returns the value of the boolean stepThrough, returns either True or False.
Parameters: None.
Pre-conditions: None.
Post-conditions: Returned the value of the boolean stepThrough, returns either True or False.
Algorithm: Manipulation of internal data.
Interaction with other objects: None.
Error Conditions: None
Return Value: The boolean stepThrough.

 

Search engine sitemap created by AutoSitemap.com