<div class="gmail_quote">
<div>hi everyone, I'm a bit new here but i was wondering if someone could check some of my code, it's not doing quite what it's meant to. the problem is when you start the application again and enter the databox.txt to load from</div>
<div>thanks</div>
<div> </div>
<div>Databox_2_0.py:</div>
<div> </div>
<div>import sys, os<br>pygame.init()</div>
<div>def load(filename):<br> if filename != '':<br> e = 1<br> dec = "placeholder"<br> fic = open(filename, "r")<br> while dec != '':<br> num = str(e)<br>
print "found " + num + " enteries"<br> dec = fic.readline(e)<br> databox[e] = dec<br> dec = fic.readline((e+1))<br> databox2[e] = dec<br> e = e+1<br>
fic.close()<br> else:<br> return 0</div>
<div>def search():<br> print "\n"<br> x = 1<br> items = len(databox)<br> ins = items+1<br> while ins > x :<br> dac = databox[x]<br> dac2 = databox2[x]<br> x = x + 1<br> print dac + " " + dac2<br>
print "\n\n"<br> </div>
<div>def add():<br> dat = raw_input("First name.\n")<br> dat2 = raw_input("\nSecond name.\n")<br> items = len(databox)<br> ins = items+1<br> databox[ins] = dat<br> databox2[ins] = dat2<br>
print "Done.\n\n"</div>
<div>def exitprog():<br> fic = open('databox.txt','w')<br> print "saveing\n"<br> x = 1<br> items = len(databox)<br> ins = items+1<br> while ins > x :<br> dac = databox[x]<br>
dac2 = databox2[x]<br> x = x + 1<br> fic.write(dac)<br> fic.write(dac2)<br> fic.close()<br> print "goodbye"<br> pygame.time.delay(900)<br> exit()</div>
<div>databox = dict()<br>databox2 = dict()<br>go = raw_input("filename, blank for none.\n")<br>load(go)<br>while True:<br> print "Welcome to databox V2.0."<br> print " 1. Searth the database."<br>
print " 2. Add a record."<br> print " 3. Exit."<br> inme = raw_input("Please make a selection.\n")<br> if inme == "1":<br> search()<br> elif inme == "2":<br>
add()<br> elif inme == "3":<br> exitprog()<br> else:<br> print "input not recignised."<br></div></div><br>