RobotStudio event

Indirect Referencing of Record variables

bwinter714
edited August 2015 in RobotStudio
Hi, I'm creating a recipe structure, and I want to be able to assign values to a record element based on a user input. For example below, I made a simple Recipe data type, and I created 4 of them named "Part1"-"Part4". A user would select a button that would assign the string "Part1" into strHMISelect, and then I would use that string to reference the desired instance of the recipe data type.

Since strHMISelect now = "Part1", I want to be able to indirectly reference the Part1 recipe structure by using the string strHMISelect, reading something like "strHMIMessage.TravelDistance := 100"

OR, I could assign a value of "1" to a number register called nNumber for example, and then ask something like Part'nNumber'.TravelDistance := x.

Is there a clean way/possible way to do this?

For example:

RECORD Recipe
num TravelDistance;
ENDRECORD

PERS Recipe Part1;
PERS Recipe Part2;
PERS Recipe Part3;
PERS Recipe Part4;

PERS string strHMISelect;

PROC SetData()

strHMISelect := "Part1"

strHMISelect.TravelDistance := 100;

ENDPROC

I am also asking this because I need to figure out how to indirectly reference a tag in an HMI screen, so that when I switch recipes, the field for "Travel Distance" updates with the current setpoint for that recipe, if that makes sense.

Comments