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

Write Function

Format
b = write(message ‖ msg_numʃ, argument1, ..., argumentNʅ);
Description
The write function writes text to a write file that can be used as a report. Each argument is sequentially inserted into the write string. Arguments can be numeric or alphanumeric expressions, but the type of the argument must match the type of the receiving field in the message text. If no write file is specified at run time, the write file lines are placed in the default data entry or batch error report.
In the string expression:
%[n]d = Insert a number and display it as an integer
%[n.d]f = Insert a number and display it as a decimal value
%[n.d]s = Insert a text string
where "n" is the size of the field and "d" is the number of decimal places to show for a number. For a complete list of possible message formatters, see Message Formatting Options.
Numbers are never truncated. Text strings are truncated only if ".d" is used. If "n" is positive, the insert is right-justified in the size of the field. If "n" is negative, the insert is left-justified in the size of the field. If "n" is a positive number with a leading zero, the insert is right-justified in the size of the field and zero-filled to the left. When inserting a number, if "n" is preceded by a "+", the sign of the number is always displayed.
Return Value
The function returns a logical value 1 (true) if successful and 0 (false) otherwise.
Example 1
write("Sex = %d", SEX);
Example 2
numeric integerValue = 23456;

errmsg( "%d"       , integerValue);      //  23456
errmsg( "%-10d"    , integerValue);      //  23456
errmsg( "%10d"     , integerValue);      //       23456
errmsg( "%+10d"    , integerValue);      //      +23456
errmsg( "%+010d"   , integerValue);      //  +000023456
errmsg( "%-010d"   , integerValue);      //  0000023456
errmsg( "%f"       , integerValue);      //  23456.000000  Note the usage of %f


numeric decimalValue = 12.567;

errmsg( "%f"        , decimalValue);    //   12.567000
errmsg( "%-10.3f"   , decimalValue);    //   12.567
errmsg( "%d"        , decimalValue);    //   12           Note the usage of %d
errmsg( "%10.2f"    , decimalValue);    //        12.57
errmsg( "%10.3f"    , decimalValue);    //       12.567
errmsg( "%+10.3f"   , decimalValue);    //      +12.567
errmsg( "%+010.3f"  , decimalValue);    //   +00012.567
errmsg( "%010.3f"   , decimalValue);    //   000012.567
errmsg( "%10.5f"    , decimalValue);    //     12.56700


string stringValue = "abcdef";

errmsg( "%s"        , stringValue);     //   abcdef
errmsg( "%-10s"     , stringValue);     //   abcdef
errmsg( "%-10.3s"   , stringValue);     //   abc
errmsg( "%10s"      , stringValue);     //       abcdef
errmsg( "%10.3s"    , stringValue);     //          abc
See also: FileWrite Function, LogText Function, Message Formatting Options