11-01-2023, 07:27 PM
fixed an error occuring in multifile selection
this is the new code that runs ok
this is the new code that runs ok
Code: (Select All)
Sub RunFile (file$, I%)
ReDim As String Dir(0), File(0)
$If WIN Then
slash$ = "\"
$Else
slash$ = "/"
$End If
GetFileList file$, Dir(), File()
'first, count bas files
max = UBound(File)
ReDim bbas$(max)
For i = 1 To max
If LCase$(Right$(File(i), 4)) = ".bas" Then counter = counter + 1: bas$ = File(i): num = i: bbas$(counter) = bas$
Next
If counter < max Then ReDim _Preserve bbas$(counter)
' selecting file.bas to run
If SI(I%).Status = "Multifile" Then
'pop up menu with files .BAS
a& = _Dest
_Dest 0
chosen = 1
Locate 10, 45: Print "arrows " + Chr$(24) + " " + Chr$(25) + " for choosing and Enter for running"
Do
Locate 12, 45
For i = 1 To counter
If i = chosen Then Color Black, Blue Else Color White, Black
Locate , 45: Print bbas$(i)
Next
k = _KeyHit
Select Case k
Case 18432
'up
If chosen > 1 Then chosen = chosen - 1
Case 20480:
'down
If chosen < counter Then chosen = chosen + 1
End Select
_Dest a&
_Display
Loop Until k = 13
bas$ = bbas$(chosen)
ElseIf LCase$(Right$(_Trim$(SI(I%).Status), 4)) = ".bas" Then
' it is a chain of programs and status is the head of the chain
bas$ = LCase$(_Trim$(SI(I%).Status))
ElseIf SI(I%).Status = "Monofile" Or counter = 1 Then
' do nothing because file has already been selected
End If
' running file.bas choosen
' If counter = 1 Then
path$ = _CWD$ + slash$ + file$ + slash$
exe$ = path$ + Left$(bas$, Len(bas$) - 4) + ".exe"
If _FileExists(exe$) Then 'see if that bas file has been turned into an exe file already
Shell Chr$(34) + exe$ + Chr$(34) 'if so, then just run it
Else
b$ = path$ + bas$
If _FileExists("..\qb64pe.exe") Then pe$ = "pe" Else pe$ = "" ' path corrected for working both with QB64 both QB64pe
Shell _Hide "..\qb64" + pe$ + " -c " + Chr$(34) + b$ + Chr$(34) + " -o " + Chr$(34) + exe$ + Chr$(34)
Shell Chr$(34) + exe$ + Chr$(34)
End If
' End If
screenchanged = -1
_KeyClear
End Sub