• <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
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
      • Logic Namespace
        • Logic Action Invoker Namespace
        • Logic.eval Action
        • Logic.getSymbol Action
        • Logic.getSymbolMetadata Action
        • Logic.getSymbolValue Action
        • Logic.invoke Action
        • Logic.updateSymbolValue Action
      • Message Namespace
      • Path Namespace
      • Settings Namespace
      • Sqlite Namespace
      • System Namespace
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Logic.eval Action

Format
s = CS.Logic.eval(logic := ...)
ArgumentDescriptionTypes / Required
logicThe logic statement(s).string
required
Description
The Logic.eval action evaluates and runs one or more logic statements.
As of CSPro 8.0, the full compiler is not available at runtime and thus the action can only call execute user-defined functions that use numeric and string parameters. This limitation also means that only numeric constants and string literals can be passed as arguments to the CSPro function. This limitation will be removed in a future version.
Because logic functions can display UI elements, it is a good idea to use the asynchronous version of this action when using this action from a web view.
User-defined functions can also be executed at runtime using the Logic.invoke action and the invoke function.
Return Value
The action returns the result of the last statement as a number or string.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form or if there is an error compiling the logic.
Example (HTML + JavaScript)
This example uses the asynchronous version of Logic.eval to ensure that the UI elements of the Report.view function call are displayed correctly.
<h1>District Reports</h1>

<p>Select a province or district report to view:</p>

<ul>
   
<li><a href="#" onclick="showDistrictReport(1); return false;">Artesia</a>
       
<ul>
           
<li><a href="#" onclick="showDistrictReport(1, 1); return false;">Dongo</a></li>
           
<li><a href="#" onclick="showDistrictReport(1, 2); return false;">Varda</a></li>
       
</ul>
   
</li>
</ul>

<script>
    const CS = new CSProActionInvoker();

    function showDistrictReport(province, district) {
        CS.Logic.evalAsync({
            logic: `ShowDistrictReport(${province}, ${district ? district : "notappl"});`
        })
        .catch(e => {
            CS.UI.alertAsync({
                text: e.message
            });
        });
    }
</script>
The logic function that is called by the above JavaScript:
function ShowDistrictReport(numeric province, numeric district)
   
// generate report...
end;
See also: Logic Action Invoker Namespace, Logic.invoke Action