TM1 Macro Functions
-
- Regular Participant
- Posts: 269
- Joined: Tue Apr 21, 2009 3:43 am
- OLAP Product: Cognos TM1, Planning
- Version: 9.1 SP3 9.4 MR1 FP1 9.5
- Excel Version: 2003
TM1 Macro Functions
I'd like to ask...is there any guidelines on how the TM1 Macro Functions are written like for there are some functions when you look at the referene guide they show the sample with the "=" infront of the syntax or function like =VUSLICE,=T_CREATE but there are some function like T_SAVE which are ran by write Applicaiton.Run ("T_SAVE"). I'm still not too familiar with VBA.
- Martin Ryan
- Site Admin
- Posts: 1989
- Joined: Sat May 10, 2008 9:08 am
- OLAP Product: TM1
- Version: 10.1
- Excel Version: 2010
- Location: Wellington, New Zealand
- Contact:
Re: TM1 Macro Functions
The "=" indicates that you are trying to assign the value that is returned by the function to a variable. E.g
If the value does not need to be retained by the VBA for future use, then there's no need to store it, e.g.
HTH,
Martin
Code: Select all
myVal=application.run("dbrw", myCube, dim1, dim2) 'store this value for later use
Code: Select all
application.run("dbss", myString, myCube, dim1, dim2) ' just tell TM1 to do something, don't assign the result to anything in vba
Martin
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Jodi Ryan Family Lawyer
-
- Site Admin
- Posts: 6645
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: TM1 Macro Functions
To a large extent you need to ignore the =VUSLICE style syntax.appleglaze28 wrote:I'd like to ask...is there any guidelines on how the TM1 Macro Functions are written like for there are some functions when you look at the referene guide they show the sample with the "=" infront of the syntax or function like =VUSLICE,=T_CREATE but there are some function like T_SAVE which are ran by write Applicaiton.Run ("T_SAVE"). I'm still not too familiar with VBA.
Macro functions are so named because they were originally intended to be used with what's now known as the Excel 4.0 macro language (also known as XLM), which was a forerunner of VBA. Those macros were stored in Excel macro sheets which you can still insert into an Excel workbook (right click on a sheet tab and select "Insert...", and you'll be able to see them), but for practical purposes support for that type of macro ended with Excel 2000. (You can still run them if they already exist in a workbook, edit them and you can still call some Excel 4 macro functions via the ExecuteExcel4Macro method of the Application object. However it's probably been years since anyone (other than a hermit living in a cave with an 80386) has written a new Excel 4 macro.)
What you need to understand is that the =VUSLICE style syntax represents what the syntax was with Excel 4.0 macros.
As Martin stated, the VBA syntax is always Application.Run("MacroName", {Macro Arguments}). Some people omit the Application object since it's implied in the Run method; I don't, because I regard it as being a bit sloppy. If the macro function does return a value then as Martin said you return it from the Application.Run method. You'll never return it directly from the function itself in VBA using the =VUSLICE style syntax.
This is kinda-sorta explained at the head of the relevant help page; the section titled "Accessing macro functions from Excel versions 5 and 7" takes you back to the versions where the XLM language was predominant (7 was Excel 95, when VBA first emerged from the primordial ooze, but it obviously took a while for XLM code to be converted), "Accessing macro functions from Excel version 8 and later" is for Office 97 and later which still support XLM code but only to a limited extent, and "Accessing macro functions from VBA modules" tells you essentially the same thing that Martin did.
I'm not going to bag out Iboglix for failing to update this page since it does correctly apply to the historical functions; the only problem is that XLM / Excel 4 macros were all such a long time ago now that you need to be a computer archaeologist to be able to remember them in that context. I think it's probably time to at least rewrite the page to show the VBA syntax as the predominant one, since I can understand how it can be confusing to someone who has never worked with the old language.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Regular Participant
- Posts: 269
- Joined: Tue Apr 21, 2009 3:43 am
- OLAP Product: Cognos TM1, Planning
- Version: 9.1 SP3 9.4 MR1 FP1 9.5
- Excel Version: 2003
Re: TM1 Macro Functions
Okay...is just very confusing for me abit since not all variables or functions are the same when being indicated in the reference.
But when it came to the TM1 TI Variable, it technically works the same way as other function? However are there instances that you need to use them(TM1 TI Variables)? Cause I'm not sure how useful or how frequently you might use the TI Variables when I browsed through some of them.
Can you give a sample where TM1 TI Variables are used just for reference to better understand how & when to use them?
But when it came to the TM1 TI Variable, it technically works the same way as other function? However are there instances that you need to use them(TM1 TI Variables)? Cause I'm not sure how useful or how frequently you might use the TI Variables when I browsed through some of them.
Can you give a sample where TM1 TI Variables are used just for reference to better understand how & when to use them?
-
- Site Admin
- Posts: 6645
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: TM1 Macro Functions
It would be really cool if you wouldn't keep shifting one conversation (the one in thread http://forums.olapforums.com/viewtopic. ... 8458#p8458) into the middle of another completely unrelated one (this thread) like this.appleglaze28 wrote:Okay...is just very confusing for me abit since not all variables or functions are the same when being indicated in the reference.
But when it came to the TM1 TI Variable, it technically works the same way as other function? However are there instances that you need to use them(TM1 TI Variables)? Cause I'm not sure how useful or how frequently you might use the TI Variables when I browsed through some of them.
Can you give a sample where TM1 TI Variables are used just for reference to better understand how & when to use them?
TI process variables have nothing to do with the macro functions and vice versa.
The Macro functions allow you to perform certain actions via VBA (or, earlier, XLM) code in an Excel workbook.
TI process variables either provide you with information about a TM1 TurboIntegrator process or the data therein, or to modify the settings of the process.
Excel worksheets on the one hand, TI process on the other.
Chalk on the one hand, cheese on the other.
For some examples of how to use TI process variables, see my comments in the other thread and take a read through the help file examples. Give some of them a try in your Dev environment and you'll get a better understanding of how they work.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Regular Participant
- Posts: 269
- Joined: Tue Apr 21, 2009 3:43 am
- OLAP Product: Cognos TM1, Planning
- Version: 9.1 SP3 9.4 MR1 FP1 9.5
- Excel Version: 2003
Re: TM1 Macro Functions
Okay Alan...thanks for the advise very much appreciated...its just seems like there's too much work needs to be put in to understand everything.