Post by krash81 on Jul 14, 2019 18:48:07 GMT
Greetings, I am attempting to create a database type of program to save basic user information in a file. Everything seems to work except for one thing, when I change a field and save the file, then navigate back to that record, the change isn't reflected on the screen. I believe I am just somehow not saving the file correctly. Any help would be greatly appreciated!
nomainwin
cc = 0
WindowWidth = 936
WindowHeight = 600
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #main.statictext1, "Krash's Client Directory", 350, 36, 144, 20
statictext #main.statictext2, "First Name:", 86, 76, 72, 20
statictext #main.statictext3, "Last Name:", 86, 106, 72, 20
statictext #main.statictext4, "Phone Number:", 86, 141, 96, 20
statictext #main.statictext5, "Address:", 86, 171, 56, 20
statictext #main.statictext6, "City:", 86, 231, 32, 20
statictext #main.statictext7, "State:", 86, 266, 40, 20
statictext #main.statictext8, "Zip Code:", 86, 301, 64, 20
textbox #main.address, 182, 171, 224, 55
textbox #main.firstName, 182, 76, 208, 25
textbox #main.lastName, 182, 106, 208, 25
textbox #main.phoneNumber, 182, 141, 208, 25
textbox #main.city, 182, 231, 100, 25
textbox #main.state, 182, 261, 100, 25
textbox #main.zipCode, 182, 296, 100, 25
statictext #main.statictext16, "Pitch:", 86, 356, 40, 20
textbox #main.pitch, 182, 356, 520, 160
statictext #main.statictext19, "Client ID:", 86, 331, 56, 20
textbox #main.clientID, 182, 326, 100, 25
button #main.button21, "Previous", [prevRecord], UL, 182, 531, 112, 25
button #main.button22, "Next", [nextRecord], UL, 310, 531, 122, 25
button #main.button23, "Save", [clientSave], UL, 446, 531, 122, 25
button #main.button24, "Exit", [kcdQuit], UL, 582, 531, 122, 25
statictext #main.statictext25, "Client Notes:", 422, 76, 80, 20
textbox #main.clientNotes, 502, 76, 368, 205
open "clientViewer" for window as #main
print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
print #main.statictext1, "!font MS_Sans_Serif 15"
'populate the arrays with client data from file
dim fName$(100)
dim lName$(100)
dim phNumber$(100)
dim addy$(100)
dim clientCity$(100)
dim clientState$(100)
dim clientZip$(100)
dim clientNotez$(100)
[grabClients]
open str$(cc) + ".txt" for input as #1
currentClient = cc
do
input #1, cFirstName$
input #1, cLastName$
input #1, cPhoneNum$
input #1, cAddress$
input #1, clientTown$
input #1, cState$
input #1, cZipCode$
input #1, clientInfo$
fname$(currentClient) = cFirstName$
lname$(currentClient) = cLastName$
phNumber$(currentClient) = cPhoneNum$
addy$(currentClient) = cAddress$
clientCity$(currentClient) = clientTown$
clientState$(currentClient) = cState$
clientZip$(currentClient) = cZipCode$
clientNotez$(currentClient) = clientInfo$
currentClient = currentClient + 1
loop until eof(#1)
close #1
'done loading data to display
'populate the form
currentClient = cc
print #main.clientID, str$(currentClient)
print #main.firstName, fname$(currentClient)
print #main.lastName, lname$(currentClient)
print #main.phoneNumber, phNumber$(currentClient)
print #main.address, addy$(currentClient)
print #main.city, clientCity$(currentClient)
print #main.state, clientState$(currentClient)
print #main.zipCode, clientZip$(currentClient)
print #main.clientNotes, clientNotez$(currentClient)
wait
[quit.Main]
end
[kcdQuit]
close #main
end
[nextRecord]
cc = cc + 1
if cc > 99 then cc = 100
goto [grabClients]
wait
[prevRecord]
cc = cc - 1
if cc < 1 then cc = 0
goto [grabClients]
wait
[clientSave]
currentClient = clientID
print #main.firstName, "!contents? cFirstName$"
print #main.lastName, "!contents? cLastName$"
print #main.phoneNumber, "!contents? cPhoneNum$"
print #main.address, "!contents? cAddress$"
print #main.city, "!contents? clientTown$"
print #main.state, "!contents? cState$"
print #main.zipCode, "!contents? cZipCode$"
print #main.clientNotes, "!contents? clientInfo$"
fname$(currentClient) = cFirstName$
lname$(currentClient) = cLastName$
phNumber$(currentClient) = cPhoneNum$
addy$(currentClient) = cAddress$
clientCity$(currentClient) = clientTown$
clientState$(currentClient) = cState$
clientZip$(currentClient) = cZipCode$
clientNotez$(currentClient) = clientInfo$
open str$(clientID) + ".txt" for output as #1
print #1, fname$(currentClient)
print #1, lname$(currentClient)
print #1, phNumber$(currentClient)
print #1, addy$(currentClient)
print #1, clientCity$(currentClient)
print #1, clientState$(currentClient)
print #1, clientZip$(currentClient)
print #1, clientNotez$(currentClient)
close #1
wait