Re: CASE (added some more info) (fixed a few typos in the pseudo code)

by Michael Calkins (Login MCalkins)
ASM Forum


Are you wanting the user to type the name of the state to delete?

In that case, loop through the states() array until you find the match.

Here's how you might do it:

have an outer DO loop to prompt (and reprompt) the user for the state to delete.
 if the user entered a blank string, exit the loop
 have an inner FOR loop to loop through the states() array looking for a case insensitive match.
  when you find a match, clear that element of the array, then exit both loops.
 print a message that no match was found.

alternatively, you might exit just the inner FOR loop, instead of exiting both loops, if you want to give the user the chance to delete another state. However, then you would need an IF statement for the error message, instead of just printing it unconditionally. In such a case, it is not necessary to introduce another variable to track whether a match was found or not. You can tell from the FOR's counter alone. If the FOR loop is 1 to 50, the counter will be 51 after finishing the loop without a match, but would be less than 51 if the EXIT FOR were executed...


Are you wanting the user to type the array index? (This is how my other modification worked, but might not be ideal.) Then check that the index is within bounds, then delete it.


I think you are going for the first method, but the code looks like you are trying to mix the two methods.


A better method would be to have the user be able to select which one to delete from the display. That is, scroll through the list and let the user select which. However, that is more complicated to code.


This message has been edited by MCalkins on May 12, 2012 6:25 PM

Posted on May 12, 2012, 6:09 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
REMATT on May 12
 * I edited my previous post...Michael Calkins on May 12
  ThanksMatt on May 12
   * yw.Michael Calkins on May 12
re: case updatedMATT on May 12
 I see 2 main problemsMichael Calkins on May 12
  RE: two main problemsMatt on May 13
   I see some other potential problems in your program.Moneo on May 24

 Copyright © 1999-2018 Network54. All rights reserved.   Terms of Use   Privacy Statement