Main sections
SHELLCMD()
ok# = SHELLCMD(cmd$, wait#, show#, rv##)
Executes another program. If you want to execute DOS commands, you have to call CMD or COMMAND (on Win9x/ME) and then enter the DOS command. e.g. "CMD /C dir > files.txt"
wait# specifies whether to wait for completion of the other program (TRUE / FALSE)
show# allows you to start the program hidden (TRUE / FALSE).
ok# returns TRUE or FALSE, depending on whether the program could be started or not.
The return value of the other program will be transferred to rv##
// --------------------------------- //
// Project: SHELLCMD
// Warning: Sophisticated program ahead!
DIM files$[1]
 ListFiles(files$[])
 
 FOR i=0 TO BOUNDS(files$[], 0)-1
  PRINT "-" + i + ":" + files$[i], 0, i*16+32
 NEXT
 SHOWSCREEN
MOUSEWAIT
// ------------------------------------------------------------- //
// -=#  LISTFILES  #=-
// ------------------------------------------------------------- //
FUNCTION ListFiles: names$[]
 // Diese Werte werden per Referenz übergeben:
 // names$[], 
 LOCAL tmp$[]
 win9x=FALSE
 ok = SHELLCMD("CMD /C dir /B /ON /OG > dir.txt", TRUE, FALSE, rv)
 IF ok =FALSE
  ok = SHELLCMD("COMMAND /C dir /B /ON /OG > dir.txt", TRUE, FALSE, rv)
  win9x=TRUE
 ENDIF
 IF ok=FALSE
  PRINT "Strange error - no cmd supplied!?", 0, 0
 ELSE
  IF win9x
   PRINT "Windows 9x based", 0, 0
  ELSE
   PRINT "Windows NT based", 0, 0
  ENDIF
 ENDIF
 FOR i=0 TO 255
  GETFILE "dir.txt", i, data$
  IF data$ = "NO_DATA" OR data$ = "NO_FILE" THEN RETURN i
  // realloc space for old files + new file
  DIM tmp$[i+1]
  // copy existing files into temp array
  FOR n=0 TO i-1
   tmp$[n] = names$[n]
  NEXT
  // realloc space for original array
  DIM names$[i+1]
  // copy temp files to array
  FOR n=0 TO i-1
   names$[n] = tmp$[n]
  NEXT
  // add new file
  names$[i] = data$
 NEXT
 RETURN i
ENDFUNCTION

