COMMAND$ and wildcards on files
#5
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
Reply


Messages In This Thread
COMMAND$ and wildcards on files - by zaadstra - 12-24-2022, 05:12 PM
RE: COMMAND$ and wildcards on files - by SMcNeill - 12-24-2022, 07:35 PM
RE: COMMAND$ and wildcards on files - by zaadstra - 12-25-2022, 12:33 AM
RE: COMMAND$ and wildcards on files - by SMcNeill - 12-25-2022, 12:48 AM
RE: COMMAND$ and wildcards on files - by mdijkens - 12-25-2022, 08:10 AM
RE: COMMAND$ and wildcards on files - by zaadstra - 12-25-2022, 04:23 PM
RE: COMMAND$ and wildcards on files - by zaadstra - 12-29-2022, 05:58 PM
RE: COMMAND$ and wildcards on files - by mdijkens - 12-30-2022, 01:01 PM
RE: COMMAND$ and wildcards on files - by mdijkens - 12-30-2022, 06:11 PM
RE: COMMAND$ and wildcards on files - by zaadstra - 01-17-2023, 10:12 PM
RE: COMMAND$ and wildcards on files - by zaadstra - 01-19-2023, 05:25 PM
RE: COMMAND$ and wildcards on files - by mdijkens - 01-19-2023, 05:59 PM
RE: COMMAND$ and wildcards on files - by zaadstra - 01-19-2023, 07:31 PM



Users browsing this thread: 5 Guest(s)