Trying to figure out a clean/simple way to create a user input driven menu to update key positions in my program. This is a silly way to update positions, I know. It's more of an exercise in creating menus.
Currently I have a series of UIListView commands which set values in an array, then TEST / CASE of the array value to determine what robtarget or jointtarget to modify.
Once the desired position is selected:
1. Set the selected value to a local variable
2. Move to current value of desired position
3. Prompt user to jog
4. Update to new position? Yes/No
5. Return to top menu
I'll replace the first TEST with something a little cleaner. Probably set a STRING based on the first list input, then run that string through a single UIListView to get my second array value.
I've never made an in-depth menu like this. Is there a better way, or am I headed down a reasonable path?
PROC UpdatePositions()
VAR num list_item;
VAR num list_item2;
VAR num list_selection{2};
VAR btnres button_answer;
VAR robtarget RobTarget_Modify;
! CONST listitem TeachPos_Main{4}:=[["","Shared"],["","Side 1"],["","Side 2"],["","Misc."]];
! CONST listitem TeachPos_Shared{2}:=[["","HomePos"],["","ToolServ"]];
! CONST listitem TeachPos_Side1{4}:=[["","FunnelPos"],["","Funnel Pounce"],["","Tray Pounce"],["","Clear of Camera"]];
! CONST listitem TeachPos_Side2{4}:=[["","FunnelPos"],["","Funnel Pounce"],["","Tray Pounce"],["","Clear of Camera"]];
! CONST listitem TeachPos_Misc{3}:=[["","ShipPos"],["","RESERVED"],["","RESERVED"]];
!Menu-driven interface to touch up non-vision positions
TPErase;
list_item1:=UIListView(
\Result:=button_answer
\Header:="UIListView Header",
TeachPos_Main
\Buttons:=btnOKCancel
\Icon:=iconInfo
\DefaultIndex:=1);
IF button_answer=resOK THEN
TEST list_item1
CASE 1:
list_item2:=UIListView(
\Result:=button_answer
\Header:="UIListView Header",
TeachPos_Shared
\Buttons:=btnOKCancel
\Icon:=iconInfo
\DefaultIndex:=1);
CASE 2:
list_item2:=UIListView(
\Result:=button_answer
\Header:="UIListView Header",
TeachPos_Side1
\Buttons:=btnOKCancel
\Icon:=iconInfo
\DefaultIndex:=1);
CASE 3:
list_item2:=UIListView(
\Result:=button_answer
\Header:="UIListView Header",
TeachPos_Side2
\Buttons:=btnOKCancel
\Icon:=iconInfo
\DefaultIndex:=1);
CASE 4:
list_item2:=UIListView(
\Result:=button_answer
\Header:="UIListView Header",
TeachPos_Misc
\Buttons:=btnOKCancel
\Icon:=iconInfo
\DefaultIndex:=1);
ENDTEST
ENDIF
list_selection:=[list_item,list_item2];
TEST list_selection
CASE [1,1]:
!RobTarget_Modify:=HomePos;
CASE [1,2]:
!RobTarget_Modify:=pToolService;
CASE [2,1]:
!RobTarget_Modify:=Bagger1_FunnelPos;
CASE [2,2]:
!RobTarget_Modify:=Bagger1_PouncePos;
CASE [2,3]:
!RobTarget_Modify:=AsyCube1_PouncePos;
CASE [2,4]:
!RobTarget_Modify:=Camera1_ClearPos;
CASE [3,1]:
!RobTarget_Modify:=Bagger2_FunnelPos;
CASE [3,2]:
!RobTarget_Modify:=Bagger2_PouncePos;
CASE [3,3]:
!RobTarget_Modify:=AsyCube2_PouncePos;
CASE [3,4]:
!RobTarget_Modify:=Camera2_ClearPos;
DEFAULT:
RETURN ;
ENDTEST
ENDPROC
Display More