Page 1 of 1

TM1 Macro Functions

Posted: Thu Oct 08, 2009 5:53 am
by appleglaze28
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.

Re: TM1 Macro Functions

Posted: Thu Oct 08, 2009 7:32 am
by Martin Ryan
The "=" indicates that you are trying to assign the value that is returned by the function to a variable. E.g

Code: Select all

myVal=application.run("dbrw", myCube, dim1, dim2) 'store this value for later use
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.

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
HTH,
Martin

Re: TM1 Macro Functions

Posted: Thu Oct 08, 2009 8:35 am
by Alan Kirk
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.
To a large extent you need to ignore the =VUSLICE style syntax.

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.

Re: TM1 Macro Functions

Posted: Thu Oct 08, 2009 8:38 am
by appleglaze28
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?

Re: TM1 Macro Functions

Posted: Thu Oct 08, 2009 8:59 am
by Alan Kirk
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?
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.

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.

Re: TM1 Macro Functions

Posted: Thu Oct 08, 2009 9:33 am
by appleglaze28
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.