-
ReadLine
鎖定
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); }
- 參考資料
-
- 1. The GNU Readline Library .GNU Readline官網[引用日期2013-11-07]
- 詞條統計
-
- 瀏覽次數:次
- 編輯次數:27次歷史版本
- 最近更新: kf8mv2