有没有办法从 dxl 脚本导入 txt 或 rft 文件?

Is there a way to import a txt or rft file from a dxl script?

我正在尝试将一个文本文件导入到我的 dxl 脚本中,以使用包含在 txt 中的单词作为字符串进行比较。有办法吗?

提前谢谢你。

嗯,是的,当然。您可以使用 Stream 变量读取文件的上下文,例如

Syntax:
Stream read [binary] (string filename)
bool end (Stream strm)

// Read from a stream. var can be of type: Buffer, char, real, int, string
<Stream>  >>  var [ >> var [ >> ...]]

// Special Read Functions: 
<Stream>  >=  <Buffer var       // Read one text line including whitespace
<Stream>  ->  <Buffer var>  // Read one text line. Omit leading whitespace
string readFile (string filename)   // Returns the contents of a file a string

Example:
string filename = "c:/datafile.txt"
Stream input = read filename

real cost
for (input >> cost; !end input; input >> cost) {
    print cost "\n"
}

close input

在您的例子中,您会将流读入 Buffer 类型的变量中。根据您的需要,您还必须将一行分成几个词,例如由 space 分隔。如果不需要拆分值,也可以直接将流读入字符串变量。

据我所知,读取 RTF 文件要复杂得多。我认为您必须了解 RTF 文件的内部结构,并能够将格式信息与真实字符串区分开来,或者使用 COM 库。也许可以使用 DOORS 的 richText 功能之一,查看帮助或 Google,我对带有 RTF 的 DOORS 不是很流利。