Scripting

  • 1.  I have a UDS which enables/disables various custom

    Posted 07-05-2017 11:18
    I have a UDS which enables/disables various custom tabs. Works like a charm. What I am trying to do is change the background color of the tab when it is enabled. I don't see anyway to do this so I was wondering if anyone has any insight as to how this could be done. SetControlProperty doesn't seem to work and from what I see in the scripting documentation SetFolderState is the only function that deals with the Tabs.


  • 2.  RE: I have a UDS which enables/disables various custom

    Posted 07-05-2017 11:49
    Did you try to hide tabs instead of disabling them?


  • 3.  RE: I have a UDS which enables/disables various custom

    Posted 07-05-2017 12:24
    I would think SetControlProperty is correct. If it's 2016+, i wonder if the Theme Settings prevent/override it.


  • 4.  RE: I have a UDS which enables/disables various custom

    Posted 07-05-2017 17:22
    i was just messing with this last week. i don't think it can be done currently using conventional scripting techniques like SetControlProperty. You have two options depending on how you want to proceed, one involves requiring a button so you can get a hook back to the nomads object so you can use the FLDR object variable, this means in your script, you have to call the InvokeButton method, i'm not a fan of this because it means one more dependency that you have to add to panels. The other is only applicable if you are on v2015+. In a UI post load script, you place the applicable local object references into global object references so they can be used from the table and field event scripts. If you use a button script, it needs to have the following and use providex to manipulate the tab and folder object via the FLDR object reference. ___________________________________________ MAS_SCR_PFM = ""some_file_name.pl"" ___________________________________________ If you use a UI Post Load, then all you need in the post load script is the following, ___________________________________________ oScript.Execute(""LET %FLDR=FLDR"") oScript.Execute(""CMD_STR$=""""X LET %_MAINPNL_COLORS$=_MAINPNL_COLORS$"""""") ___________________________________________ In your main script, you can now reference the %FLDR object. If you don't know the index number of your custom tabs, then you can always loop through until your counter is greater than %FLDR'TabCount The following also assumes you are disabling the folder using another method, see example 2 for how to disable and color the tab in one line. To ""Enable"" it, just use ""EnableTab"" instead of ""DisableTab"" Example 1 ___________________________________________ nTabIndex = 6 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""RGB: 128 128 128""""), %FLDR'ReDraw(), 'SR', 'CF',"") ___________________________________________ Example 2 ___________________________________________ nTabIndex = 6 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""RGB: 128 128 128""""), %FLDR'DisableTab("" & nTabIndex & ""), 'SR', 'CF',"") ___________________________________________


  • 5.  RE: I have a UDS which enables/disables various custom

    Posted 07-10-2017 12:19
    Well I finally got this to work. Part of the script is as follows. I did create the UI script to initialize the folder object variable. ' The purpose of this script is to enable tabs based on items selected ' RKL TE 6-28-17 ' RKL this script is used to change the functionality ' an appearance of the tabs. retval = oScript.DebugPrint(""Begin PR_EnableGR_Panels script"") sItemCode="""" screenname="""" panelname="""" foldername="""" ' Get the item code retval = oScript.DebugPrint(""Begin Script"") retval = oBusObj.GetValue(""ItemCode$"",sItemCode) retval = oScript.DebugPrint(sItemCode & "" Before if"") ' test for the presence of the UI Object if one doesn't exist ' create a connection myUIOBJ to the UI Object. If (IsObject(oUIObj)) Then MASUI = True screenName = oUIObj.GetScreenName() panelName = oUIObj.GetPanelName() folderName = oUIObj.GetFolderName() retval = oScript.DebugPrint(""fIRST "" & screenname &"":""&panelname &"":""&foldername) Else myUIOBJ="""" MASUI = CBool(oScript.UIObj) retval = oScript.DebugPrint(screenname &"":""&panelname &"":""&foldername) If (MASUI) Then Set myUIObj = oSession.AsObject(oScript.UIObj) screenName = myUIObj.GetScreenName() panelName = myUIObj.GetPanelName() folderName = myUIObj.GetFolderName() End If End If retval = oScript.DebugPrint(screenname & panelname & foldername) IF sItemCode = ""GR1"" THEN 'retVal = myUIObj.SetFolderState(""PNL_CMNEW_1"", ""ENABLE"") nTabIndex = 7 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Red""""), %FLDR'Redraw(), 'SR', 'CF',"") oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Red""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 8 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 9 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 10 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""),%FLDR'Redraw(), 'SR', 'CF',"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_1"", ""ENABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_2"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_3"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_4"", ""DISABLE"") retval = oScript.DebugPrint(""GR1 panel enabled"") ELSE IF sItemCode = ""GR2"" THEN nTabIndex = 7 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""),%FLDR'DisableTab("" & nTabindex & ""), 'SR', 'CF',"") nTabIndex = 8 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Red""""), %FLDR'EnableTab("" & nTabindex & ""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 9 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""),%FLDR'DisableTab("" & nTabindex & ""), 'SR', 'CF',"") nTabIndex = 10 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""),%FLDR'DisableTab("" & nTabindex & ""), 'SR', 'CF',"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_1"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_2"", ""ENABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_3"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_4"", ""DISABLE"") retval = oScript.DebugPrint(""GR2 panel enabled"") Else IF sItemCode = ""GR3"" THEN nTabIndex = 7 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 8 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""),%FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 9 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Red""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 10 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""),%FLDR'Redraw(), 'SR', 'CF',"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_1"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_2"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_3"", ""ENABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_4"", ""DISABLE"") retval = oScript.DebugPrint(""GR3 panel enabled"") Else IF sItemCode = ""GR4"" THEN nTabIndex = 7 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 8 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 9 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Gray""""), %FLDR'Redraw(), 'SR', 'CF',"") nTabIndex = 10 oScript.Execute(""PRINT %_MAINPNL_COLORS$, %FLDR'GetTab("" & nTabIndex & "")'SetTabColor(""""Light Red""""), %FLDR'Redraw(), 'SR', 'CF',"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_1"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_2"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_3"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_4"", ""ENABLE"") retval = oScript.DebugPrint(""GR4 panel enabled"") End IF retVal = myUIObj.SetFolderState(""PNL_CMNEW_1"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_2"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_3"", ""DISABLE"") retVal = myUIObj.SetFolderState(""PNL_CMNEW_4"", ""DISABLE"") retval = oScript.DebugPrint(""NO panels enabled"") End IF End If End If retval = oScript.DebugPrint(""End PR_EnableGR_Panels script"")


  • 6.  RE: I have a UDS which enables/disables various custom

    Posted 07-10-2017 12:38
    Glad you got it to work. I will add that you might be able to simplify your IF statements checking the item code by using either [SELECT CASE](https://ss64.com/vb/select.html) or [ELSEIF](https://ss64.com/vb/if.html). SELECT CASE EXAMPLE _____________________________________________________________ sItemCode = """" retval = oBusObj.GetValue(""ItemCode$"",sItemCode) select case sItemCode case ""GR1"" ' Do stuff case ""GR2"" ' Do stuff case ""GR3"" ' Do stuff case ""GR4"" ' Do stuff end select ' ' ELSEIF EXAMPLE _____________________________________________________________ sItemCode = """" retval = oBusObj.GetValue(""ItemCode$"",sItemCode) if sItemCode = ""GR1"" then ' Do stuff elseif sItemCode = ""GR2"" then ' Do stuff elseif sItemCode = ""GR3"" then ' Do stuff elseif sItemCode = ""GR4"" then ' Do stuff end if