WebExeBuilder Documentation

getAllVars

Category: Variable Management

Namespace: web.variables.getAllVars

Description

Retrieves all stored variables as an array of key-value pairs.

Syntax

const allVars = await web.variables.getAllVars();

Parameters

None

Returns

Promise<Array> - Returns a promise that resolves with an array of objects containing key and value properties

Examples

Simple example

const allVars = await web.variables.getAllVars();
console.log('Total variables:', allVars.length);

allVars.forEach(v => {
    console.log(`${v.key} = ${v.value}`);
});

Display all settings

const allVars = await web.variables.getAllVars();

const settingsList = document.getElementById('settingsList');
settingsList.innerHTML = '';

allVars.forEach(variable => {
    const item = document.createElement('div');
    item.textContent = `${variable.key}: ${variable.value}`;
    settingsList.appendChild(item);
});

Export to JSON

// Convert all variables to a simple object
const allVars = await web.variables.getAllVars();

const varsObject = {};
allVars.forEach(v => {
    varsObject[v.key] = v.value;
});

console.log('Variables as JSON:', JSON.stringify(varsObject, null, 2));

Use Cases

  • Display all settings to user
  • Debug variable storage
  • Export variables for backup
  • List all saved preferences
  • Audit stored data

Notes

  • Returns array of objects with key and value properties
  • Returns empty array if no variables exist
  • All values are strings
  • The order of variables is not guaranteed
  • Returns current in-memory state