Global Variables, Lexical Scope & Data Types

I'm struggling to understand how to properly use Global Variables. I had asked a question about them on Reddit and between the help received there and my own tinkering I was able to sort myself out on one issue (global variables in a for loop).

It turns out that if your data type is a Number you cannot expect it to work as an argument in a for loop. Changing it to Text fixed my problem.

In exploring a different way to accomplish my desires (a simple list of upcoming events) I ran into a different problem - Lexical Scope being missed in Komponents.

Refernce: https://www.reddit.com/r/kustom/comments/pxn0n4/comment/her6a31/?utm_source=share&utm_medium=web2x&context=3

I've attempted to replicate your method in my own way. Do you know why the lexical scope of these "komponents" is being ignored? It looks like $gv(title)$ is scoping to the first komponent child rather than its own global definition.

This is in reference to having a list of child Komponents, each one has it's own set of globals for:

  1. Their index in the parent container
  2. A calendar event title derived from that index
    $ci(title, gv(idx))$‚Äč

Frankly, both of these problems feel like bugs. If anyone can clarify how Globals are meant to be used, I'd appreciate it.

Edits: Formatting