Better Way to Write this
ondrovic
Posts: 217
Define_Function Update_Panel(Integer Index) { Stack_Var Integer x If(Debug_State) debug("'Line # ',Itoa(__Line__),' Updating Touch Panel With Info Parsed Info!!!'") If(nIndex = 1) { For(x=1;x<7;x++) { Send_Command dvPanel,"'^TXT-',Itoa(0+x),',0,',(Left_String(sNews[x].Article_Title,40))" Send_Command dvPanel,"'^BAT-',Itoa(0+x),',0,',(Mid_String(sNews[x].Article_Title,41,40))" Send_Command dvPanel,"'^TXT-',Itoa(6+x),',0,',(Left_String(sNews[x].Article_Description,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x].Article_Description,101,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x].Article_Description,201,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x].Article_Description,301,100))" Send_Command dvPanel,"'!T',12+x,sNews[x].Article_Author" Send_Command dvPanel,"'!T',18+x,sNews[x].Article_PubDate" } } If(nIndex = 2) { For(x=1;x<7;x++) { Send_Command dvPanel,"'^TXT-',Itoa(0+x),',0,',(Left_String(sNews[x+6].Article_Title,40))" Send_Command dvPanel,"'^BAT-',Itoa(0+x),',0,',(Mid_String(sNews[x+6].Article_Title,41,40))" Send_Command dvPanel,"'^TXT-',Itoa(6+x),',0,',(Left_String(sNews[x+6].Article_Description,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+6].Article_Description,101,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+6].Article_Description,201,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+6].Article_Description,301,100))" Send_Command dvPanel,"'!T',12+x,sNews[x+6].Article_Author" Send_Command dvPanel,"'!T',18+x,sNews[x+6].Article_PubDate" } } If(nIndex = 3) { For(x=1;x<7;x++) { Send_Command dvPanel,"'^TXT-',Itoa(0+x),',0,',(Left_String(sNews[x+12].Article_Title,40))" Send_Command dvPanel,"'^BAT-',Itoa(0+x),',0,',(Mid_String(sNews[x+12].Article_Title,41,40))" Send_Command dvPanel,"'^TXT-',Itoa(6+x),',0,',(Left_String(sNews[x+12].Article_Description,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+12].Article_Description,101,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+12].Article_Description,201,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+12].Article_Description,301,100))" Send_Command dvPanel,"'!T',12+x,sNews[x+12].Article_Author" Send_Command dvPanel,"'!T',18+x,sNews[x+12].Article_PubDate" } } If(nIndex = 4) { For(x=1;x<7;x++) { Send_Command dvPanel,"'^TXT-',Itoa(0+x),',0,',(Left_String(sNews[x+18].Article_Title,40))" Send_Command dvPanel,"'^BAT-',Itoa(0+x),',0,',(Mid_String(sNews[x+18].Article_Title,41,40))" Send_Command dvPanel,"'^TXT-',Itoa(6+x),',0,',(Left_String(sNews[x+18].Article_Description,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+18].Article_Description,101,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+18].Article_Description,201,100))" Send_Command dvPanel,"'^BAT-',Itoa(6+x),',0,',(Mid_String(sNews[x+18].Article_Description,301,100))" Send_Command dvPanel,"'!T',12+x,sNews[x+18].Article_Author" Send_Command dvPanel,"'!T',18+x,sNews[x+18].Article_PubDate" } } }
Was wondering if someone could make some suggestions to make this more efficient
Thanks
0
Comments
Alternately, define a STACK_VAR with your structure type and assign it before the loop: