当前位置:首页 科普知识 ReadLine

ReadLine

发布时间:2023-09-14 18:38:11

GNU readline是一个开源的跨平台程序库,提供了交互式的文本编辑功能。它最早由Brian Fox使用C语言开发在1989年发布,遵守GNU/GPL协议。

ReadLine介绍

GNU readline是一个开源的跨平台程序库,提供了交互式的文本功能。它最早由Brian Fox使用C语言开发在1989年发布,遵守GNU/GPL协议。

ReadLine

VB、ActiveX等其他语言或组件中也有类似的实现。

ReadLine程序介绍

readline 是一个强大的库,只要使用了它的程序,都可以用同一个配置文件配置,而且用同样的方法操作命令行,让你可以方便的命令行。

使用 readline 的程序现在主要有 Bash, GDB,ftp 等。readline 赋予这些程序强大的 Emacs 似的命令行方式,你可以随意绑定你的键盘,搜索命令历史等。

ReadLine

ReadLine定义

ReadLine 方法 描述从一个 TextStream文件读取一整行(到换行符但不包括换行符)并返回得到的字符串。ReadLine 方法可从 TextStream 文件中读取一整行字符,并以字符串返回结果。

ReadLine

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;     // 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);}

温馨提示:
本文【ReadLine】由作者 爱百科 转载提供。 该文观点仅代表作者本人, 自学教育网 信息发布平台,仅提供信息存储空间服务, 若存在侵权问题,请及时联系管理员或作者进行删除。
(c)2008-2025 自学教育网 All Rights Reserved 汕头市灵创科技有限公司
粤ICP备2024240640号-6