home *** CD-ROM | disk | FTP | other *** search
- ***************************************************************************
- ** DONEDIT.PRG
- ** (C) Copyright 1990, Sub Rosa Publishing Inc.
- ** A demonstration program provided to VP-Info users.
- ** This program may be copied freely. If it is used in commercial code,
- ** please credit the source, Sub Rosa Publishing Inc.
- **
- ** DONEDIT is a subroutine on MENU.PRG, used to edit and add donor
- ** records to DONOR.DBF.
- **
- ** DONEDIT is compatible with all current versions of VP-Info.
- **
- ** Sid Bursten and Bernie Melman
- ** May 9,1990
- ***************************************************************************
- ON escape ;what to do when <Esc> is pressed
- WINDOW
- CLEAR gets
- CANCEL
- ENDON
- SET deleted off
- USE donor index don_name,don_code
- USE#2 solicit index sol_code
- IF recno(1)=0
- APPEND blank
- ENDIF
- goto dbf(recs) ;goto last record added to file
- PERFORM inputscrn
- DO WHILE t
- IF donor=' ' ;this means it's a new record
- mfname=fname ;initialize memory variables with 1st name
- mname=name ; also last name
- recnum=# ;save record number to allow return to same record
- WINDOW 10,10,17,69 double
- CLEAR gets
- TEXT
- .. donor,!!!-!-99
-
- Record to add
-
- First Name... @mfname
- Last Name... @mname
- ENDTEXT
- WINDOW
- READ
- * build a donor code--3 characters from last name, plus first initial, plus
- * a 2-digit serial number to force every donor to have a unique code
- finder=!(left(mname,3)+left(mfname,1)) ;build alpha part of code
- finder=replace(finder,' ','*') ;fill in blanks in code with asterisks
- * LAST &finder ;only in Professional...for Level 1 use commented lines below
- *****************************Level 1 version*******************************
- FIND &finder ;these 6 lines are equivalent to above single line,
- IF #>0 ; although LAST is substantially faster. Essentially,
- LIMIT 4 ; all we have to do is find if a record exists with the
- GOTO bottom ; same 1st 4 letters of the code, and find out what the
- LIMIT ; last serial number is so we can increment it
- ENDIF
- IF #=0
- finder=finder+'01'
- ELSE
- num=val(right(donor,2)) ;get number of last matching record
- IF num<99 ;only allow numbers up to 99
- finder=finder+right(str(101+num,3),2) ;increment with leading zero
- ELSE
- finder='******' ;overflow if already 99 records with same letters
- ENDIF
- ENDIF
- GOTO recnum ;go back to original record and fill in name and code
- REPLACE fname with mfname,name with mname,donor with finder
- PERFORM inputscrn ;rebuild original input screen
- :field=field(address) ;start with address
- ELSE
- :field=field(fname) ;start with fisrt name
- ENDIF
- IF solicitor<>solicitor#2 ;align solicitor file
- FIND#2 &solicitor#1
- ENDIF
- @ 0,0 say pic(#,'999,999')
- @ 0,77 say iff(deleted(1),'DEL',' ')
- READ
- kn=:key ;save key used to get out of READ
- DO CASE kn
- CASE kn=17 ; ^Q=no update
- NOUPDATE ;cancel any changes already made
- CASE kn=329 ; <PgUp>=Beginning of file
- SKIP -1
- IF #=0 ;don't back up past beginning of file
- GOTO top
- RING ;notify user end of file reached
- ENDIF
- CASE kn=337 ; <PgDn>=End of file
- SKIP
- IF eof
- GOTO bottom
- RING ;notify user end of file reached
- ENDIF
- CASE kn=375 ; ^<Home>=Beginning of file
- GO top
- CASE kn=373 ; ^<End>=End of file
- GOTO bottom
- CASE kn=374 ; ^<PgDn>=Add a record
- GOTO top
- IF donor>' '
- APPEND blank ;append only if not already an empty record
- ENDIF
- CASE kn=335 ; <End>=Quit
- BREAK
- ENDCASE kn
- ENDDO
- CLOSE all
- RETURN
- *
- PROCEDURE inputscrn
- WINDOW ;cancel any existing window before erasing screen
- ERASE
- TEXT .1 ;get screen text from library, volume number 1
- ON field
- FIELD solicitor
- IF @(' ',solicitor)>0
- :field=field(solicitor)
- @ 23,0 say cen('Solicitor code must be specified.',80)
- ELSE
- @ 23,0
- IF solicitor<>solicitor#2
- FIND#2 &solicitor#1 ;align file when solicitor code filled in
- IF recno(2)=0
- :field=field(solicitor)
- @ 23,0 say cen('No solicitor found with this code number.',80)
- ELSE
- :field=field(fname)
- @ 23,0
- ENDIF
- ENDIF
- ENDIF
- ENDON
- ENDPROC inputscrn
- *
- * *** end of program donedit.prg ***
-