已知数据名称,可以根据数据名称使用GetDataVal指令获取对应数据值。或者对名称有规律的变量,批量写入数据,可以使用SetDataVal指令。例如有要获取p200,p201,p202点位数据之数组,或者对p300,p301,p302点位写入数据,可以使用以下代码。PERS robtarget p200:=[[1,0,0],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]]; PERS robtarget p201:=[[2,0,0],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]]; PERS robtarget p202:=[[3,0,0],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
PERS robtarget pArr{3};
PERS robtarget p300:=[[11,0,0],[1,0,0,0],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]]; PERS robtarget p301:=[[12,0,0],[1,0,0,0],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]]; PERS robtarget p302:=[[13,0,0],[1,0,0,0],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]]; VAR robtarget ptmp; PROC test333() FOR i FROM 1 TO 3 DO GetDataVal "p"+(ValToStr(200+i-1)),ptmp;
pArr{i}:=ptmp; ENDFOR
FOR i FROM 1 TO 3 DO ptmp:=pArr{i}; ptmp.trans.x:=ptmp.trans.x+10; SetDataVal "p"+(ValToStr(300+i-1)),ptmp; ENDFOR ENDPROC
********************************
|