mirko.comparetti
Topic Author
Posts: 36
Joined: 04 Jun 2018, 11:01
Answers: 0
Location: Lomazzo

Automatic assignment of external variable

20 May 2019, 16:45

Hello,
I have a string variable that contains the name of an external variable. How can I use the value of that string to get the proper value from the external?

The pseudocode of what I'd like to do is here
PROGRAM someProgram
	VAR
		someString : STRING[50];
		someWord : WORD;
	END_VAR
	VAR EXTERNAL
		someExternalA : WORD;
		someExternalB : WORD;
	END_VAR
	
	someString := 'someExternalA';
	
	someWord := SOMEGET(IN := someString); //GET THE VALUE OF someExternalA
	
	someString := 'someExternalB';
	
	someWord := SOMEGET(IN := someString); //GET THE VALUE OF someExternalB
END_PROGRAM
so basically I'd like to find a way to assign the proper value to
someWord
based on the content of
someString
using a method
SOMEGET(IN := someString);
(or something similar).

Thanks

Who is online

Users browsing this forum: No registered users and 0 guests