• Login
  • login to access premium content (it's free).

A Simple Convention for Passing Multiple Variables: The 2-Column Table

When working in environments or languages that don't support named parameters, flexible objects, or complex data structures, passing around multiple variables can quickly become messy.

To bring clarity and consistency to this challenge, I’ve adopted a simple but powerful convention: using 2-column tables as a lightweight way to group and pass around multiple variables.

The Problem

In many scripting or embedded environments, passing multiple values to a function often means juggling a long list of arguments or relying on position-based parameters. This can be:

  • Hard to read
  • Easy to break
  • Difficult to extend

Let’s say you want to pass the following values:

username    terry
role        admin
active      true

In traditional function calls, this might turn into something like:

doSomething("terry", "admin", true)

Now imagine you add a new parameter. Do you add it at the beginning? At the end? What about backward compatibility?

The Solution: 2-Column Tables

Instead, I use table with two columns: one for the variable name, and one for its value.

Example Format

username    terry
role        admin
active      true

This format is easy to read, easy to debug, and easy to extend. It has all the benefits of named parameters without the syntactic overhead.

Benefits

  • Human-readable – easy to skim and understand
  • Extensible – add or remove variables without breaking code
  • Perfect for building API connections works with html, xml, and JSON data structures as a common intermediary
  • Debug-friendly – output logs can show exactly what's being passed around

Example Use Case

See my article on how to handle JSON with HTML/OS

Inside the function, you can grab a varible by using getvalue(table,'username') == 'terry' and handle accordingly.

When to Use This

This pattern works especially well when:

  • You are working with JSON data structures
  • You are connecting to an external API
  • You want clear logging or debugging output

It can be used as an elegant way to handle JSON, or named parameters. It's a clean, elegant solution.