fb:porticula NoPaste
Working Open Pipe-Example(Windows)
Uploader: | ytwinky |
Datum/Zeit: | 24.01.2008 20:44:10 |
'a working example for the use of Open Pipe()
'¸2007 by ytwinky, MD
'feel free to modify this to your needs :D
Const fbLf=!"\n"
Declare Function Exists(DateiName As String) As Integer 'declare the function we want to use later..
Dim As String Path2Exe=Environ("windir") &"\System32" 'notice no trailing '\'
Dim As String ExeFile="\Ping.Exe" 'so we have to insert it here..
Dim As String WithParameter=" -a -n 1 127.0.0.1" 'don't forget the leading space ;)
Dim As String ConsoleCommand, L, ConsoleOutput
Dim As Integer FNo=FreeFile
ConsoleCommand=Path2Exe &ExeFile &WithParameter
If Not Exists(Path2Exe &ExeFile) Then
Print Path2Exe &ExeFile &" not found or not properly installed ;-))"
Sleep
End
End If
Open Pipe ConsoleCommand For Input As #FNo 'assign a filenumber to console-output
While Not Eof(FNo) 'start reading console-output..
Line Input #FNo, L 'there may be commas in the line, ignore them..
If L<>"" Then ConsoleOutput+=L &fbLf 'ignore empty lines..
Wend 'console-output reached its end
Close #FNo 'finish console-output
?ConsoleOutput
?"Eniki..";
Sleep
End
Function Exists(FileName As String) As Integer 'ooh, I love this function :D
Dim As Integer FileNumber=FreeFile, Missing=Open(FileName For Input As FileNumber) 'init vars as needed..
If Not Missing Then Close FileNumber 'program like you think..
Return Missing=0 'true if file exists..
End Function 'guess what..