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

Dictionary.getDictionary Action

Format
s = CS.Dictionary.getDictionary(ʃname := ... ‖ path := ...ʅ)
ArgumentDescriptionTypes / Required
nameThe name of a dictionary associated with an application.string
not required
pathThe path of a dictionary file to read.string
not required
Description
The Dictionary.getDictionary action returns a dictionary associated with an application or loaded from the disk. One, and only one, of the arguments name or path must be provided.
If specifying name, you can also specify the name of an application or form file. When using an application name, the application's main dictionary is returned. When using a form file name, the dictionary associated with the forms is returned.
If neither name nor path are specified, the application's main dictionary is returned.
Return Value
The action returns the dictionary.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form, or if:
  • No dictionary, or associated dictionary, exists with the specified name.
  • The dictionary file does not exist or cannot be read.
Example (JavaScript)
// write to the console all of the item names along with their parent record
const dictionary = CS.Dictionary.getDictionary({
    path: 
"Census Dictionary.dcf"
});

dictionary.levels.forEach(level => {

    level.ids.items.forEach(item => {
        console.log(`ID: ${item.name}`);
    });

    level.records.forEach(record => {
        record.items.forEach(item => {
            console.log(`${record.name}: ${item.name}`);
        });
    });
});
Example (CSPro Logic)
// construct the input needed for the questionnaire view, using the external dictionary
// attached to this application but getting the forms and question text from the disk
string questionnaireViewInput =
   
maketext("{ \"dictionary\": %s, \"forms\": %s, \"questionText\": %s, \"case\": %s }",
             
CS.Dictionary.getDictionary(name := "MARINE_DICT"),
             
CS.Application.getFormFile(path := "Marine Mammals Survey.fmf"),
             
CS.Application.getQuestionText(path := "Marine Mammals Survey.ent.qsf"),
             
CS.Data.getCase(name := "MARINE_DICT"));

// pass this input to the questionnaire view
CS.UI.view(path := Path.concat(html, "questionnaire-view", "index.html"),
           
inputData := @object questionnaireViewInput);
See also: Dictionary Action Invoker Namespace, Application.getQuestionnaireContent Action