PCS7 WinCC Scripting

SIMATIC S7-200/300/400, Step7, PCS7, CFC, SFC, PDM, PLCSIM,
SCL, Graph, SPS-VISU S5/S7, IBHsoftec, LOGO ...
Post Reply
Dardenoith
Posts: 3
Joined: Sun Jul 28, 2019 5:19 am

PCS7 WinCC Scripting

Post by Dardenoith » Wed Jul 01, 2020 5:58 pm

Hello there, Im new here and also I started to learn C and how to use it in WinCC.

Im trying to make script with C-Action in Graphic Designer but my knowlage is really limited.
What I want to do is to make a button, that will change state of defined tags.
Example:
Show

Code: Select all

Tagname section... start

#define TAG_1 "tag1"
#define TAG_2 "tag2"
..
#define TAG_68 "tag68"

Tagname section end..

Picname section start...
Picname section end...

// Here I have IF function converted from Dynamic Action to C action

if((GetTagDWord(TAG_1)) & 0x1)
 return value;
else
 return value2;
Now the question if anyone can show me how to do that for all 68 defined tags inf FOR loop or any other function, just to avoid copying that IF 68 times...

I tried to search for info about using arrays or tables but as I said, my knowlage is really limited, I just started with scripts and in fact I don't know how to do that :S

Can anyone show me on example how to use here FOR loop? It will help me a lot! Thank you!

Rex2701
Posts: 370
Joined: Wed Oct 13, 2010 8:44 am
Location: Russian Federation

Re: PCS7 WinCC Scripting

Post by Rex2701 » Mon Jul 06, 2020 5:17 pm


Dardenoith
Posts: 3
Joined: Sun Jul 28, 2019 5:19 am

Re: PCS7 WinCC Scripting

Post by Dardenoith » Wed Jul 08, 2020 7:24 am

This one did not help a lot but I found some C tutorials and I came up with something like that:

Code: Select all

 for(i=1; i<=68; i++){
  char str[50];
  sprintf(str, "%f", i); if((GetTagDWord(strcat("TAG_", str)) &0x1) {
      return 65280;
  } else {
      return 16777215;
  }
 }
But I have no idea if it will work

Rex2701
Posts: 370
Joined: Wed Oct 13, 2010 8:44 am
Location: Russian Federation

Re: PCS7 WinCC Scripting

Post by Rex2701 » Mon Jul 13, 2020 8:23 pm

You cannot use "return" inside "for" because it immediately exits the function by returning the result.

Post Reply