* Note: This is a procedure (part of a program) is designed to be called * from your program. The following two lines are an example of how * this would look. DO make_dbf WITH "question" && call procedure and pass file name QUIT && end program * Note: The following is a procedure to create a fixed (always the same) * database. You can add question prompts to allow a user to build * a database with custom field names and sizes if you want. PROCEDURE make_dbf PARAMETER dbf_name && this is passed variable IF .NOT. FILE(TRIM(dbf_name) + ".dbf") && is database file not here? IF UANSI() && does user have ANSI color? SET COLOR TO G && green ENDIF ? "* Creating new data file..." && tell user what is happening SELECT 1 && first (of 9 possible) channels CREATE newstruc && make a temp database * The NEWSTRUC file has this format: * field_name C 10 && 10 characters * This is the name of the field you want to make. * field_type C 1 && 1 character * This is the type of information that will be stored in the above * named field - Character, Number, Logical, Date, Memo * field_len N 3 (C#/N#/L1/D8/M10) && 1 or 3 digit number * This is the length of the data to be stored in the above named field - * Character (1-200), Number (1-19), Logical (1), Date (8), Memo (10) * field_dec N 3 && 3 digit number * If the above named field is a number then this is the number of * digits past the decimal point. One extra digit will be taken away * from the "field_len" number for the decimal point itself USE newstruc && open temp database APPEND BLANK && add a blank record to the database REPLACE field_name WITH "QUESTION" && first field is named "QUESTION" REPLACE field_type WITH "C" && it will hold characters REPLACE field_len WITH 79 && it will hold up to 79 characters APPEND BLANK && add another blank record to the file REPLACE field_name WITH "ANSWER" && first field is named "ANSWER" REPLACE field_type WITH "C" && it will hold characters REPLACE field_len WITH 50 && it will hold up to 50 characters APPEND BLANK && add another blank record to the file REPLACE field_name WITH "USERNAME" && first field is named "USERNAME" REPLACE field_type WITH "C" && it will hold characters REPLACE field_len WITH 35 && it will hold up to 35 characters APPEND BLANK && add another blank record to the file REPLACE field_name WITH "DATE" && first field is named "DATE" REPLACE field_type WITH "D" && it will hold a date REPLACE field_len WITH 8 && it will ALWAYS hold 8 characters * Note: Date fields MUST be a length of 8! Any other length will cause errors! APPEND BLANK && add another blank record to the file REPLACE field_name WITH "SCORE" && first field is named "SCORE" REPLACE field_type WITH "N" && it will hold numbers REPLACE field_len WITH 10 && it will hold up to 10 digits REPLACE field_dec WITH 2 && it will have 2 digits past decimal * Note: The above number will look like: #######.## * Notice 10 digit overall length, 7 digit whole number, 2 digits past decimal. USE && close database file CREATE (dbf_name) FROM newstruc && make the real data file USE && close database file ERASE newstruc.dbf && clean up temp file ENDIF RETURN && go back to calling part of program