複製鏈接
請複製以下鏈接發送給好友

ReadLine

鎖定
GNU readline是一個開源的跨平台程序庫,提供了交互式的文本編輯功能。它最早由Brian Fox使用C語言開發在1989年發佈,遵守GNU/GPL協議 [1] 
VB、ActiveX等其他語言或組件中也有類似的實現。
外文名
ReadLine
性    質
一個開源的跨平台程序庫
發佈日期
1989年
遵守協議
gnu協議

目錄

ReadLine程序介紹

readline 是一個強大的庫,只要使用了它的程序,都可以用同一個配置文件配置,而且用同樣的方法操作命令行,讓你可以方便的編輯命令行。
使用 readline 的程序現在主要有 Bash, GDB,ftp 等。readline 賦予這些程序強大的 Emacs 似的命令行編輯方式,你可以隨意綁定你的鍵盤,搜索命令歷史等。

ReadLine定義

ReadLine 方法 描述從一個 TextStream文件讀取一整行(到換行符但不包括換行符)並返回得到的字符串。ReadLine 方法可從 TextStream 文件中讀取一整行字符,並以字符串返回結果。

ReadLine語法

語法object.ReadLine中object參數始終是一個 TextStream對象的名字。

ReadLine示例

1,gnu readline
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
 
int main()
{
    char* input, shell_prompt[100];
 
    // Configure readline to auto-complete paths when the tab key is hit.
    rl_bind_key('\t', rl_complete);
 
    for(;;) {
        // Create prompt string from user name and current working directory.
        snprintf(shell_prompt, sizeof(shell_prompt), "%s:%s $ ", getenv("USER"), getcwd(NULL, 1024));
 
        // Display prompt and read input (n.b. input must be freed after use)...
        input = readline(shell_prompt);
 
        // Check for EOF.
        if (!input)
            break;
 
        // Add input to history.
        add_history(input);
 
        // Do stuff...
 
        // Free input.
        free(input);
    }
}
2,ActiveX readline
function GetLine()
{
    var fso, f, r;
    var ForReading = 1, ForWriting = 1;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    f = fso.OpenTextFile("c:\\testfile.txt", ForWriting, true);
    f.WriteLine("Hello world!");
    f.WriteLine("JScript is fun");
    f.Close();
    f = fso.OpenTextFile("c:\\testfile.txt", ForReading);
    r = f.ReadLine();
    return(r);
}
參考資料