TYPE

Display the contents of a text file

Syntax

      TYPE <xcFile> [TO PRINTER] [TO FILE <xcOutFile>]

Arguments

<xcFile> is the name of the file, including extension, to be displayed to the screen. This argument may be specified as a literal file name or as a character expression enclosed in parentheses. <xcFile> must be specified with an extension if it has one.

TO PRINTER echoes the display to the printer.

TO FILE <xcOutFile> echoes the display to the specified file. <xcOutFile> may be specified either as a literal file name or as a character expression enclosed in parentheses. If no extension is specified, .txt is added.

Description

TYPE is a console command that displays the contents of a text file to the screen, optionally echoing the display to the printer and/or another text file. To suppress output to the screen while printing or echoing output to a file, SET CONSOLE OFF before the TYPE invocation.

If <xcFile> is specified without a path and/or drive designator, TYPE searches the current DEFAULT directory, and then, the current PATH. If <xcOutFile> is specified without a path and/or drive designator, TYPE creates the file in the current DEFAULT directory.

TYPE performs no special formatting on the listing. There are no special headings or pagination when the output is sent to the printer.

To pause output, use Ctrl-S. Note that you cannot interrupt a listing with Esc.

Examples

      .  This example illustrates the TYPE command:

      TYPE Main.prg TO PRINTER

Seealso

COPY FILE, SET DEFAULT, SET PATH, SET PRINTER

Advertisements

COPY TO

COPY TO

Export records to a new database (.dbf) file or ASCII text file

Syntax

      COPY [FIELDS <idField list>] TO <xcFile>
             [<scope>] [WHILE <lCondition>] [FOR <lCondition>]
             [SDF | DELIMITED [WITH BLANK | <xcDelimiter>] |
             [VIA <xcDriver>]]

Arguments

FIELDS <idField list> specifies the list of fields to copy to the target file. The default is all fields.

TO <xcFile> specifies the name of the target file. The file name can be specified either as a literal file name or as a character expression enclosed in parentheses. If SDF or DELIMITED is specified, .txt is the default extension. Otherwise, .dbf is the default extension.

<scope> defines the portion of the current database file to COPY. The default is ALL records.

WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.

FOR <lCondition> specifies the conditional set of records to copy within the given scope.

SDF specifies the output file type as a System Data Format ASCII text file. Records and fields are fixed length.

DELIMITED specifies the output file type as a delimited ASCII text file where character fields are enclosed in double quotation marks (the default delimiter). Records and fields are variable length.

DELIMITED WITH BLANK identifies an ASCII text file in which fields are separated by one space and character fields have no delimiters.

DELIMITED WITH <xcDelimiter> identifies a delimited ASCII text file where character fields are enclosed using the specified delimiter. <xcDelimiter> can be specified either as a literal character or as a character expression enclosed in parentheses.

See the tables below for more information regarding the format specifications for ASCII text files created using these arguments.

VIA <xcDriver> specifies the replaceable database driver (RDD) to use to create the resulting copy. <cDriver> is name of the RDD specified as a character expression. If <cDriver> is specified as a literal value, it must be enclosed in quotes.

If the VIA clause is omitted, COPY TO uses the driver in the current work area. If you specify the VIA clause, you must REQUEST the appropriate RDDs to be linked into the application.

Note: If the DELIMITED WITH clause is specified on a COPY or APPEND command, it must be the last clause specified.

Description

COPY TO is a database command that copies all or part of the current database file to a new file. Records contained in the active database file are copied unless limited by a <scope>, a FOR|WHILE clause, or a filter.

If DELETED is OFF, deleted records in the source file are copied to <xcFile> where they retain their deleted status. If DELETED is ON, however, no deleted records are copied. Similarly, if a FILTER has been SET, invisible records are not copied.

Records are copied in controlling index order if there is an index open in the current work area and SET ORDER is not zero. Otherwise, records are copied in natural order.

In a network environment, Clipper opens the target database file EXCLUSIVEly before the COPY TO operation begins. Refer to the “Network Programming” chapter.

          This table shows the format specifications for SDF text files:
          SDF Text File Format Specifications
          ------------------------------------------------------------------------
          File Element        Format
          ------------------------------------------------------------------------
          Character fields    Padded with trailing blanks
          Date fields         yyyymmdd
          Logical fields      T or F
          Memo fields         Ignored
          Numeric fields      Padded with leading blanks for zeros
          Field separator     None
          Record separator    Carriage return/linefeed
          End of file marker  1A hex or CHR(26)
          ------------------------------------------------------------------------
          This table shows the format specifications for DELIMITED and DELIMITED
          WITH <xcDelimiter> ASCII text files:
          DELIMITED Text File Format Specifications
          ------------------------------------------------------------------------
          File Element        Format
          ------------------------------------------------------------------------
          Character fields    Delimited, with trailing blanks truncated
          Date fields         yyyymmdd
          Logical fields      T or F
          Memo fields         Ignored
          Numeric fields      Leading zeros truncated
          Field separator     Comma
          Record separator    Carriage return/linefeed
          End of file marker  1A hex or CHR(26)
          ------------------------------------------------------------------------
          This table shows the format specifications for DELIMITED WITH BLANK
          ASCII text files:
          DELIMITED WITH BLANK Text File Format Specifications
          ------------------------------------------------------------------------
          File Element        Format
          ------------------------------------------------------------------------
          Character fields    Not delimited, trailing blanks truncated
          Date fields         yyyymmdd
          Logical fields      T or F
          Memo fields         Ignored
          Numeric fields      Leading zeros truncated
          Field separator     Single blank space
          Record separator    Carriage return/linefeed
          End of file marker  1A hex or CHR(26)
          ------------------------------------------------------------------------

Examples

      .  This example demonstrates copying to another database file:
      USE Sales NEW
      COPY TO Temp
      .  This example demonstrates the layout of a DELIMITED file:
      COPY NEXT 1 TO Temp DELIMITED
      TYPE Temp.txt
      Result:
      "Character",12.00,19890801,T
      .  This example demonstrates the layout of an SDF file with four
      fields, one for each data type:
      USE Testdata NEW
      COPY NEXT 1 TO Temp SDF
      TYPE Temp.txt
      Result:
      Character     12.0019890801T
      .  This example demonstrates the layout of a DELIMITED file WITH
      a different delimiter:
      COPY NEXT 1 TO Temp DELIMITED WITH '
      TYPE Temp.txt
      Result:
      'Character',12.00,19890801,T

Seealso

APPEND FROM, COPY FILE, COPY STRUCTURE, SET DELETED

TYPE

TYPE

Show the content of a file on the console, printer or file

Syntax

      TYPE <xcFile> [TO PRINTER] [TO FILE <xcDestFile>]

Arguments

<xcFile> is a name of the file to display. If the file have an extension, it must be specified (there is no default value). It can be specified as literal file name or as a character expression enclosed in parentheses.

TO PRINTER is an optional keyword that specifies that the output should go to both the screen and printer.

TO FILE <xcDestFile> copy the source <xcFile> also to a file. If no extension is given (.txt) is added to the output file name. <xcDestFile> can be specified as literal file name or as a character expression enclosed in parentheses.

Description

TYPE command type the content of a text file on the screen with an option to send this information also to the printer or to an alternate file. The file is displayed as is without any headings or formatting.

If <xcFile> contain no path, TYPE try to find the file first in the SET DEFAULT directory and then in search all of the SET PATH directories. If <xcFile> can not be found a run-time error occur.

If <xcDestFile> contain no path it is created in the SET DEFAULT directory.

Use SET CONSOLE OFF to suppress screen output. You can pause the output using Ctrl-S, press any key to resume.

Examples

      The following examples assume a file name mytext.dat exist in all
      specified paths,  a run-time error would displayed if it does not

      // display mytext.dat file on screen
      TYPE mytext.dat

      // display mytext.dat file on screen and printer
      TYPE mytext.dat TO PRINTER

      // display mytext.dat file on printer only
      SET CONSOLE OFF
      TYPE mytext.dat TO PRINTER
      SET CONSOLE ON

      // display mytext.dat file on screen and into a file myreport.txt
      TYPE mytext.dat TO FILE MyReport

Compliance

Clipper

Seealso

COPY FILE, SET DEFAULT, SET PATH, SET PRINTER, __TypeFile()

COPY FILE

 

COPY FILE

Copies a file.

Syntax

      COPY FILE <cfile> TO <cfile1>

Arguments

<cFile> Filename of source file <cFile1> Filename of target file

Description

This command makes an exact copy of <cFile> and names it <cFile1>. Both files must have the file extension included; the drive and the directory names must also be specified if they are different from the default drive and/or director. <cFile1> also can refer to a OS device (e.g. LPT1). This command does not observe the SET PATH TO or SET DEFAULT TO settings.

Examples

      COPY FILE C:\harbour\tests\adirtest.prg TO C:\temp\adirtest.prg
      COPY FILE C:\harbour\utils\hbdoc\gennf.prg TO LPT1

Compliance

Clipper

Seealso

ERASE, RENAME, FRENAME(), FERASE()

__TypeFile()

Template

Function

Name

__TypeFile()

Category

API

Subcategory

Terminal

Oneliner

Show the content of a file on the console and/or printer

Syntax

      __TypeFile( <cFile>,  [<lPrint>] ) --> NIL

Arguments

<cFile> is a name of the file to display. If the file have an extension, it must be specified (there is no default value).

<lPrint> is an optional logical value that specifies whether the output should go only to the screen (.F.) or to both the screen and printer (.T.), the default is (.F.).

Returns

__TypeFile() always return NIL.

Description

__TypeFile() function type the content of a text file on the screen with an option to send this information also to the printer. The file is displayed as is without any headings or formatting.

If <cFile> contain no path, __TypeFile() try to find the file first in the SET DEFAULT directory and then in search all of the SET PATH directories. If <cFile> can not be found a run-time error occur.

Use SET CONSOLE OFF to suppress screen output.

You can pause the output using Ctrl-S, press any key to resume.

__TypeFile() function is used in the preprocessing of the TYPE command.

Examples

      The following examples assume a file name mytext.dat exist in all
      specified paths,  a run-time error would displayed if it does not

      // display mytext.dat file on screen
      __TypeFile( "mytext.dat" )

      // display mytext.dat file on screen and printer
      __TypeFile( "mytext.dat",  .T. )

      // display mytext.dat file on printer only
      SET CONSOLE OFF
      __TypeFile( "mytext.dat",  .T. )
      SET CONSOLE ON

Compliance

Clipper

Files

Library is core

Seealso

COPY FILE, SET DEFAULT, SET PATH, SET PRINTER, TYPE

SP_TAGMARRAY

TAGMARRAY()

  Short:
  ------
  TAGMARRAY() Tag elements in muti-dimensioned array

  Returns:
  --------
  <aTagged> => an array of numbers representing the
  tagged elements

  Syntax:
  -------
  TAGMARRAY(aArray,[cTitle],[cMark],[aTags],[aHeads])

  Description:
  ------------
  A popup which allows tagging/untagging of elements in
  <aArray>, which is a multi-dimmed array of the format
  {array(n),array(n)} such as is returned by DIRECTORY() or DBSTRUCT().

    SPACE   = Tag/Untag
    F10     = Done
    ESC     = Abort
    ALT-A   = Tag All
    ALT-U   = Untag All
    ALT-S   = Swap Tagged/untagged

  The return value <aTagged> is an array of integer
  values representing the offsets into the original array <aArray> which
  were tagged.

  [cTitle] is a string to be used as the box title

  [cMark]  is the tag character. Default is chr(251) - checkmark

  [aTags]  is an array of logicals the same length as
  <aArray>. This allows pre-tagging. You may also use this
  array on return from the function. The (.T.) elements
  correspond to the tagged elements in <aArray>.

  [aHeads] is an array for the column titles for each
  subarray element in <aArray>, and needs to be the same length
  as a subarray of <aArray>

  Examples:
  ---------
   aDir  := directory()

   aCols := {"File","Size","Date","Time","Attribute"}

   aCopy := tagmarray(aDir,"Select Files for copying",nil,nil,aCols)

   for i = 1 to len(aCopy)

     COPY FILE (aDir[aCopy[i],1 ]) TO (cDestination)

   next

  Notes:
  -------
  Coded by Matthew Maier - thanks.

  Source:
  -------
  S_TAGAM.PRG

 

C5_COPY FILE

 COPY FILE
 Copy a file to a new file or to a device
------------------------------------------------------------------------------
 Syntax

     COPY FILE <xcSourceFile> TO <xcTargetFile>|<xcDevice>

 Arguments

     <xcSourceFile> is the name of the source file to copy including the
     extension.

     <xcTargetFile> is the name of the target file including the
     extension.

     Both arguments can be specified as literal file names or as character
     expressions enclosed in parentheses.  COPY FILE supplies no default
     extensions.

     <xcDevice> is the name of the device where all subsequent output
     will be sent.  You can specify a device name as a literal character
     string or a character expression enclosed in parentheses.  Additionally,
     a device can be either local or network.  If you COPY TO a non-existing
     device, you create a file with the name of the device.  When specifying
     device names, do not use a trailing colon.

 Description

     COPY FILE is a file command that copies files to and from the Clipper
     default drive and directory unless you specify a drive and/or path.  If
     the <xcTargetFile> exists, it is overwritten without warning or error.

 Examples

     .  This example copies a file to a new file and then tests for
        the existence of the new file:

        COPY FILE Test.prg TO Real.prg
        ? FILE("Real.prg")                  // Result: .T.

 Files   Library is EXTEND.LIB.

See Also: COPY TO RENAME SET DEFAULT