1、怎样从外部文件读入数据?
得到一行数据。再次使用 readfrom 就会得到后面的行。如果到达文件末尾,readfrom 会返回一个空字符串 EOF,
readfrom "文件"
读入的数据都是作为一个字符串,如果你想要得到数字,你必须用 scantokens 把字符串 evaluate 一下。
u=1mm;
numeric nr, l, Len;
string x, gd, dn;
nr := scantokens(readfrom "DrawSettings.txt")*u; % 点半径(毫米)
Len := scantokens(readfrom "DrawSettings.txt")*u; % 图像大小(毫米)
x := (readfrom "DrawSettings.txt"); % 图像格式(png或eps)
gd := (readfrom "DrawSettings.txt"); % 是否绘制轨道(ON