DIM SHARED nRecs
' for when you get a file going
DIM myRec
AS customer
'edit this record over and over for testing edit = EditCustomer(myRec, 1) ' assign to first record 1 if not Cancelled
PRINT "Record #:"; myRec.id
PRINT " First:"; myRec.first
PRINT " Last:"; myRec.last
PRINT " Address:"; myRec.address
PRINT " City:"; myRec.city
PRINT " State:"; myRec.state
PRINT " Phone:"; myRec.phone
PRINT "user cancelled edit" PRINT "(SLEEPing) press any to continue..." 'if edit then fileRec myRec, 1
'return 0 if user cancelled, -1 if record edit was accepted
FUNCTION EditCustomer%
(customerRec
AS customer
, recNumber
AS LONG) ' use for new Customer or edit Customer rec(1, 0) = "First Name"
rec(2, 0) = "Last Name"
rec(3, 0) = "Address"
rec(4, 0) = "City"
rec(5, 0) = "State (abbrev:2)"
rec(6, 0) = "Zip (5)"
rec(7, 0) = "Phone" ' might split to Home and Mobile
IF customerRec.first
<> "" THEN rec
(1, 1) = customerRec.first
IF customerRec.last
<> "" THEN rec
(2, 1) = customerRec.last
IF customerRec.address
<> "" THEN rec
(3, 1) = customerRec.address
IF customerRec.city
<> "" THEN rec
(4, 1) = customerRec.city
IF customerRec.state
<> "" THEN rec
(5, 1) = customerRec.state
IF customerRec.zip
<> "" THEN rec
(6, 1) = customerRec.zip
IF customerRec.phone
<> "" THEN rec
(7, 1) = customerRec.phone
doAgain:
FOR i
= 1 TO 7 'show what we have PRINT i
, rec
(i
, 0);
" = "; rec
(i
, 1) PRINT:
PRINT "Press a to Accept, n for New, a digit to edit field, or escape to Cancel." choice$
= getChar$
("aAnN1234567" + CHR$(27)) IF ASC(choice$
) = 27 THEN ' maybe this should be a function customerRec.id = recNumber 'assign the record
customerRec.first = rec(1, 1)
customerRec.last = rec(2, 1)
customerRec.address = rec(3, 1)
customerRec.city = rec(4, 1)
customerRec.state = rec(5, 1)
customerRec.zip = rec(6, 1)
customerRec.phone = rec(7, 1)
FUNCTION getChar$
(fromStr$
) ' get a char$ usually for a menu getChar$ = k$