WebExeBuilder Documentation

clearVariables

Category: Variable Management

Namespace: web.variables.clearVariables

Description

Clears specific variables or all variables from memory.

Syntax

// Clear all variables
await web.variables.clearVariables();

// Clear specific variables (positional string argument)
await web.variables.clearVariables('theme,language,fontSize');

Parameters

  • variableNames (optional) - Comma or pipe-separated list of variable names to clear. If omitted, clears all variables.

⚠️ Note: The argument is a positional string, not an options object. Use clearVariables('theme,language') not clearVariables({ variableNames: 'theme,language' }).

Returns

Promise - Resolves with a message indicating how many variables were cleared

Examples

Clear all variables

await web.variables.clearVariables();
console.log('All variables cleared');

Clear specific variables

// Clear only theme and language settings
await web.variables.clearVariables('theme,language');
console.log('Theme and language cleared');

Reset to defaults

// Clear old settings and set new defaults
// NOTE: setVar and getVar use positional string args
await web.variables.clearVariables();

await web.variables.setVar('theme', 'light');
await web.variables.setVar('language', 'en');
await web.variables.setVar('fontSize', '12');
await web.variables.saveVariables();

console.log('Reset to defaults');

Use Cases

  • Reset application to defaults
  • Clear user preferences
  • Remove specific cached data
  • Implement "Clear All Data" feature
  • Clean up temporary variables

Notes

  • If argument is empty or omitted, clears ALL variables
  • Variable names can be separated by comma (,) or pipe (|)
  • Only clears variables that exist — no error for non-existent names
  • Returns count of variables actually cleared
  • Does not affect saved files — only in-memory variables
  • Call saveVariables() after clearing if you want the cleared state persisted to disk