There's a couple of ways to very quickly test / use some gambas code in a terminal or bash script did you know?
For example gbx3 has an -e argument that "Evaluates an expression" that can be useful for a simple Eval on a string.
So if you want to do a quick sum using gambas syntax..
gbx3 -e "500\7"
# 71
If you want to do a quick Split().Join() on a string...
gbx3 -e "Split(\"$PATH\", \":\").Join(\"\n\")"
#/usr/local/sbin
#/usr/local/bin
#/usr/sbin
#/usr/bin
#/sbin
#/bin
#/usr/games
#/usr/local/games
#/snap/bin
And so on.
Another very useful trick is to use gbs3 and stdin input for an inline script using echo like
echo -e "gambas script text" | gbs3 -
Notes:
* You must use echo -e "text" if the script has escape chars like linefeed \n
* You have to use \" for doublequotes to parse them correctly if your string is encased in double quotes. if youre string is enclosed in single quotes then \" is not needed but you have to use single quotes to parse $Variables. eg . echo 'Print "Home is in the '$HOME' folder"' | gbs3
* the - arg with gbs3 to tell it to read from stdin is not actually needed, it reads piped text anyway.
Some examples...
List .txt files in home directory (it doesn't do anything, it's just an example, but it could)
echo -e "For Each s As String In Dir(User.Home, \"*.txt\")\nPrint s\nNext" | gbs3 -
#
How about if zenity is not installed but gbs3 is then have a gambas Dialog.SelectDirectory() version?
echo -e "Use \"gb.gui\"\nDialog.Title=\"Select a directory\"\nDialog.Path=\"$HOME\"\nIf Dialog.SelectDirectory() Then quit 1\nPrint Dialog.Path" | gbs3 -
#
you can do all sorts of simple zenity alternatives with that sort of code, Dialog.OpenFile() / SelectFont() / SelectColor(), also InputBox() , Message() etc
Something more advanced.
Clean out obsolete dirs in /tmp/gambas.1000 (list obsolete gambas temp dirs and offer to delete them)
echo -e 'Use "gb.gui"\nPublic Sub Main()\n Dim sDir As String = File.Dir(File.Dir(Temp()))\n Dim aObs As String[] = []\n For Each s As String In Dir(sDir, "*", gb.Directory)\n If s Match "^[0-9]+$" Then\n Print s;;\n If Not Exist("/proc" &/ s) Then aObs.Add(s)\n Endif\n Next\nPrint ""\n If Message.Question("Found " & aObs.Count & " obsolete dirs", "Remove", "Ignore") = 1 Then\n Shell "cd " & Shell(sDir) & "; rm -vrf " & aObs.Join(" ") Wait\n Endif\nEnd' | gbs3
#
this line can also be set as an alias in $HOME/.bashrc
alias gbclean='echo -e "Use \"gb.gui\"\nPublic Sub Main()\n Dim sDir As String = File.Dir(File.Dir(Temp()))\n Dim aObs As String[] = []\n For Each s As String In Dir(sDir, \"*\", gb.Directory)\n If s Match \"^[0-9]+$\" Then\n Print s;;\n If Not Exist(\"/proc\" &/ s) Then aObs.Add(s)\n Endif\n Next\nPrint \"\"\n If Message.Question(\"Found \" & aObs.Count & \" obsolete dirs\", \"Remove\", \"Ignore\") = 1 Then\n Shell \"cd \" & Shell(sDir) & \"; rm -vrf \" & aObs.Join(\" \") Wait\n Endif\nEnd" | gbs3 -'
#
Have fun