Sign in to follow this  
Followers 0
drei

Pointers in ST task

5 posts in this topic

Hello, is it possible use pointer in a task programmed with st language? I tried to write this: <SYMBOL> DM_0 CHANNEL D0 0 DM_1 CHANNEL D1 0 </SYMBOL> <CODE> DM_0 := 10; DM_1 := @DM_0; </CODE> I was expecting that @DM_0 was a pointer to D10, but in DM_1 i found the value of DM_0. Any help? Thanks

Share this post


Link to post
Share on other sites
I am no expert at ST but it appears that you have a space between D1 and 0. I suspect the space need s go and the number become D10.

Share this post


Link to post
Share on other sites
Hello drei, This will not work, the @ symbol does not work in ST the same as it does in Ladder. What you will need to do is set D0 as an array, and use an INT variable (i.e. MyIndex) as your pointer. value. MyPointer := 10 ; E.g. DM_1 := DM_0[MyPointer]; This will set D1 to the value that is in D10

Share this post


Link to post
Share on other sites
It's exactly what i was looking for! Thank you very much Edited by drei

Share this post


Link to post
Share on other sites
I will also note, that the use of the [] brackets is common for addressing pointers in other platforms.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0