
includepath "$\inc\"
'% filename  "z.exe"
'include     "RTL32.inc"
include     "console.inc"

 library "kernel32.dll"
'! GetCommandLine alias "GetCommandLineA"  () as char*
 ! GetEnvironmentStrings alias "GetEnvironmentStringsA" () as sys
 ! FreeEnvironmentStrings alias "FreeEnvironmentStringsA"  (sys p)
 ! GetEnvironmentVariable alias "GetEnvironmentVariableA" (char*var,*buf,sys n) as sys
 library ""

indexbase 1
sys p=GetEnvironmentStrings()
sys k
string s=nuls 8000
byte b at  (p)
byte r  at  strptr s
byte rb at  strptr s
do
  select b
  case 0 : r=13 : @r++ : r=10 : @r++ : k++
           if b[2]=0 then exit do
  case 1 to 255 : r=b : @r++
  end select
  @b++
end do
s=left s,@r-@rb

printl s
printl "count:" tab k
printl "length:"tab @r-@rb
FreeEnvironmentStrings(p)

string v=nuls 256
GetEnvironmentVariable "ComSpec",v,len v
printl "ComSpec:" cr rtrim v

v=nuls 8000
GetEnvironmentVariable "Path",v,len v
printl "Path:" cr rtrim v



waitkey









