Example 1记录当前日期
{'Create a file containing today's date}
{open "date.fil"}
{date()}
{close}
Example 2 记录当前时间
{file_name = "time_stamp.out"}
{open file_name}
{date("%A")} : {time()}
{close}
Example 3 将曲线信息写入到文本中
{'Create a file containing today's date}
{open "date.fil"}
{p1w1c1.x}
{p1w1c1.y}
{close}
Example 4 将曲线信息格式化后写入到文本中
{x = p1w1c1.x}
{y = p1w1c1.y}
{open "date.fil"}
{table(x, y, "%12.6f %12.6f", 0, numpts(x)-1)}
{close}
Example 5 匹配foreach和if判断写入文件的文本
{file_name = "week_time_stamp.out"}
{open file_name}
{days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}}
{foreach(day = days)}
{date("%A", day)} : {time()}
{if(day == "Saturday" || day == "Sunday")}
Note: It's the weekend!
{endif}
{endloop}
{close}
Example 6 将信息添加到文件末尾
{'Create a file containing today's date}
{append "date.fil"}
{date()}
{close}
{file_name = "time_stamp.out"}
{append file_name}
{date(%A)} : {time()}
{close}
Example 7 读
取文本文件
{
a = read("two.xy", 0, 0, 0);
b = read("two.xy", 0, 0, 1);
table(a, b, "%8.2f %8.2f", 0, 5);
}
Example 8 解析pch文件
{
a = read("car.pch", "GPForce", "Point id 1130488 Elem id 1082288 QUAD4", "Frequency [Hz] - subcase 2 (modal_frequency_response_analysis )")
b = read("car.pch", "GPForce", "Point id 1130488 Elem id 1082288 QUAD4", "REL | MY")
table(a,b, " %15.6f %8.6f", 0, numpts(b)-1)
}