• <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
        • Compress Function
        • Decompress Function
        • diagnostics Function
        • Encode Function
        • ErrMsg Function
        • ExecSystem Function (Desktop)
        • ExecSystem Function (Mobile)
        • ExecPFF Function
        • GetProperty Function
        • GetLabel Function
        • GetLanguage Function
        • GetSymbol Function
        • GetValueLabel Function
        • hash Function
        • htmldialog Function
        • InValueSet Function
        • Invoke Function
        • IsChecked Function
        • loadsetting Function
        • LogText Function
        • MaxValue Function
        • MinValue Function
        • paradata Function
        • PathConcat Function
        • PathName Function
        • savesetting Function
        • SetLanguage Function
        • SetProperty Function
        • SetValueSet Function
        • SetValueSets Function
        • Special Function
        • sqlquery Function
        • Stop Function
        • SysParm Function
        • tr Function
        • Trace Function
        • UUID Function
        • View Function
        • Warning Function
      • Date and Time Functions
      • External File Functions
      • 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>

View Function

Format
b = view(file_name ‖ website_url ‖ object_nameʃ, viewer_argumentsʅ);
Description
The view function displays a variety of media. HTML files or web pages are displayed in an embedded window using a Chromium-based web browser (Edge WebView2 on Windows; WebView on Android). In this web view, it is possible to use the Action Invoker to run user-defined functions or to execute other CSPro operations.
The first argument to the function indicates what to view:
  • file_name (string expression): The contents of the file are displayed, either in an embedded web browser, or using the system's default viewer for that file type. For example, if an Excel document is referenced, the function will open the document in Excel. However, if a HTML document is referenced, it will be shown in an embedded web browser. Documents are considered HTML if they have one of the following extensions: .html, .htm, or .cshtml.
  • website_url (string expression): An embedded web browser is used to display the website.
  • object_name: The contents of the object are displayed, generally in an embedded web browser. Passing an object to the view function is identical to calling the view function on the object using dot notation. For example, the following calls are identical:

    image_name.view();
    view(image_name);

    The following objects support viewing: Case, Document, Freq, Image, and Report.
If an embedded web browser is used, any logic coded after the view function call will not execute until the window is closed. However, if a separate application is launched, the application will continue while the external application is still active.
An alternative way to view files is to use the UI.view action, or to use CSView, which can be launched from logic by creating a PFF and calling Pff.exec.
Viewer Arguments
Optional named arguments can be used to control how the embedded web browser displays on Windows:
  • title := string expression giving the title of the window.
  • width := numeric expression specifying the width of the window in display units.
  • height := numeric expression specifying the height of the window in display units.
  • showCloseButton := conditional expression that, if false, hides the window's Close button.
If either the height or width is specified, then both values must be provided. Hiding the Close button also removes the margin around the web browser, so the browser will fill the entire embedded window.
Return Value
The function returns a logical value of 1 (true) if the file exists, or the object has data, and the embedded web browser or external application was launched successfully, and 0 (false) otherwise.
Examples
// provide the URL of a website as a string
view("https://www.census.gov/data/software/cspro.html");

// provide the name of a local HTML file as a string
view("hh-report.html", title := "Household Completion Report",
                       
width := 600, height := 400,
                       
showCloseButton := false);

// provide the name of a local image file as a string
view("../Nineties Images/carn03.jpg");

// provide the dictionary name to see its case contents
view(CENSUS_DICT);
See also: HTML in CSPro, Action Invoker Execution from JavaScript Run from Web Views, Introduction to CSView