That's a good point. I would like to think that if gotos were completely useless, they wouldn't be a part of the code and would have been eliminated long ago. I've re-written my code to use subroutines instead, but still found gotos useful for small stuff like that one smart guy demonstrated. Check it out and tell me if this looks any better than before:
dim book$(100,7)
for i=1 to 100
book$(i,1)="0"
next i
hide mouse
start:
do
cls
print "1 - Add a New Entry."
print "2 - Edit an Existing Entry."
print "3 - Delete an Existing Entry."
print "4 - Display an Existing Entry."
print "5 - Load an address book."
print "6 - Save information to an address book."
print " "
input "Please make a selection> ",action
select action
case 1
gosub bookinput
print "Information added."
print "<PRESS ANY KEY>"
wait key
endcase
case 2
cls
input "Please tell me the last name for the entry to be edited> ",sl$
input "Please tell me the first name for the entry to be edited> ",sf$
print " "
for i=1 to 100
if sl$=book$(i,2) and sf$=book$(i,3) and book$(i,1)="1"
var=i
gosub edit
exit
endif
next i
endcase
case 3
cls
input "Please tell me the last name for the entry to be deleted> ",dl$
input "Please tell me the first name for the entry to be deleted> ",df$
print " "
for i=1 to 100
if dl$=book$(i,2) and df$=book$(i,3) and book$(i,1)="1"
var=i
gosub delete
exit
endif
next i
endcase
case 4
cls
input "Please enter the last name for the entry to display> ",disl$
input "Please enter the first name for the entry to display> ",disf$
print " "
for i=1 to 100
if book$(i,1)="1" and book$(i,2)=disl$ and book$(i,3)=disf$
var=i
gosub display
exit
endif
next i
endcase
case 5
input "What did you call the address book you saved?> ",filename$
if file exist(filename$)=1
print "Address book found."
load array filename$,book$(0)
print "Address book loaded."
print "<PRESS ANY KEY>"
wait key
else
print "Address book not found. Please try again."
print "<PRESS ANY KEY>"
wait key
endif
endcase
case 6
input "What would you like to call this address book?> ",filename$
if file exist(filename$)=1
input "That file already exists. Would you like to replace it?> ",overwrite$
if overwrite$="y"
delete file filename$
save array filename$,book$(0)
print "Address book saved."
print "<PRESS ANY KEY>"
wait key
else
print "Address book not saved."
print "<PRESS ANY KEY>"
wait key
endif
else
save array filename$,book$(0)
print "Address book saved."
print "<PRESS ANY KEY>"
wait key
endif
endcase
endselect
loop
`******************** BOOK INPUT ********************
bookinput:
cls
input "Last Name?> ",last$
input "First Name?> ",first$
input "Address?> ",address$
input "Home Phone Number?> ",home$
input "Cell Phone Number?> ",cell$
input "Work Phone Number?> ",work$
print " "
input "Is this Information Correct?> ",correct$
if correct$="y"
for i=1 to 100
if book$(i,1)="0"
book$(i,1)="1"
var=i
gosub array
exit
endif
next i
else
gosub bookinput
endif
return
array:
book$(var,2)=last$
book$(var,3)=first$
book$(var,4)=address$
book$(var,5)=home$
book$(var,6)=cell$
book$(var,7)=work$
return
`******************** EDIT INFORMATION ********************
edit:
cls
print "(1) ";book$(var,2);", (2) ";book$(var,3)
print "(3) ";book$(var,4)
print "(4) Home Phone - ";book$(var,5)
print "(5) Cell Phone - ";book$(var,6)
print "(6) Work Phone - ";book$(var,7)
print " "
print "(7) GO BACK"
input "Please enter the number of the item to be changed.> ",edit
select edit
case 1
input "Please enter the new information.> ",last$
book$(var,2)=last$
print "Information changed."
endcase
case 2
input "Please enter the new information.> ",first$
book$(var,3)=first$
print "Information changed."
endcase
case 3
input "Please enter the new information.> ",address$
book$(var,4)=address$
print "Information changed."
endcase
case 4
input "Please enter the new information.> ",home$
book$(var,5)=home$
print "Information changed."
endcase
case 5
input "Please enter the new information.> ",cell$
book$(var,6)=cell$
print "Information changed."
endcase
case 6
input "Please enter the new information.> ",work$
book$(var,7)=work$
print "Information changed."
endcase
case 7
goto start
endcase
endselect
print " "
input "Are you done changing this entry?> ",done$
if done$="n" then goto edit
return
`******************** DELETE INFORMATION ********************
delete:
for i=2 to 7
print book$(var,i)
next i
input "Delete this entry?> ",confirm$
if confirm$="y"
book$(var,1)="0"
print "Information deleted."
print "<PRESS ANY KEY>"
wait key
endif
return
`******************** DISPLAY INFORMATION *********************
display:
cls
print book$(var,2);", ";book$(var,3)
print book$(var,4)
print "Home Phone - ";book$(var,5)
print "Cell Phone - ";book$(var,6)
print "Work Phone - ";book$(var,7)
print "<PRESS ANY KEY>"
wait key
return
If you look in the Edit Information subroutine, you'll find my only goto in case seven. Thanks again for all the excellent criticisms and posts!