** Last revision: June 30, 1986 at 12:59 ** I found this little critter on a BBS without an authors name. ** Revised it to my own personal tastes and Clippered it. ** H.M. Van Tassell * Generate memory variable names from data file * Save the output in a text file with the same name as the database * file and a .txt extension set talk off clear all clear ? ? "Ready to GENerate memory variable NAMES from a data (dbf) file." ? accept 'Enter [drive:] with no extension -->' to filename ? filename = upper(trim(filename)) datafile = filename + '.DBF' if file(datafile) use &datafile else ? datafile + "does not exist where I'm looking for it." set talk on return endif wait "You want listing in alphabetical order by data types and names (Y/N) ?" to alpha_order ? ? "One moment please..." copy to temp structure extended use temp replace all field_name with lower(field_name) IF upper(left(alpha_order,1)) = "Y" index on field_type + field_name to temp ENDIF clear outfile = filename + '.NAM' set alternate to &outfile set alternate on ? "Generated "+DtoC(DATE())+" @ "+TIME()+" from data file: " + datafile ? store '00000000000000000000' to zeros goto top do while .not. eof() do case case field_type = 'C' ? 'm_'+substr(field_name,1,8) + ' = SPACE(' + str(field_len,3) + ')' case field_type = 'N' .and. field_dec = 0 ? 'm_'+ substr(field_name,1,8) + ' = ' + substr(zeros,1,field_len-; field_dec) case field_type = 'N' .and. field_dec >0 ? 'm_' + substr(field_name,1,8) + ' = ' + substr(zeros,1,field_len-; field_dec-1) + '.' +substr(zeros,1,field_dec) case field_type = 'L' ? 'm_' + substr(field_name,1,8) + ' = .F.' case field_type = 'D' ? 'm_' + substr(field_name,1,8) + ' = CtoD(" / / ")' endcase skip enddo ? go top do while .not. eof() ? 'm_' + substr(field_name,1,8) + ' = ' + upper(substr(field_name,1,1)) +; substr(field_name,2,9) skip enddo ? go top do while .not. eof() ? 'REPLACE ' + upper(substr(field_name,1,1)) + substr(field_name,2,9)+; ' WITH m_' + substr(field_name,1,8) skip enddo set alternate off set alternate to close databases ? ? "Output will be in file: " + outfile ? set talk on return