dStruct (c) Time & headache saving tools! Gary Herbstman 1065 S. W. 30th Ave. Deerfield Beach, FL 33442-8104 cServe: 76056,512 phone: (305) 429-2886 fax: (305) 429-3658 Disclaimer: Use at your own risk. The software and accompanying written materials are provided "as is". In no event shall The author be liable for any damages, claims or losses whatsoever including but not limited to any special, incidental, consequential, indirect, or similar damages due to loss of data or any other reason. Retribution: If you put this program to good use, buy me lunch. Five (5) dollars will help me to keep dStruct up to date and create future programs for the programmer. Yes, let me know if you find any "B" words, or any ideas you have for improvement. What is dStruct? dStruct is a utility for Clipper programmers. dStruct creates Clipper header files containing #define statements of the field positions in your database files. Sooo what? Well along with the 3 small functions included with this utility, you can easily copy your current record to an array, edit the array as the record, and then save it if you want to. Where does the header file help? The header file #defines are used as the index pointers into the array. With this you do not need to remember the field positions in the array. If you modify the structure of the Database array all you need to do is recreate the header file with dStruct and recompile. No time! No headaches! No problems! dStruct can also be used to document datafile structures and to just plain look at the structure. Why edit arrays? Two good reasons for copying the record to an array: 1) You can discard the changes by not saving the edit. 2) The record does not have to be locked while it is being edited. Usage: dStruct [options] [> outfile] Options: -p[text] Set the #define prefix text. By default the prefix = "D_". The length may be from 0 to 14 characters. -f[n] The number of chars to include in the #define from the filename. The default is 2 chars. n can be between 0 and 8. -i This will cause information about the fields to be commented with each #define. path Any DOS path including the global characters ? and *. outfile Use dos redirection to send the output to a file. Typically a dedicated clipper header file to include in your application. dStruct sends its output to Stdout allowing dStruct to display file structures to the screen. Typical program output: // Database field #defines, Produced by dStruct, 11-9-1990 // Datafile DSDEMO.DBF #define F_DSDEMO_FC 7 #define F_DS_CUSNUM 1 // Width 10 Dec 0 Type N #define F_DS_NAME 2 // Width 30 Dec 0 Type C #define F_DS_ADDR1 3 // Width 30 Dec 0 Type C #define F_DS_ADDR2 4 // Width 30 Dec 0 Type C #define F_DS_CITY 5 // Width 30 Dec 0 Type C #define F_DS_STATE 6 // Width 2 Dec 0 Type C #define F_DS_ZIP 7 // Width 10 Dec 0 Type C // END: Database field #defines. The helper functions: getRec() Parameters: None. Returns: An array as an image of the current record. Notes: getRec will return an array containing the data from the current record. getRec may be aliased to acquire a record from another area. Usage: LOCAL ary := {} ary = getRec() .... edit the array saveRec( ary ) blankRec() Parameters: None. Returns: An array as an image of a database record. Notes: blankRec will return an array containing an image of an empty record from the current or an aliased database. Usage: LOCAL ary := {} ary = blankRec() .... edit the array saveRec( ary ) saveRec() Parameters: A record array. Returns: NIL Notes: saveRec will replace each field in a record with the data in the corresponding array element. The array must be an image of the record you are replacing to avoid any type mismatches. Usage: LOCAL ary := {} ary = blankRec() .... edit the array saveRec( ary )