Tips_todo   >   Objectclasses   >   Custom Constants Using Task Variables

Custom Constants Using Task Variables

I have been experimenting with Global Variables and the best way to handle them. I have several libraries and I want certain variables to be visible/available from all modules. windows/reports/objects etc.

I thought about MOFFs (memory only file formats) and object classes but was not happy with either.

Task Variables are instantiated so they are not suitable. However, Task Class Variables persist so they are perfectly suitable. I experimented with how to access these task variables and discovered you simply need to prefix them with $ctask. e.g. Calculate $task.tcvUserID as Userf.UserID etc.

Now the trick is this: Everything inside Studio must be performed inside a Task so one simply has to create a supertask and subclass EVERY task from it (either directly or indirectly) and voila... there you have it!

The only downside is that you do not have direct access to the task class variables from the variables pane but ... it works and I'm happy.

P.S. I suggest you prefix these variables with tcv.
Kevin James

Note: There is a bug in Studio v2.4 and 3.0 which causes task class class and instance variable names to be changed occassionally when you copy and paste them in your code. $ctask.tvcName will change to $cvars.tvcSomeOtherName. I reported this to Tech Support in v2.4, Eric Azarcon confirmed that the bug still exists in v3.0.