Functions in CMD Scripts

With the (now not so new) function syntax any more: anybody having time to update the examples using the function syntax http://wiki.mikrotik.com/wiki/Manual:Scripting#Functions

(note to self: a function does not need to be :global as it can be :local just fine)

Hello guys,
I am using the DateToNum and TimeToNum Functions (included in the Functions Library) to build unique filenames and log simple queues data every second.
Then I have a php script pulling those files to save their data to a MySQL DB. I do remove those files one by one using the API.
Everything works pretty good until midnight when the “00” are automatically removed and not appended to the the string for the filename so I ended up with file names like 20180917-325 instead of 20180917-000325.
Does someone know how to fix this?

Thank you guys

Guys
any one knows how to remove a space from the end of a variable? please

The code generated is having a space at the end in the file downloaded thus now allowing the user to login

Thank in advance

:local send [:parse [/system script get tg_sendMessage source]]


:local fetchrandom [ /tool fetch url="https://www.random.org/strings/\?num=1&len=12&digits=on&upperalpha=on&unique=on&format=plain&rnd=new" keep-result=yes dst-path="pass.txt"  ]

:local file "pass.txt"

:global TTGen [ [ /file get $file contents ] [:len $TTGen]-1 ] do={ :set TTGen "$TTGen" }]

 /ip hotspot user add limit-uptime=1d profile=default name=([$TTGen]) comment=("Auto created at ".[/system clock get date]."-".[/system clock get time]);

:local text "AUTH-CODE: $TTGen "


:log info $text
: delay 3

$send chat=$chatid text=$text mode="Markdown"

Here is an example on how to remove space from an variable.
Or actually it takes all text up until first space.

{
:local test "MyTest "
:put "Before *$test*"
:set test [:pick $test 0 [:find $test " "]]
:put "After *$test*"
}
Before *MyTest *
After *MyTest*