You are here: Lua Scripting Resources eGuide > Lua Scripting API Reference Guide > Math Library Extension > setEvalSettings

12.4 setEvalSettings

math.setEvalSettings(settingStructure)

This function is used to override one or more of the current document settings for all subsequent math evaluations performed by math.eval and math.evalStr. It does not change the document context settings. The setting structure is a table of tables. Each inner table consists of the name of the document setting to override and the name of the value to use instead.

Listing 12.5: Calling math.setEvalSettings() using a table with names

settings = {
      {'Unit System', 'Eng/US'},
      {'Calculation Mode', 'Approximate'},
      {'Real or Complex Format', 'Polar'},
      {'Exponential Format', 'Engineering'}
}

math.setEvalSettings(settings)

For user convenience, setEvalSettings also accepts the ordinal number of the setting to override and the ordinal number of the value to use instead. The ordinal numbers to use correspond to the order of the settings and their values found at File > Settings > Document Settings.

Listing 12.6: Calling math.setEvalSettings() using a table with ordinal number

settingsTable = {
      {2, 3},
      {4, 3},
      {6, 3},
      {8, 2}
}

math.setEvalSettings(settingsTable)

In fact, setEvalSettings accepts any combination of names and ordinal numbers. So the following example is also valid.

Listing 12.7: Calling math.setEvalSettings() using a table with combined names and numbers

settings = {
      {3, 'Exact'},
      {'Angle Mode', 2},
      {'Real or Complex Format', 'Polar'},
      {8, 2}
}

math.setEvalSettings(settings)

The function math.setEvalSettings may be called at any point in the script app. The modified document settings are used by math.eval for all subsequent calls within the script app (unless modified by a subsequent call to setEvalSettings).

Precision of Results

All results from the TI-Nspire™ math server are returned as full-precision expressions. If users want to limit the display digits, they must call math.getEvalSettings() and apply the appropriate precision before displaying the value returned by the TI-Nspire™ math server.

Introduced in platform.apiLevel = '2.0'