Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>create from</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
CREATE FROM


Syntax:     CREATE <file1>/(<expC1>) FROM <file2>/(<expC2>)

Purpose:    To create a new database file from a structure extended
            file.

Arguments:  <file1> is the name of the new database file to create
            from the structure extended file (<file2>).  The field
            definitions in the new database file are taken from the
            records of <file2>.

            <file2> is the name of a structure extended file to use
            as the structure definition for the new database file.

Usage:      CREATE FROM produces a new database file with the field
            definitions taken from the contents of a structure extended
            file.  To qualify as a structure extended file, a database
            file must contain the following four fields:


            Table: Structure of an Extended File
            -----------------------------------------------------
               Field    Name        Type      Length     Decimals
            -----------------------------------------------------
               1     Field_name     Character   10
               2     Field_type     Character   1
               3     Field_len      Numeric     3           0
               4     Field_dec      Numeric     3           0
            -----------------------------------------------------

            <File1> is automatically opened in the current work area
            after it is CREATEd.

            Data dictionaries: For data dictionary applications, you
            can have any number of other fields within the structure
            extended file to describe the extended field attributes.
            You may, for example, want to have fields to describe such
            field attributes as a description, key flag, label, color,
            picture, and a validation expression for the VALID clause.
            When you CREATE FROM, Clipper creates the new database file
            from the required fields only.  All other fields in the
            extended structure are ignored.  Moreover, Clipper is not
            sensitive to the order of the required fields.

            Field lengths greater than 999: There are two methods
            for creating a character field greater than 999 characters:

            Specify the Field_dec equal to the INT() of the desired
            length divided by 256 and the Field_len equal to the
            remainder of the length divided by 256.

            Change the length of Field_len to 5.

Library:    CLIPPER.LIB


----------------------------------- Examples -------------------------------

   CREATE New FROM Struc
   USE New
   ? LASTREC()                && Result: 0

   This example is a procedure that simulates an interactive CREATE
   utility:

   CREATE New_stru
   USE New_stru
   more_flds = .T.

   * Get the new database field names.
   DO WHILE more_flds

      APPEND BLANK
      @ 5, 0 SAY "Name.....: " GET Field_name
      @ 6, 0 SAY "Type.....: " GET Field_type
      @ 7, 0 SAY "Length...: " GET Field_len
      @ 8, 0 SAY "Decimals.: " GET Field_dec
      READ

      more_flds = (.NOT. EMPTY(Field_name))

   ENDDO

   * Remove all blank records.
   DELETE ALL FOR EMPTY(Field_name)
   PACK
   USE

   * Create the new database file.
   CREATE Newfile FROM New_stru
   ERASE New_stru.dbf


   To create a field with 4000 characters:

      .  Field_dec = INT(4000/256) = 15
      .  ld_len = 4000 % 256 = 160

   REPLACE Field_name WITH "Note";
           Field_type WITH "C",;
           Field_len  WITH 160,;
           Field_dec  WITH 15


See Also: COPY STRU EXTENDED CREATE

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson