Example ====== Store cues with current page names as legends ====== ^ by: | Sebastian Beutel | ^ published: | May 2024 | ^ description: | store cues with current pagenames as legends | ^ remarks: | This records some cues into the Macros window and sets their legends to the current pages legends of some windows.\\ Page legends are not available through WebAPI. In order to get these legends:\\ - deploy this macro\\ - recall it from WebAPI http://localhost:4431/titan/script/2/UserMacros/RecallMacroById?macroId=Wiki.Macros.Test.PageName\\ - get handles JSON http://localhost:4431/titan/handles/Macros\\ - parse the answer for the numbers/legends you are after | {{tag>pagename webapi trick json}} ==== functions ==== * [[:macros:function:ActionScript.SetProperty]] * [[:macros:function:Handles.Macros.ChangePage]] * [[:macros:function:Handles.SetSourceHandleFromHandle]] * [[:macros:function:Handles.ConfirmDelete]] * [[:macros:function:Math.ToString]] * [[:macros:function:Playbacks.StoreCue]] * [[:macros:function:Handles.SetSourceHandle]] * [[:macros:function:Handles.SetUserNumber]] * [[:macros:function:Handles.ClearSelection]] ==== affected properties ==== * [[:macros:property:UserMacros.CurrentUserNumber]] * [[:macros:property:Handles.Macros.Page.Index]] * [[:macros:property:Playbacks.PendingLegend]] * [[:macros:property:Handles.Playbacks.Page.DisplayName]] * [[:macros:property:Handles.CurrentUserNumber]] * [[:macros:property:Handles.Playbacks.Page.DisplayIndex]] File with some more windows' pages here: {{ :macros:example:pagename.xml |}} ===== Code ===== ActionScript.SetProperty("UserMacros.CurrentUserNumber", Handles.Macros.Page.Index) Handles.Macros.ChangePage(1) Handles.SetSourceHandleFromHandle("cueHandleUN=1001") Handles.ConfirmDelete() ActionScript.SetProperty("Playbacks.PendingLegend", Handles.Playbacks.Page.DisplayName) Playbacks.StoreCue("Macros", 0, false) Handles.SetSourceHandle("Macros", 0) ActionScript.SetProperty("Handles.CurrentUserNumber", userNumber:1001) Handles.SetUserNumber() Handles.SetSourceHandleFromHandle("cueHandleUN=1002") Handles.ConfirmDelete() ActionScript.SetProperty("Playbacks.PendingLegend", Math.ToString(Handles.Playbacks.Page.DisplayIndex)) Playbacks.StoreCue("Macros", 1, false) Handles.SetSourceHandle("Macros", 1) ActionScript.SetProperty("Handles.CurrentUserNumber", userNumber:1002) Handles.SetUserNumber() Handles.ClearSelection() Handles.Macros.ChangePage(UserMacros.CurrentUserNumber) ===== Explanation ===== This explains the functional steps within the sequence. For all the other XML details please refer to [[:macros:formats_and_syntax#xml_format|Formats and syntax]] * the first two lines cache the current page of the Macros window into a variable and toggle to another page. This is to make sure all created dummy playbacks are not in the way for other things. * then, per item (window pagename and window page number), a designated playback is stored with that value as legend, like this: * ''Handles.SetSourceHandleFromHandle(..)'' selects the handle for the following delete action * ''Handles.ConfirmDelete()'' deletes this handle * ''ActionScript.SetProperty("Playbacks.PendingLegend", Handles.Playbacks.Page.DisplayName)'' loads the current pagename of a window into the variable Playbacks.PendingLegend * ''Playbacks.StoreCue("Macros", 0, false)'' stores a dummy cue on the current Macros page's first button and sets its legend * ''Handles.SetSourceHandle("Macros", 0)'' selects this handle to set its usernumber * ''ActionScript.SetProperty("Handles.CurrentUserNumber", userNumber:1001)'' prepares the usernumber to be set for the specific handle * ''Handles.SetUserNumber()'' sets the usernumber * the last two lines toggle the Macros window back to the page it was previously on ===== How to use it ===== - [[:macros:deploying|make this macro available]] - recall it from WebAPI http://localhost:4431/titan/script/2/UserMacros/RecallMacroById?macroId=Wiki.Macros.Test.PageName - get handles JSON http://localhost:4431/titan/handles/Macros - parse the answer for the numbers/legends you are after ~~DISCUSSION~~