Has anyone attempted to use Visual Basic 2010 for the TM1 API?
Im wondering if the deprecated feature of setting a max string length is an issue or if I there is a way around it. Many of the API functions required a fixed length string and I can't seem to figure out if this is causing the issues with my code.
IE (This does not work in VB 2010)
Dim VariableName as String * 75
TM1 API Visual Basic 2010
-
- Community Contributor
- Posts: 349
- Joined: Tue Aug 17, 2010 6:31 am
- OLAP Product: Planning Analytics
- Version: 2.0.5
- Excel Version: 2016
-
- Site Admin
- Posts: 6647
- 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 API Visual Basic 2010
I haven't tried this myself but in the VB6 to VB.Net transition document there is mention of this issue, with a note that a compatibility class (VB6.FixedLengthString) was provided to emulate fixed length strings in VB6/VBA. It's marked as "obsolete" in the current Visual Studio help file (since the same effect can be obtained via other classes), but is still supported in the .Net framework that you should probably be working with. (That is, 3.5; it'll generate a warning in 4.0 but will still compile.) Look in VS on-line help for the class name for further information. It's worth a try, and I think given that you're working with the API that was designed for VBA/VB6 it would probably be a safer approach than trying to use a "native" .Net class.PlanningDev wrote:Has anyone attempted to use Visual Basic 2010 for the TM1 API?
Im wondering if the deprecated feature of setting a max string length is an issue or if I there is a way around it. Many of the API functions required a fixed length string and I can't seem to figure out if this is causing the issues with my code.
IE (This does not work in VB 2010)
Dim VariableName as String * 75
Alternatively you could try to use the .Net API but it's much, MUCH more limited in functionality than the classic C/VB API is.
"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.
-
- Community Contributor
- Posts: 349
- Joined: Tue Aug 17, 2010 6:31 am
- OLAP Product: Planning Analytics
- Version: 2.0.5
- Excel Version: 2016
Re: TM1 API Visual Basic 2010
Thanks for the info!
I saw that in VB 2010 there is a class called FixedLengthString but its a tad confusing as it says that it doesn't directly create a fixed length string that is usable.
I have been looking for VB 6.0 but Im not sure where to get it (for free if possible). We don't have it available for install here which is why I have 2010 now.
Thanks!
I saw that in VB 2010 there is a class called FixedLengthString but its a tad confusing as it says that it doesn't directly create a fixed length string that is usable.
Im not sure what it means when it says a fixed length string cannot be converted to a string in the sense that if its not a string then what would I put in the TM1API function where it wants the fixed length string variable to store something like the server name?In Visual Basic 6.0, a String could be declared with a fixed length. In Visual Basic 2010, fixed-length strings are no longer supported and a new String is allocated every time the length of the String is changed.
The FixedLengthString class can be used to emulate the behavior of a Visual Basic 6.0 string, which enables you to declare a string with a fixed length. A FixedLengthString cannot be converted to a String; you must either reference the Value property or call the ToString method to convert the type.
I have been looking for VB 6.0 but Im not sure where to get it (for free if possible). We don't have it available for install here which is why I have 2010 now.
Thanks!
-
- Site Admin
- Posts: 6647
- 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 API Visual Basic 2010
In .Net pretty much everything is a class (or perhaps more correctly an object derived from a class), even strings. I read the above to mean that you can't directly assign from a FixedLengthString object to a System.String object, but instead have to assign the value via the specified property or method. This shouldn't matter with the TM1 API; you just keep everything in the FixedLengthString object.PlanningDev wrote: I saw that in VB 2010 there is a class called FixedLengthString but its a tad confusing as it says that it doesn't directly create a fixed length string that is usable.
Im not sure what it means when it says a fixed length string cannot be converted to a string in the sense that if its not a string then what would I put in the TM1API function where it wants the fixed length string variable to store something like the server name?In Visual Basic 6.0, a String could be declared with a fixed length. In Visual Basic 2010, fixed-length strings are no longer supported and a new String is allocated every time the length of the String is changed.
The FixedLengthString class can be used to emulate the behavior of a Visual Basic 6.0 string, which enables you to declare a string with a fixed length. A FixedLengthString cannot be converted to a String; you must either reference the Value property or call the ToString method to convert the type.
Except perhaps for including the content in dialogs and the like, there wouldn't be any need to convert it to a System.String object... which is what I think it's referring to when it says "A FixedLengthString cannot be converted to a String". But i agree that it's a rather unclear statement.
You may be able to pick up a copy on FeePay... er, I mean, eBay. Doubt that you'll get it as a freebie. Being aware of how hard it is to replace I've got a couple of divisions of Panzers guarding my disks, though truth be told I'm starting to switch to VB.Net for anything that I'm doing from scratch. I haven't (yet) had the "pleasure" of doing classic TM1 API code in that, but I know that that will happen eventually since unless you're just looking up a number or doing some other trivial things, the TM1 .Net API is the functional equivalent of the village idiot.PlanningDev wrote:I have been looking for VB 6.0 but Im not sure where to get it (for free if possible). We don't have it available for install here which is why I have 2010 now.
"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.
-
- Posts: 26
- Joined: Fri Oct 09, 2009 5:54 pm
- OLAP Product: TM1
- Version: 9.5.1
- Excel Version: 2007
Re: TM1 API Visual Basic 2010
I know you guys said you're using VB.NET, but I'm getting close to having a complete classic TM1 API class in C# if you're interested. I'll post it up on the useful code forum when I'm done translating the function declarations in the header file if there's any interest and to save people from the effort of having to type it all up.