

include "$/inc/minwin.inc"


function GetExeDir() as string
================================
char* s=getCommandline
byte *b=strptr s
sys bb=@b,bs=@b,mm=0,ms=0
do
  select case b
  case 0  : exit do
  case 32 : if mm=0 then exit do '   space (no quote at start)
  case 34 : if mm   then exit do ' " double quote
            mm=@b
            bs=@b+1
  case 47 : ms=@b             ' / fwd slash
  case 92 : ms=@b             ' \ back slash
  end select
  @b++
end do
if ms then return mid s,bs-bb+1,ms-bs
end function

print GetExeDir
