從輸入流返回指定數(shù)量的字符。
object.Read(characters)
Read 方法返回一個字符串。StdIn、StdOut 和 StdErr 屬性與方法只在用 CScript.exe 主機可執(zhí)行文件運行腳本時奏效。用 WScript.exe 運行腳本時返回錯誤。從當前的位置指針所在的位置開始讀取并一次向前移動一個字符。
在按 enter 鍵之前,Read 方法不返回任何字符串。所返回的只是被請求的字符數(shù)。任何其他字符都將只在以后調(diào)用 Read、ReadLine 或 ReadAll 方法時返回。
下面的代碼使用 Read 方法從鍵盤獲得字符,并在控制臺顯示。
Dim Input
Input = ""
Do While Not WScript.StdIn.AtEndOfLine
Input = Input & WScript.StdIn.Read
(1)
Loop
WScript.Echo Input
var input = "";
while (!WScript.StdIn.AtEndOfLine)
{
input += WScript.StdIn.Read
(1);
}
WScript.Echo(input);