• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
        • Clear Function
        • Close Function
        • CountCases Function
        • CurrentKey Function
        • DelCase Function
        • DirCreate Function
        • DirDelete Function
        • DirExist Function
        • DirList Function
        • FileConcat Function
        • FileCopy Function
        • FileCreate Function
        • FileDelete Function
        • FileEmpty Function
        • FileExist Function
        • FileName Function
        • FileRead Function
        • FileRename Function
        • FileSize Function
        • FileTime Function
        • FileWrite Function
        • Find Function
        • Key Function
        • KeyList Function
        • LoadCase Function
        • Locate Function
        • NMembers Function
        • Open Function
        • Retrieve Function
        • Set Access Statement
        • SetFile Function
        • Set First Statement
        • Set Last Statement
        • Write Function
        • WriteCase Function
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Open Function

 

Format:

b = open(ext-dict-name | file-name[, update | append | create]);

 

Description:

The open function opens and keeps open an external file or file declared in a file statement.

 

Under most circumstances, neither an open nor a close function is necessary to manipulate the file. In data entry applications, by default, the file is opened when it is operated on with a file function, such as loadcase, writecase, readfile, or writefile and closed immediately afterward. In batch applications, by default, the file is opened at the beginning of the run and closed at the end.

 

If you want to control the opening and closing of the file, you can use the open and close functions to do this. If you code an open function anywhere is the application logic, then you must control all opening and closing of the file

 

The ext-dict-name or file-name must be supplied. Ext-dict-name is the name of a data dictionary defining an external data file. File-name is the name of a file declared in a file statement.

 

The keywords update, append or create are optional. If no keyword is coded, the file is opened in update mode.

 

When an ext-dict-name is used, if update or append is used, the file is opened, its contents are not changed, and the file is ready to update cases. If create is coded, the file is opened, all previous records are removed and the file is ready to add cases.

 

When a file-name is used, if update is used, the file is opened and you are positioned at the beginning of the file. If append is coded, the file is opened, its contents are not changed, and you are positioned at the end of the file. If create is coded, the file is opened, all previous records are removed and you are positioned at the beginning of the file.

 

Return value:

The function returns a logical value of 1 (true) if file is opened and 0 (false) otherwise.

 

Example 1:

OK = open(LOOKUP);

 

Example 2:

OK = open(REPORT, append);