SCL实现数组全复制的三种方法

已锁定

'Razor

西门子1847工业学习平台

  • 帖子

    2773
  • 精华

    24
  • 被关注

    180

论坛等级:至圣

注册时间:2008-03-31

钻石 钻石 如何晋级?

SCL实现数组全复制的三种方法

6042

16

2017-11-09 17:54:04

star star star star

当一回孔乙己,如题。

//copy a array totally to another array

//first way: use SFC20

#Error := BLKMOV(SRCBLK := #SourceArray, DSTBLK =>#DestinationArray_1);


//second way: copy the elements one by one

FOR #index := 0 TO 9 DO  

  #DestinationArray_2[#index] := #SourceArray[#index];

END_FOR;

#index := #index + 1;


//third way: use the name of array

#DestinationArray_3 := #SourceArray;


//Error check

FOR #index := 0 TO 9 DO    

IF (#DestinationArray_1[#index] <> #SourceArray[#index]) THEN  

      #Error_1 := TRUE; 

ELSE       

      IF (#DestinationArray_2[#index] <> #SourceArray[#index]) THEN         

            #Error_2 := TRUE; 

      ELSE         

            IF (#DestinationArray_3[#index] <> #SourceArray[#index]) THEN               

                  #Error_3 := TRUE;

            ELSE

                  ;

            END_IF;       

       END_IF;    

 END_IF;

END_FOR;


若要倒序复制,则变更索引下标即可:

//second way: copy the elements one by one

FOR #index := 0 TO 9 DO

    #DestinationArray_2[9-#index] := #SourceArray[#index];

END_FOR;

#index := #index + 1;

或者

//second way: copy the elements one by one

FOR #index := 0 TO 9 DO

    #DestinationArray_2[#index] := #SourceArray[9-#index];

END_FOR;

#index := #index + 1;


SCL实现数组全复制的三种方法 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54049条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。