Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Repeating Code???
Hi guys,

I guess this may have been asked before, so forgive me.
over the last few days I have found a lot of situations where I need to have the same code used in different places, - like Button Click, OnLoad etc.

this has resulted in me copying and pasting line by line and then going back a few hours later to edit every instance when i need to make a change.

Can I ask is there a more intelligent way to achive this? I see the command

Is it possible to have a central place to store the commands as a macro, and have any template or object action call this?

example of code repeated far to many times:
// Prep and Load the FStrip
lstZones::GetText(%(GVar:intZoneStripZoneNum), GVarConfusedtrZoneStripZoneName)
GlobalVars::Add(GVar:intZoneStripZoneNum, 1)

You could use template level actions. If you open up the dialog for the template you will see a tab called actions. There you create the actions you want to run (can't run in the OnLoad or OnPreload). Since that code looks to just use GVar's you would add a template action called something like LoadMusicStrip and use the IntfViewer::RunTmplAction(LoadMusicStrip).
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
I did see that - it its helpful for sure, but the limitation of not using this at ONLOAD is a bit of a pain.

Am i making things over complex with the CQC Macro Workshop? or is this the wrong use for that utility
I concur. I think just about every template action I have, I have to duplicate the code in the OnLoad.

I think the fact you can't use template actions in OnLoad/OnPreload stems from the way Dean does his validation. He only displays commands you can use, and validates them when you edit (making them comments). If he could just do a validation step when you try to add a template action to the OnLoad/OnPreload to make sure it doesn't have any offending commands and throw an error, then he could possible allow us to use them there.

It is definitely near the top of my list for CQC limitations...
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
damian.flynn Wrote:I did see that - it its helpful for sure, but the limitation of not using this at ONLOAD is a bit of a pain.

Am i making things over complex with the CQC Macro Workshop? or is this the wrong use for that utility

I do believe this is a perfect use of the macro workshop. The issue I have with the macro workshop is that it uses programming language. So it isn't as simple as the normal action interface where you can create actions with ease. If you are versed in the CQC programming languages (from writing drivers for example), then it should be easy to use. If you are not, then it is an uphill battle to learn the language and program macros.

At least that is the way I understand it. Because I do not have experience programming in CQC language (or any language since a college FORTRAN course), I haven't really looked into it.
Brian - a long time user that rarely messes with the system now
Other systems used:
SageTV w/ cablecard tuner & multiple extenders for viewing
BlueIris and IP cameras for CCTV
Incredible PBX for home phone
The reason for not allowing them in OnLoad/OnPreload, is that certain things can't be done there, but there's no way to limit the template level actions because there's no way to know where they will be called from.

I could allow you to call them and if they croak because the command isn't available, then they croak. I've just been being conservative about this so as to be safe, and so that I don't have to continually explain why actions are dying because of a command not being available.
Dean Roddey
Explorans limites defectum

Possibly Related Threads…
Thread Author Replies Views Last Post
  REpeating error after reboot znelbok 3 1,258 07-18-2020, 06:11 PM
Last Post: Dean Roddey
  I've open sourced my general purpose code Dean Roddey 0 1,022 03-09-2019, 06:53 PM
Last Post: Dean Roddey
  Is it possible to pass onto CQC what user code was used on the ELK? ghurty 9 4,413 01-23-2015, 12:53 PM
Last Post: wuench
  Field Based Triggered Events - Repeating wuench 4 2,403 12-27-2013, 06:59 AM
Last Post: George M
  using a pronto hex ir code... pjwinstalls 6 2,656 11-06-2010, 09:01 PM
Last Post: pjwinstalls
  How does one view a driver's source code? 123 6 2,535 07-21-2009, 10:14 AM
Last Post: Mark Stega
  Code Reuse? indygreg 15 3,706 06-06-2009, 06:57 AM
Last Post: IVB
  All media is repeating Roscoe62 11 2,371 05-31-2009, 08:42 PM
Last Post: Dean Roddey
  Links or function calls to code: A Good Programming Practice advise rocker 15 4,299 05-23-2009, 05:19 PM
Last Post: Dean Roddey
  XML Gateway example code? beelzerob 52 10,971 09-03-2008, 07:17 AM
Last Post: potts.mike

Forum Jump:

Users browsing this thread: 1 Guest(s)