FreeBASIC Isredirected
目次→実行時ライブラリー参考→オペレーティング・システム関連→ISREDIRECTED←オリジナル・サイト
stdin か stdout が、ファイルにリダイレクト(転送)されるかどうかをチェックします。
構文:
例:
#include "fbio.bi"
result = IsRedirected( is_input )
パラメータ:
戻り値:
stdin または stdout が転送される場合、ゼロでない (-1) が戻ります。そうでなければ、ゼロ (0) を返します。
記述:
IsRedirected は、通常のコンソール/ターミナルへの接続の代わりに、stdin か stdout がファイルに転送されるかどうかを調べます。
is_input が、ゼロでない (-1) 場合、IsRedirected は、stdin をチェックします。
is_input が、ゼロ (0) なら、IsRedirected は、stdout をチェックします。
例:
'' A Windows based example, just for the use principle
'' 自給自足の例。ダミーの入力ファイルとして彼自身の .exe ファイルを、stdin 転送に使います
#include "fbio.bi"
'' 引用符は、パス名の中でスペースがあってもよいように使っています。
Dim As String pathExe = """" & ExePath & """"
Dim As String fileExe = Mid(Command(0), Instrrev(Command(0), "\") + 1)
Dim As String redirection = " < """ & Command(0)
If LCase(Right(Command(0), 4)) = ".exe" Then
redirection &= """"
Else
redirection &= ".exe"""
End If
If Command() = "" Then '' stdin 転送のない1回目のプロセス
'' Check stdin redirection
Print "First process without stdin redirection: IsRedirected(-1) = "; Isredirected(-1)
'' file.exe から転送された stdin を備えた、非同期第2のプロセスを生成
Shell("start /d " & pathExe & " /b " & fileExe & redirection & " secondprocess")
'' 非同期の第2のプロセスの終了を待ちます
Sleep
ElseIf Command() = "secondprocess" Then '' stdin 転送を備えた第2のプロセス
'' stdin 転送をチェック
Print "Second process with stdin redirection : IsRedirected(-1) = "; Isredirected(-1)
End If
QBからの違い:
参照:
ページ歴史:2017-11-21 01:11:17
日本語翻訳:WATANABE Makoto、原文著作者:FxMwikki