将 For 循环中递增的变量名称保存到列表中我在尝试着
1)打开Unique_Files列表中列出的一系列文件
2) 如果文件不存在,则会打开一个对话框,其中显示一条消息,指示文件存在
3) 如果文件确实存在,则在JMP中打开该文件
4)如果文件确实存在,则将数据表引用名称添加到UniqueTables列表中
除了能够创建数据表引用名称列表之外,我的脚本的所有其他部分似乎都在工作。我的脚本编写方式如下所示,结果出现在列表中
UniqueTables = { DataTable("filename1"), Data Table("filename2"),....}
相反,我希望脚本产生的列表为
唯一表 = My_Table_1、My_Table_2、My_Table_3、...
提前致谢。
N Items (Unique_Files);
UniqueTables = { };
For ( i = 1, i <= N, i ++,
If(
File Exists( "C:\PretendFilePath\" ||Unique_Files[i]|| ".csv"),
Eval(
Substitute(
Expr(
MyTab = Open( "C:\PretendFilePath\" ||Unique_Files[i]|| ".csv");
Insert Into( UniqueTables, MyTab)
),
Expr( MyTab),
Parse( My_Table_" ||Char(i))
)
),
New Window ("File Not Found",
<< Modal,
V List Box(
Text Box( Unique_Files[i]|| " does not exist in folder."),
Button Box( "OK")
)
)
)
);回复:将 For 循环中递增的变量名称保存到列表中是的
回复:将 For 循环中递增的变量名称保存到列表中那个时期很难看啊!!!!
回复:将 For 循环中递增的变量名称保存到列表中有些如何一个句点“。”之后结束
Show( UniqueTables );.
所以删除它,它会正常工作......我将更正前面的示例以供将来参考。
回复:将 For 循环中递增的变量名称保存到列表中在最后一行我收到以下错误:
意想不到的“独特表”。 可能少了一个“;”或者 ”,”。
第 42 行第 1 列:►UniqueTables[1] << Concatenate( UniqueTables[2] );
其余被忽略的文本是
UniqueTables[1]<回复:将 For 循环中递增的变量名称保存到列表中
您似乎对各种结构实际上为您提供了什么缺乏了解。我强烈建议您花时间阅读脚本指南。但是,我还认为下面的内容可能会解决您当前代码的一些问题。看看下面我带注释的代码,看看它是否可以解决您遇到的问题。
names default to here(1);
dt1=open("$SAMPLE_DATA/big class.jmp");
dt2=open("$SAMPLE_DATA/big class families.jmp");
// Here is what the value of dt1 is
show(dt1);
// From the log
// dt1 = DataTable("big class");
// Therefore the value of dt2 is,
show(dt2);
// dt2 = DataTable("big class families");
// The structure of the Concatenate Platform syntax is:
// data table("data table name") << Concatenate( data table("data table2 name"), data table("data table2 name") );
// That would mean that the following will concatenate our two files
data table( "big class" ) << Concatenate( data table( "big class families" ) );
// It also means, that since we have variables dt1, which was shown to equal Data Table( "big class" ), and
// dt2 which has the value of Data Table( "big class families" )
// the above concatenate statement can be written
dt1 << Concatenate( dt2 );
// Here is another way to do this
UniqueTables = {};
MyTab = open("$SAMPLE_DATA/big class.jmp");
insert into( UniqueTables, MyTab );
MyTab = open("$SAMPLE_DATA/big class families.jmp");
insert into( UniqueTables, MyTab );
Show( UniqueTables );
// returns
// UniqueTables = {DataTable("big class"), DataTable("big class families")};
// So now the Concatenate statement can be written
UniqueTables[1] << Concatenate( UniqueTables[2] );回复:将 For 循环中递增的变量名称保存到列表中看看是什么XY问题是的,它肯定会帮助我们帮助您。
但除此之外。如果您想要做的只是将文件夹中的所有 JMP 文件连接在一起。
Names default to here( 1 );
// this is just creating an example set don't worry about it.
dt = open("$SAMPLE_DATA\Big Class.jmp");
dir = convert file path("$DESKTOP\Example\");
Create Directory(dir);
for(i=1, i<=6, i++,
path = convert file path(char(i)||".jmp", base(dir));
dt << Save As(path);
);
// this is actually what you'll want to run
dir = convert file path("$DESKTOP\Example\");
// find the files in that directory
files = files in directory(dir);
// create a base table
dt_final = New Table("Concatted");
for(i=1, i<=nitems(files), i++,
dt = open(convert file path(files[i], base(dir)));
dt_final << Concatenate(dt, append to first table(1));
close(dt, no save);
)回复:将 For 循环中递增的变量名称保存到列表中嗨吉姆,
不幸的是,我仍然没有得到想要的结果,因为我不清楚如何解释我的情况。
我应该指定 Unique_Files 列表是存储在文件夹位置中的 CSV 的文件名。
Unique_Files = {"FileName1", "FileName2", "FileName3", etc...}
使用 << Get Name 函数会产生 UniqueTables 列表,如下所示
UniqueTables = {"FileName1", "FileName2", "FileName3", etc...}
当我寻找
UniqueTables = {My_Table_1, My_Table_2, My_Table_3, etc...}
一旦我以这种格式将 UniqueTables 列表放在一起,我的计划是将其中一些表连接在一起并关闭连接的源表。我只知道如何使用 My_Table_1 的表引用名称来执行此操作。有没有办法从文件名“FileName1”连接表?如果有的话,我就可以完全绕过这个问题。
提前致谢!你非常有帮助。
回复:将 For 循环中递增的变量名称保存到列表中我可以问你为什么要这样做吗?这样做会使脚本很难支持,因为您找不到变量名称。 一旦所有者无法再理解自己的代码,我就会修复脚本,这总是我遇到的问题。
给出多个变量可以给你带来什么列表不能带来的好处?
因为似乎没有必要
UniqueTables[1] = My_Table_1 = DataTable("filename1");
回复:将 For 循环中递增的变量名称保存到列表中您需要做的就是从数据表引用中检索表名称,因此将对“Mytab”的引用更改为:
Insert Into( UniqueTables, MyTab << get name)
JSL 中各种元素的所有消息都记录在脚本指南中
帮助==>脚本指南