[Gambas-user] Gambas Linux Shell - GSH

Brian G brian at westwoodsvcs.com
Sun Jan 2 22:09:31 CET 2022


Playground help is also supported in the shell

> help loop
Please select Choice using number
0) Event Loop
1) LOOP
2) Loop Control Structures
3) loops_break
0

NAME
event loop
The event loop is an internal function of the Gambas interpreter that waits for
system events and dispatch them as they arrive.
These system events can come from the user interface, from a child process, from
a timer... They are usually followed by a normal Gambas.


See also
    * Event_Loop

> help loop
Please select Choice using number
0) Event Loop
1) LOOP
2) Loop Control Structures
3) loops_break
2
NAME
Loop Control Structures
BREAK             Leaves a loop immediately.
CONTINUE          Jumps to the next occurence of a loop.
DO ... LOOP       Infinite loop.
FOR ... NEXT      Counter loop.
FOR_EACH ... NEXT Enumeration loop.
REPEAT ... UNTIL  Loop with an exit test at the end.
WHILE ... WEND    Loop with an exit test at the beginning.

>


> playground
Listing Playground Examples
Process Response
  1) 100 doors                                                   28) Exceptions                   .....
  2) ABC Problem                                                 29) Execute a system command     .....

........ List Everything in playground ......                                          
 
Enter the Number of the example you would like to work with 0 or Q to quit? > 2

Function loaded it may be executed by entering : abc_problem
 or edited by entering : edit abc_problem
> List abc_problem
Public Sub abc_problem()
Dim sCheck As String[] = ["A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "CONFUSE"]
Dim sBlock As String[] = ["BO", "XK", "DQ", "CP", "NA", "GT", "RE", "TG", "QD", "FS", "JW", "HU", "VI", "AN", "OB", "ER", "FS", "LY", "PC", "ZM"]
Dim sList As New String[]
Dim siCount, siLoop As Short
Dim sTemp, sAnswer As String
 
For Each sTemp In sCheck
  sAnswer = ""
  sList = sBlock.Copy()
  For siCount = 1 To Len(sTemp)
    For siLoop = 0 To sList.Max
      If InStr(sList[siLoop], Mid(sTemp, siCount, 1)) Then
        sList.Extract(siLoop, 1)
        sAnswer &= Mid(sTemp, siCount, 1)
        Break
      Endif
    Next
  Next
 
 If sAnswer = sTemp Then 
   Print sTemp & " - True"
 Else
   Print sTemp & " - False"
 End If
Next
 
End

> abc_problem
A - True
BARK - True
BOOK - False
TREAT - True
COMMON - False
SQUAD - True
CONFUSE - True

> edit abc_problem

>




"Failure is the key to success; 
 each mistake teaches us something"  .. Morihei Ueshiba
Brian G

----- On Dec 30, 2021, at 8:34 AM, Brian G brian at westwoodsvcs.com wrote:

> In the shell it is possible to do things such as
> 
> if `ls -l | tr [a-z] [A-Z] > $a` = 0 then
>    print $a
> else
>    echo the command failed
> endif
> 
> from the command line or in a script
> 
> or shortcuts such as
> 
> tcb Thisfile                       ' Copy this file to the clipboard
> 
> !fcb > "thisfile"                  ' copy clipboard to a file
> !fcb | tc [a-z] [A-Z] | less       ' pass clipboard contents to a process
> !fcb > $a                          ' clipboard To a global variable for use in a
> script
> fromclipboard                      ' just print clipboard to the terminal
> 
> browse                             ' Opens a filebrowser in the current
> directory with no wait
> browse /                           ' Opens the file  browser at the root
> directory
> 
> google "New Socks"                 ' Opens the default internet browser search
> page
> 
> for each s as string in $"a{b..f}/filename" ' auto file name expansion and
> enumeration
>    touch {s}
> next
> 
> 
> "Failure is the key to success;
> each mistake teaches us something"  .. Morihei Ueshiba
> Brian G
> 
> ----- On Dec 29, 2021, at 6:11 PM, Martin Belmonte mbelmonte at belmotek.net wrote:
> 
>> El 29/12/21 a las 23:14, Brian G escribió:
>>> Hi Everyone,
>>> Over the past couple of years I have developed a Gambas interactive shell, It is
>>> finally at a point where I have been using as my daily driver at work and home.
>>> In my environment it replaces bash for the most part.
>>> 
>>> It can be found here [ https://github.com/justlostintime/GambasShell/wiki |
>>> https://github.com/justlostintime/GambasShell/wiki ]
>>> 
>>> If anyone finds it interesting I would love some feedback.
>> Great, congratulations. I see there is a pdf manual and quite a lot of
>> documentation, good point.
>> I am now trying to make a CAD with gambas, so I don't know if I will be
>> able to test but you never know.
>> Martín.
>> 
>> 
>> 
>> 
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


More information about the User mailing list