I have a client application which is using a specific library. This library can have different versions and I would like to have only one application flexible to be used with all different versions of this library.
My main problem now is that they changed the number of arguments of some specific functions in different versions and I don't know if I can workaround in VB for that.
Example:
Library Version 1, we have:
FuncA(Arg1, Arg2, Arg3) as Boolean
Library Version 2 we have the same but with 4 arguments:
FuncA(Arg1, Arg2, Arg3, Arg4) as Boolean
If I use always 4 arguments I will not be able to compile in using Library Version 1.
Does anyone know if it is possible to have such flexibility in VB?
William Vidal.
3 1414
I don't have much experience in this area. But I wonder, if there is some way you can interrogate the libary for its version, then perhaps you can follow different paths in your VB code. Something along the lines of... -
If Library-Version = 1 Then
-
Value = FuncA(Arg1, Arg2, Arg3)
-
ElseIf Lubrary-Version = 2 Then
-
Value = FuncA(Arg1, Arg2, Arg3, Arg4)
-
Thanks Killer,
But in this way the code will not compile once it will expect to match exactly the number of arguments the library has. In this way you will receive during compilation: "Argument not Optional" in case you are in version 2 of the library (which asks for 4 arguments)
Actually this is a mistake from the library designers, they should have done the library with this new 4th argument as Optional.
But I found a way using Conditional Compilation. Follows the code: - #Const LibVer1 = "Version 1.0"
-
#Const LibVer2 = "Version 2.0"
-
-
Function AuxFuncA(Arg1, Arg2, Arg3, Optional Arg4) as Boolean
-
Dim CurrentLibVersion as string
-
'The Function or method to find out the library version
-
CurrentLibVersion = GetLibVersion()
-
-
'Now the Compiler Switches
-
#If CurrentLibVersion = LibVer1 Then
-
AuxFuncA = FuncA(Arg1, Arg2, Arg3)
-
#ElseIf CurrentLibVersion = LibVer2 Then
-
AuxFuncA = FuncA(Arg1, Arg2, Arg3, Arg4)
-
#End If
-
-
End Function
Then just replace in your code all functions FuncA to AuxFuncA.
The good thing is that with conditional compilation VB will not try to compile this region between #If ... #End If before you are really using it.
Thanks anyway,
William Vidal.
Ah! Good idea.
I didn't realise you had the luxury of running different versions of your program on the different machines.
And yes, I suppose the number of parameters could be a problem at compile time. I wonder whether you could get around it by defining two aliases for the function, with different parameters. I have seen that done to make things safer by defining an alias which constrains certain parameters to certain data types, but never changing the number of parameters (for obvious reasons).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Penn Markham |
last post by:
Hello all,
I am writing a script where I need to use the system() function to call
htpasswd. I can do this just fine on the command line...works great
(see attached file, test.php). When my...
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: Randell D. |
last post by:
Folks,
I'm sure this can be done legally, and not thru tricks of the trade - I
hope someone can help.
I'm writing a 'tool' (a function) which can be used generically in any
of my projects. ...
|
by: anonymous |
last post by:
Thanks your reply.
The article I read is from
www.hakin9.org/en/attachments/stackoverflow_en.pdf.
And you're right. I don't know it very clearly. And that's why I want
to understand it; for it's...
|
by: Randy Yates |
last post by:
Hi,
We know we can build arrays of variables of the same type and arrays
of functions of the same "type" (i.e., same return value and same
parameters), but is there a way to automate the calling...
|
by: John Friedland |
last post by:
My problem: I need to call (from C code) an arbitrary C library
function, but I don't know until runtime what the function name is,
how many parameters are required, and what the parameters are. I...
|
by: carvalho.miguel |
last post by:
hello,
imagine you have a static class method that receives a function
pointer, an int with the number of arguments and a variable number of
arguments.
in that static method you want to call...
|
by: Larax |
last post by:
Best explanation of my question will be an example, look below at this
simple function:
function SetEventHandler(element)
{
// some operations on element
element.onclick =
function(event)
{
|
by: Felix Kater |
last post by:
Hi,
I can compile and run this code (see below) which twice calls the
function f, first with too less, second with too much arguments.
But is it legal and free of memory leaks and other...
|
by: John O'Hagan |
last post by:
On Tue Sep 30 11:32:41 CEST 2008, Steven D'Aprano
Thanks, both to you and Bruno for pointing this out, I'll certainly be using
it in future.
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |