• <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
      • Numeric Values
      • String Values
      • 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
      • StringWriter Object
        • StringWriter Statement
        • StringWriter.clear Function
        • StringWriter.toString Function
        • StringWriter.write Function
        • StringWriter.writeEncoded Function
        • StringWriter.writeEncodedLine Function
        • StringWriter.writeLine Function
        • JSON Representation
      • 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
      • Synchronization Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

StringWriter.writeEncoded Function

This documentation also applies to the Report.writeEncoded function as a Report is a type of StringWriter.
Format 1
b = object_name.writeEncoded(string_expʃ, argument1, ..., argumentNʅ)
Format 2
b = object_name.writeEncoded(msg_numʃ, argument1, ..., argumentNʅ)
Description
The StringWriter.writeEncoded function writes text to a StringWriter object's string buffer (or to a templated report). The text is written after encoding the text for the StringWriter's encoding type or the templated report's format. When used as part of a Report object, the function is meant to be called from within the templated report's logic.
Each argument is sequentially inserted into the string_exp or msg_num. Arguments can be numeric or string expressions, but the type of the argument must match the type of the receiving field in the message text. See Message Formatting Options for a complete list of formatting options.
The following table summarizes the options for writing to a StringWriter:
FunctionText EncodedNewline Added
write✘
writeLine✘'\n'
writeEncoded✔
writeEncodedLine✔'\n', <br>, etc.
Return Value
The function returns a logical value of 1 (true) if successful and 0 (false) otherwise.
Example 1 (StringWriter)
StringWriter sw_html(HTML);

sw_html.
write("Terms ");
sw_html.
writeEncoded("& Conditions:");

sw_html.
writeLine("<strong>");
sw_html.
writeEncodedLine("<<< Do not use the application if you do not accept the T&Cs! >>>");
sw_html.
writeLine("</strong>");

string result = sw_html.toString();

// the result, with HTML encoding:
Terms &amp; Conditions:<strong>
&lt;&lt;&lt; Do not use the application if you do not accept the T&amp;Cs! &gt;&gt;&gt;<br></strong>
Example 2 (Report)
<?
    HOUSEHOLD_REPORT.
writeEncoded("The report was generated at: ", timestamp());

   
// alternatively, use $ to refer to HOUSEHOLD_REPORT
    $.writeEncoded("The report was generated at: ", timestamp());
?>
See also: StringWriter Object, Templated Reports