12-25-2022, 08:10 AM
I had exactly the same issue some time ago and solved it like this:
Code: (Select All)
i% = 0
p$ = getCommand$(i%)
Do While p$ <> ""
Print i%; p$
i% = i% + 1
p$ = getCommand$(i%)
Loop
End
Function getCommand$ (n%)
$If WIN Then
Static cmd$(100), ccount As Integer
If cmd$(0) = "" Then
Declare Library
Function getCommandLine%& Alias GetCommandLineA ()
End Declare
Dim m As _MEM, ms As String * 1000
a%& = getCommandLine: m = _Mem(a%&, Len(ms)): ms = _MemGet(m, m.OFFSET, String * 1000)
ms = _Trim$(Left$(ms, InStr(ms, Chr$(0)) - 1))
ccount = 0: sp0% = 1: sp1% = InStr(ms, " ")
Do While sp1% > 0
cmd$(ccount) = _Trim$(Mid$(ms, sp0%, sp1% - sp0%))
If cmd$(ccount) <> "" Then ccount = ccount + 1
sp0% = sp1% + 1: sp1% = InStr(sp1% + 1, ms, " ")
Loop
cmd$(ccount) = _Trim$(Mid$(ms, sp0%)): If Left$(cmd$(ccount), 1) = Chr$(0) Then ccount = ccount - 1
_MemFree m
End If
If n% < 0 Then
getCommand$ = _Trim$(Str$(ccount))
ElseIf n% <= ccount Then
getCommand$ = cmd$(n%)
Else
getCommand$ = ""
End If
$Else
getCommand$ = Command$(n%)
$End If
End Function
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience