“function”或“for”的语法错误JMP 们大家好,
我的(JMP 14.3.0,W10)意图是编写一个函数,该函数将表(dt)和唯一批号(uids)列表作为输入,并通过连接每个 uid 的 dt 副本并填充来构造一个表在适当的批次中。 每个地点的编号信息。 这样做的目的是让我稍后可以对表进行联接操作。 我正处于 JSL 学习曲线的早期阶段,遇到如下错误:
意想不到的“如果”。 也许缺少“,”或“)”。 尝试解析函数“For”的参数。
我认为我的函数或 For 循环存在语法问题,但在我看来,该语法与我似乎运行正常的其他代码相同。 非常欢迎任何/所有建议!
pop_limits_with_uids = Function( {dt, uids},
For( i = 1, i < N Items( uids ), i++,
Print( "here" );
If( i == 1,
pop_dt = dt << Subset( Output Table( "dt_copy" ), All rows, Selected columns only( 0 ) );
dt_copy = pop_dt;
Print( i );
,
dt_copy = dt << Subset( Output Table( "dt_copy" ), All rows, Selected columns only( 0 ) )
);
Column( dt_copy, "Lot No." )[{1, 2, 3}] = uids[i]; //dt_copy should have 3 rows. Set all 3 Lot No. to latest uid
pop_dt << concatenate( dt_copy, append to first table( 1 ) ); //add to the primary list
);
Close( dt_copy );
);
问候,
斯科特
自动化和脚本编写回复:“function”或“for”的语法错误我在 JMP 17 中发布的 JSL 中没有看到语法问题。
一旦解决了这个问题,无论结果是什么,您可能想在函数中使用一些局部变量。 像这样的东西:
pop_limits_with_uids = Function( {dt, uids},
{ i, pop_dt, dt_copy }, // these are local to the function
For( i = 1, i < N Items( uids ), i++,
Print( "here" );
If( i == 1,
pop_dt = dt << Subset( Output Table( "dt_copy" ), All rows, Selected columns only( 0 ) );
dt_copy = pop_dt;
Print( i );
,
dt_copy = dt << Subset( Output Table( "dt_copy" ), All rows, Selected columns only( 0 ) )
);
Column( dt_copy, "Lot No." )[{1, 2, 3}] = uids[i]; //dt_copy should have 3 rows. Set all 3 Lot No. to latest uid
pop_dt << concatenate( dt_copy, append to first table( 1 ) ); //add to the primary list
);
Close( dt_copy );
);
还有其他方法;这对我来说是最有效的。 它不会解决您当前面临的问题。