• <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>

FileName Function

Format
s = filename(dictionary_name ‖ file_handler ‖ pff_name ‖ object_name ‖ paradata);
Description
The filename function returns the fully qualified name of a file. If supplying a dictionary_name, the function returns the name of the data file associated with a data dictionary. If providing a file_handler (declared in a File statement), the function returns the name of the text file associated with the file handler.
If providing a pff_name (declared in a Pff statement), the function returns the name of an existing PFF file, or the name of a temporarily created PFF file. If a PFF file was loaded (via Pff.load) and not modified, the name of that PFF file is returned. If the PFF has been modified and not saved, then calling filename will save the PFF to a temporary file and the name of that file is returned.
For several other CSPro objects, if passed an object_name, the function returns the file name associated with the content of the object. This functionality works on Audio, Document, Geometry, Image, and Report objects.
The function can also take paradata as its argument, in which case it returns the file name of the currently open paradata log.
Return Value
The function returns a string containing the folder and file name.
Example
filewrite(report_file, "Report file: %s", filename(report_file));
filewrite(report_file, "Census data file: %s", filename(CENSUS_DICT));
See also: Path Namespace, PathName Function, FileExist Function, FileSize Function