Hmmm.... nothing like having a nice dinner, then sitting down and doing a little kixtart koding, eh Les ? Don't know about you, but I never get tired of Turkey leftovers ... burrrppp ... excuse me ...

Anyway .... here'a a rather hastily written, over-wraught, tortured start to this endeavor ... the UDF is called PIPE() and it goes like this ...

$output = pipe("net user")

for each $line in output
?"output"
next

code:

break on


$output = pipe("net user")


for each $line in $output
?"$line"
next


exit


function pipe($command)
;
; function: pipe() - Submits a command to %comspec% and pipes output to internal array
;
; example:
;
; $array = pipe("ddd")
;
; remarks:
;
; Do not specify any redirection of stdout or stderr in $command string
; Blank (null) lines are not included in output ( i think )
;
dim $i,$fn,$chunk
dim $array[9] ; init dim of working array
$chunk = ubound($array) ; size of realloc chunk
$fn = "%temp%\pipe.tmp" ; temp file for output
shell '%comspec% /c $command >"$fn" 2>nul'
if open(1,"$fn") = 0 ; open temp file
$i=0 ; used to index entire array
$line = readline(1) ; get a line
while not @error ; while not EOF
if $line ; skip whitespace
$array[$i] = $line ; stuff it
if $i = ubound($array) ; time to grow the array ?
redim preserve $array[$i+$chunk] ; yup - grow arraysize by $chunk
endif
$i=$i+1 ; inc index count
endif
$line = readline(1) ; get next line
loop
$=close(1) ; close 'er up
redim preserve $array[$i] ; trim back array to actual size
$pipe = $array ; pass it back to caller
endif
endfunction


-Shawn

[ 15 October 2001: Message edited by: Shawn ]