@Sergei.Shutov   $e(112345678) prevents you to pass N>9

           1
          121
         12321
        1234321
       123454321
      12345654321
     1234567654321
    123456787654321
   12345678987654321
  123456781087654321
 123456781187654321
123456781287654321
 123456781187654321
  123456781087654321
   12345678987654321
    123456787654321
     1234567654321
      12345654321
       123454321
        1234321
         12321
          121
           1
 


@Julius Kavay    similar issue, but limit is 16

My interpretation was N>9  is any number >9

UTC: 2021-01-10 21:39:34

N<=9 :   73 chr

f i=1:1:N w ! f j=1:1:i,i-1:-1:1 w !?N-j f l=1:1:j {w l} f r=l-1:-1:1 w r

N>9 : 78 chr

f i=1:1:N w ! f j=1:1:i,i-1:-1:1 w !?N-j f l=1:1:j {w l#10} f r=l-1:-1:1 w r#10
 
eg: N=14

in your ClassMethod you operate on Server side.

the equivalent to zenPage on Client side is  %page on Server side.
And methods on Server side all start with %.. and strings use double quotes.
It is ISOS/COS not JS !

try:

set ref=%page.%GetComponentById("clinic")

https://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?&LIBRARY=%25SYS&CLASSNAME=%25ZEN.Component.abstractPage#%25GetComponentById

OK. The first time I followed to the end. 
The code I was forced to produce by time pressure is so ugly and dirty that I refuse to publish it.
Nevertheless a  clear demonstration for what was ISOS (aka COS) NOT designed for:
Higher mathematical calculus, matrix transformations, arrays with independent dimensions, ....
[ Though I have to admit that I encountered tensors, rotors, matrix transformations, Mr. Fermat's theories, ... only at university 50+ years ago. And I didn't miss it in between angel]

There was no demand for the real strengths of IRIS!
In addition, I verified my personal credo that writing some code in ISOS/COS
only because it is possible makes no sense and is of no commercial value.
Especially with the broad range of options in  IRIS to include external code.   

I fully support you.
Out of tradition, there is a tendency to implement already existing solutions though  better
and well-positioned on the markets. 
@Dmitry Maslennikov :
- you might remember times when even a webserver was written inside Caché
- or various text editors, source manager packages, and ..., and ... and ...
JUST because it was possible.

Decades back you had your globals and your language and not even an OS below.
But this was in previous millenium. This time is definitely over.