Forum Discussion

jaja-oliveira's avatar
jaja-oliveira
Occasional Contributor
13 years ago

Special condition in the Uses statement

Hi,



  I have two script units with the exactly same procedures and parameters, but with diferent implementation for each ones. I'd like to choose wich one I'm going to use in my main script, for example:



if project.variables.Option = '1' then

  uses Unit1

else

  uses Unit2



Is there any way to do something like this? Can I set by programming wich unit I'm gonna use on the Uses reference?



Thank's a lot

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Sorry, there's no way to do this.  Best suggestion would be to use BOTH units but then use that kind of logic in your actual code execution and specify using UnitName.ProcedureName in order to distinguish between the two implementations.



    To be honest, if the code units are that closely related, I actually question whether or not this is a "good practice" or if you should, within a single unit, make distinctions within the procedures themselves to detect or make modifications.



    The other way to do it is to create a "wrapper" unit that uses the two units you have that receives that option and just, depending upon the option, calls the different procedures.  That way, in your actual test code, you only need one "uses" clause but your middle-unit takes care of making the distinction.