I have the pleasure to propose this tool that replaces Geany or a terminal for compilation and launching binaries in my Xubuntu .
The tool has been coded with window9.bi , it works like in FbEdit with :
the choice of 1 or more fbc stored in a combo ( for Linux only 1 fbc AFAIK ) .
the choice of several command lines in a combo ,
the choice of the bas file to compile and you can store it in a combo
these commands and file names are stored in a file ini.txt . You can save to this file and reload it if needed .
the result of the compilation is displayed in a listbox , you can copy it or save it in a file
Run : 3 choices ,you can launch the bin alone , with Open Pipe or in a terminal .
Please report any problem , I use it for weeks and it's ooookayyyy !
the code below is the Linux version .
CompileAndRunLin4.bas
Code: Select all
' CompileAndRunLin4
' code by enform 2021/06
#Include Once "window9.bi"
Type w0
As HWND hw0
Declare Function OpenWindow_0() As HWND
Declare Sub DoLoop()
Declare Sub FindFbc()
Declare Sub FindBas()
Declare Sub AddToCombo()
Declare Sub DeleteInCombo()
Declare Sub LoadIni()
Declare Sub SaveIni()
Declare Sub Copycb() ' Button : Copy results to Clipbd
End Type
Dim Shared win0 As w0
'Dim Shared pwin0 As w0 Ptr = @win0
#ifdef __FB_LINUX__
#Define crlf Chr(10)
#Else
#Define crlf Chr(13,10)
#EndIf
Function w0.OpenWindow_0() As HWND
hw0 = OpenWindow("CompileAndRunLinux4 by enform 2021/06",0,10,525,550)
WindowColor(hw0,BGR(245,245,190))
SetGadgetFont(,CInt(LoadFont("Courier New",10)))
WindowBounds(hw0,525,550,525,550)
ButtonGadget(1,10,5,80,20,"Find fbc")
ButtonGadget(12,100,5,80,20,"Load ini")
ButtonGadget(14,190,5,80,20,"Save ini")
ComboBoxGadget(11,325,5,185,27) ' command line
SetGadgetColor(11,BGR(240,240,240),BGR(0,0,0),3)
'SetGadgetFont(11,CInt(LoadFont("Tahoma",9)))
ComboBoxGadget(2,10,40,500,27) ' fbc
ButtonGadget(10,10,80,120,20,"Find bas file")
GadgetToolTip(10, "then Add to combo")
StringGadget(9,10,115,500,20,"bas file here")
ButtonGadget(6,10,150,120,20,"AddToCombo")
ButtonGadget(7,140,150,70,20,"Delete")
ComboBoxGadget(8,10,190,500,27) ' bas file
ButtonGadget(3,10,235,70,20,"Compile")
GadgetToolTip(3, "Compile the selected bas file")
ButtonGadget(4,90,235,70,20,"Run bin")
'GadgetToolTip(4, "Run the compiled bas")
ButtonGadget(19,170,235,90,20,"Open Pipe")
'GadgetToolTip(19, "Run the compiled bas")
ButtonGadget(20,270,235,150,20,"Run in a terminal")
ButtonGadget(5,450,280,60,20,"Quit")
TextGadget(18,10,265,500,2,"") ' Horiz line
ButtonGadget(16,10,280,50,20,"Copy")
ButtonGadget(17,80,280,50,20,"Clear")
EditorGadget(15,10,310,500,200)
SetGadgetColor(15,BGR(210,220,220),0,1)
SetGadgetFont(15,CInt(LoadFont("Tahoma",9)))
Return hw0
End Function
win0.hw0 = win0.OpenWindow_0()
Sub w0.LoadIni() ' Button
Var hdlini = Read_File(Exepath+"/CompileAndRun.ini")
If hdlini <> Cast(Any Ptr,-1) Then
ResetAllComboBox(2)
ResetAllComboBox(8)
ResetAllComboBox(11)
Var sData = ""
While E_O_F(hdlini) = 0
sData = Read_String(hdlini)
If sData = "[FbcPath]" Then
Do
sData = Read_String(hdlini)
If sData = "[CommandLine]" Then Exit Do
AddComboBoxItem(2,sData,-1)
Loop
Do
sData = Read_String(hdlini)
If sData = "[BasFiles]" Then Exit Do
AddComboBoxItem(11,sData,-1)
Loop
Do
sData = Read_String(hdlini)
If sData = "[End]" Then Exit Do
AddComboBoxItem(8,sData,-1)
Loop
EndIf
Wend
Close_File(hdlini)
SetItemComboBox(2,0)
SetItemComboBox(8,0)
SetItemComboBox(11,0)
SetGadgetText(9,GetComboBoxText(8,0))
Else
MessBox("","ini file not found")
EndIf
End Sub
Sub w0.SaveIni() ' Button
Var r = 0
Var hdlini = Create_File(ExePath + "/CompileAndRun.ini")
If hdlini <> Cast(Any Ptr,-1) Then
Write_String(hdlini),"[FbcPath]" + Chr(13,10)
For r = 0 To CountItemComboBox(2) -1
Write_String(hdlini),GetComboBoxText(2,r) + Chr(13,10)
Next
Write_String(hdlini),"[CommandLine]" + Chr(13,10)
For r = 0 To CountItemComboBox(11) -1
Write_String(hdlini),GetComboBoxText(11,r) + Chr(13,10)
Next
Write_String(hdlini),"[BasFiles]" + Chr(13,10)
For r = 0 To CountItemComboBox(8) -1
Write_String(hdlini),GetComboBoxText(8,r) + Chr(13,10)
Next
Write_String(hdlini),"[End]" + Chr(13,10)
Close_File(hdlini)
Else
MessBox("","ini file not created")
EndIf
End Sub
Sub w0.FindBas() ' Button
Var filterL = "*(*.bas)"
Var filterR = "*.bas"
Var namebas = OpenFileRequester("","",filterL +Chr(0)+filterR ,0)
If namebas <> "" Then
SetGadgetText(9,namebas)
EndIf
End Sub
Sub w0.FindFbc() ' Button
Var filterL = ""
Var filterR = ""
Var namefbc = OpenFileRequester("","",filterL +Chr(0)+filterR ,0)
If namefbc <> "" Then
AddComboBoxItem(2,namefbc,-1)
EndIf
End Sub
Sub w0.AddToCombo() ' Button
AddComboBoxItem(8,GetGadgetText(9),-1)
End Sub
Sub w0.DeleteInCombo() ' Button
DeleteComboBoxItem(8,GetItemComboBox(8))
End Sub
'
Sub w0.Copycb() ' Button : Copy to Clipbd
Var sLine = ""
For r As Long = 0 To GetLineCountEditor(15)-1
sLine += GetLineTextEditor(15,r) + crlf
Next r
SetClipBoardText(sLine)
End Sub
' main DoLoop
Sub w0.DoLoop()
Dim As String CompileBas,ln,ln1,exefile,sPath,sBas
Dim As Long event,ff,DotBas,Dot,lSlash
Do
event = WaitEvent
Select Case event
Case EventClose
Exit Do ' End
Case EventGadget
Select Case EventNumber
Case 1
FindFbc()
Case 5
Exit Do ' End
Case 6
AddToCombo()
Case 7
DeleteInCombo()
Case 8 ' combo sel changed ; copy to the string the bas file name
SetGadgetText(9,GetComboBoxText(8,GetItemComboBox(8)))
Case 10
FindBas()
Case 12
LoadIni()
Case 14
SaveIni()
Case 16
Copycb()
Case 17 ' clear results editor
SetGadgetText(15,"")
Case 3 ' direct compile
CompileBas = GetGadgetText(9)
lSlash = InStrRev(CompileBas,"/") +1
sBas = Mid(CompileBas,lSlash)
SetGadgetText(15,"Compiling " + sBas) ' not visible !
SetGadgetText(3,"Wait")
DisableGadget(4,1)
DisableGadget(19,1)
DisableGadget(20,1)
UpdateInfoXserver()
ff = FreeFile
Open Pipe(Chr(34)+ GetComboBoxText(2,GetItemComboBox(2))+ Chr(34) _
+ " " + GetComboBoxText(11,GetItemComboBox(11)) + " " + CompileBas) _
+ " " For Input As #ff
ln = ""
DotBas = 0
ln1 = "Result : " + crlf + crlf
Do Until EOF(ff)
Line Input #ff, ln ' read the pipe
DotBas = InStr(ln,".bas") ' after
If DotBas Then
ln = Mid(ln,DotBas+4) ' don't display all the path
EndIf
ln1 += ln + crlf
Loop
Close #ff
ln1 += crlf + "Make done at " + Time + crlf
SetGadgetText(15,ln1)
SetGadgetText(3,"Compile")
DisableGadget(4,0)
DisableGadget(19,0)
DisableGadget(20,0)
Case 4 ' run exe
CompileBas = GetGadgetText(9)
Dot = InStrRev(CompileBas,".") -1
exefile = Left(CompileBas,Dot)' + ".exe" ' for windows
RunProgram(exefile)
Case 19 ' Open Pipe
CompileBas = GetGadgetText(9)
Dot = InStrRev(CompileBas,".") -1
exefile = Left(CompileBas,Dot)' + ".exe"
ff = FreeFile
ln = ""
ln1 = "Open Pipe :" + crlf
Open Pipe(Chr(34)+ exefile +Chr(34))+ " " For Input As #ff
Do Until EOF(ff)
Line Input #ff, ln
ln1 += ln + crlf
Loop
Close #ff
SetGadgetText(15,ln1)
Case 20 ' Button Run in a terminal
CompileBas = GetGadgetText(9)
sPath = GetPathPart(CompileBas) + "/"
Dot = InStrRev(CompileBas,".") -1
exefile = Left(CompileBas,Dot)' + ".exe"
Shell ("xfce4-terminal" &" -H -e " & chr(34) & exefile & chr(34))' & " &")
End Select
End Select
Loop
End Sub
'
win0.LoadIni()
win0.DoLoop()
Code: Select all
[FbcPath]
/usr/local/bin/fbc
[CommandLine]
-s gui
-w all -Wl --verbose
-w all
-s gui -exx
-s gui -g
-s gui -v
-s console
-s gui -gen gcc -O 2 -v
[BasFiles]
/home/hal/Prog-linux/Projects/CutTheLine/CutTheLineLin5h.bas
/home/hal/Prog-linux/Projects/CompileAndRun/CompileAndRunLin3.bas
/home/hal/Prog-linux/Projects/CompileAndRun/CompileAndRunLin4.bas
/home/hal/Prog-linux/Projects/Create_ImageA.bas
[End]