home *** CD-ROM | disk | FTP | other *** search
- ************************************************************
- ************************************************************
- ***** File Converter (c) COPYRIGHT 1983 *****
- ***** confield.cmd Data Based Advisor *****
- ***** *****
- ***** AUTHOR: Larry Eitel *****
- ***** DATE: October 29, 1983 *****
- ***** *****
- ***** called from con.cmd *****
- ***** *****
- ***** PURPOSE: *****
- ***** Get a valid field name to recieve converted *****
- ***** information and valid field list from the *****
- ***** (SECONDARY) from file. Then generate REPLACE *****
- ***** statements which can be used to generate a *****
- ***** command file to accomplish the convertion. *****
- ***** *****
- ***** DISCLAIMER: *****
- ***** The author makes or implies no warranties *****
- ***** regarding the operation or usefulness of this *****
- ***** program. It is recommended the user make *****
- ***** backups of any valuable files. *****
- ************************************************************
- ************************************************************
- DO WHILE t
- ERASE
- ? header
- @ 3,0 SAY 'Convert the contents in the file ' +;
- trim(fromck)+' and add to the file ' +trim(tock)+ '.'
- ***** Loop to get a valid field to append to
- STORE t TO check
- DO WHILE check
- SELECT PRIMARY
- ***** Initialize tofield which will contain name of
- ***** the field in the to file.
- STORE ' ' TO tofield
- ***** Get the name of the tofield. If the name of the
- ***** tofield in the PRIMARY use area is the same as
- ***** the name of a field in the SECONDARY use area,
- ***** preface the field name with p.<fieldname>.
- @ 05,00 SAY 'Enter the field to convert to, '+;
- '(?)isplay fields, <RET> if Done. ' GET tofield
- @ 10,00 SAY ' '
- ***** Display last REPLACE statement generated
- IF 0#test(line&lnumber)
- ? line&lnumber
- ENDIF 0#test(line&lnumber)
- READ
- ***** Display structure of the to file
- IF !(tofield)= '?'
- @ 11,00
- @ 06,00 SAY ' '
- DISPLAY STRUCTURE
- ?
- ? 'Press any key to continue.'
- WAIT
- ERASE
- ? header
- @ 3,0 SAY 'Convert the contents in the file ' +;
- trim(fromck)+' and add to the file ' +trim(tock)+ '.'
- LOOP
- ENDIF !(tofield)= 'D'
- IF tofield= ' '
- ERASE
- RETURN
- ENDIF tofield= ' '
- ***** Test for valid field in the to file
- IF 0=test(&tofield=&tofield)
- ?? chr(7)
- SET inte OFF
- @ 23,00 SAY 'INVALID FIELD NAME'
- SET inte ON
- ELSE
- STORE f TO check
- ENDIF 0=test(&tofield=&tofield)
- ENDDO WHILE check
- ***** This loop will get the field list of the from file
- ***** that will be appended to the to file into the
- ***** tofield
- ***** Initialize fromfiel which will contain the field
- ***** list to append to new field
- STORE $(str(0,79),1,78) TO fromfiel
- STORE t TO check
- DO WHILE check
- ***** Get the field list from the SECONDARY file. If a
- ***** field name in the field list is the same as a
- ***** field in the (PRIMARY) tofile, preface the field
- ***** name with s.<fieldname>.
- @ 06,00 SAY 'Enter contents to transfer to the '+;
- 'above field.'
- @ 07,00 SAY '?>Display fields, <BLANK> to Return.'
- @ 08,00 GET fromfiel
- READ
- ***** Display structure of the from file
- IF fromfiel=' '
- @ 22,00
- STORE f TO check
- LOOP
- ENDIF
- IF '?' $fromfiel
- SELECT secondary
- @ 11,00
- @ 22,00
- @ 09,00 SAY ' '
- DISPLAY STRUCTURE
- ?
- ? 'Press any key to continue.'
- WAIT
- ERASE
- ? header
- @ 3,0 SAY 'Convert the contents in the file ' +;
- trim(fromck)+' and add to the file ' +trim(tock)+ '.'
- @ 05,00 SAY 'Enter the field to convert to, '+;
- '(D)isplay fields, <RET> to Exit. : :'
- SET inte OFF
- @ 05,65 SAY tofield
- SET inte ON
- LOOP
- ENDIF '?' $fromfiel
- ***** The following is a series of tests on the fromfiel
- ***** entry. There doesn't seem to be a more graceful
- ***** of testing this entry. What I do is tell the user
- ***** if the message at the bottom of the screen remains
- ***** there, to press any key and correct the entry.
- ***** It has to pass two different tests. One is a test
- ***** to see if it is a valid field list. The other is a
- ***** test to verify if the field list can be REPLACED
- ***** into the field chosen. In other words you will
- ***** not be able to put a character string into a
- ***** numeric field.
- SET inte OFF
- @ 22,00 SAY 'If this prompt remains on the screen, '+;
- 'press any key and correct your entry.'
- SET inte ON
- ***** Prevent a possible dBASE II error message from
- ***** being displayed on the screen by SETting CONSOL
- ***** OFF.
- SET cons OFF
- RELEASE fromstrg
- STORE &fromfiel TO fromstrg
- SET cons ON
- ***** If the above STORE command failed because
- ***** fromfiel did not contain a valid field list,
- ***** memory variable fromstrg will not have a value.
- IF 0=test(fromstrg)
- LOOP
- ENDIF 0=test(fromstrg)
- ***** Prevent a possible dBASE II error message from
- ***** being displayed on the screen by SETting CONSOL
- ***** OFF.
- SET cons OFF
- SELECT seco
- REPLACE &tofield WITH fromstrg
- SET cons ON
- SELECT PRIMARY
- ***** If the above REPLACE command failed because
- ***** tofield cannot be REPLACEd with fromstrg. Probably
- ***** due to one being numeric and the other a character
- ***** string.
- IF 0=test(&tofield=fromstrg)
- @ 22,00
- LOOP
- ELSE
- STORE f TO check
- ENDIF 0=test(&tofield=fromstrg)
- ***** If the entry passed the above tests, STORE a
- ***** REPLACE statement to a new memory variable. To do
- ***** this, I used the memory variable phrase "line"
- ***** and added a sequential apha-numeric string to the
- ***** end of it. The result is for every valid REPLACE
- ***** statement created, there will a different memory
- ***** variable created e.,g., line1, line2, line3, etc.
- IF number<10
- STORE str(number,1) TO lnumber
- ELSE
- STORE str(number,2) TO lnumber
- ENDIF number<10
- ***** STORE a REPLACE statement to a memory variable.
- ***** Note that if lnumber=1, using the macro function,
- ***** you can STORE the following string to line1. Next
- ***** time around it will be STOREd to line2.
- STORE 'REPLACE ' +trim(tofield)+ ' WITH ' +;
- trim(fromfiel) TO line&lnumber
- STORE number+1 TO number
- ENDDO WHILE check
- ENDDO WHILE t
- RETURN