Sun Oct 25, 2020 11:35 am
Login Register Lost Password? Contact Us


Reading a Repository Name in a Module/Function

Comments and questions related to the Enterprise Control Language

Fri Aug 07, 2020 5:21 pm Change Time Zone

How can I read the repo name in the code ?
RuchiM
 
Posts: 6
Joined: Wed Jul 22, 2020 10:04 pm

Sun Aug 09, 2020 8:28 pm Change Time Zone

Hello RuchiM,

I am not sure I fully understand the question (maybe you can elaborate a little bit more on what you are trying to achieve), but as long as you have structured your local repository(ies) by containing ECL definition files (.ecl) within modules (brown colored folders in your ECL IDE repository window), then referencing/calling an exported definition from another mapped repository/module would be just a matter of:

1) using an IMPORT statement to the source module (no need for the repository name);
2) fully qualifying the imported definition whenever it is referenced in the code.

HTH,
hwatanuki
hwatanuki
 
Posts: 18
Joined: Mon Apr 15, 2019 1:22 am

Sun Aug 09, 2020 8:34 pm Change Time Zone

Hi Hwatanuki,

Thanks for your reply, ok let me explain my question again.
Suppose there is a repository in ECL IDE called Statistics and there is a module called Utilities in it. I want to pass the repo name i.e. Statistics as a parameter to a function. I just need the name of that repo as a parameter or stored in any variable. Is that possible ?

I know I can import the repo name and use it in any module of any other repository or any module of the same repository.

Thanks again for your help.

Regards,
RuchiM
RuchiM
 
Posts: 6
Joined: Wed Jul 22, 2020 10:04 pm

Mon Aug 10, 2020 12:40 pm Change Time Zone

RuchiM,

Exactly what are you trying to accomplish? What do you want to do that requires the name of your repository's directory structure?

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1560
Joined: Wed Oct 26, 2011 7:40 pm

Mon Aug 10, 2020 1:40 pm Change Time Zone

HI Richard,

So I have a Repository called HC_Data_Statistics, I want to run Statistics on different files which are the results of different projects/Repositories (for eg: Here I am using two different Repos i.e. HC_DATA_NOIDS and HC_DATA_DEA).

Step 1 :
I wrote a Macro to read different files like this . Here Files is an attribute in each of the repository.
EXPORT GetCurrentFile(Name) := FUNCTIONMACRO
RETURN #EXPAND(Name).Files().Base.new; //Current File
ENDMACRO;

Step 2: The above function macro is being called in GetBase Function which is reading the files.
EXPORT GetBase := FUNCTION
//----READING NOIDS FILES---------------------------------
NOIDSPREVIOUSBASE := GetPreviousFile('HC_DATA_NOIDS');
NOIDSCURRENTBASE := GetCurrentFile('HC_DATA_NOIDS');
//----READING DEA FILES ----------------------------------
DEAPREVIOUSBASE := GetPreviousFile('HC_DATA_DEA');
DEACURRENTBASE := GetCurrentFile('HC_DATA_DEA');
RETURN MODULE
EXPORT NOIDSPDATASET := NOIDSPREVIOUSBASE;
EXPORT NOIDSCDATASET := NOIDSCURRENTBASE;
EXPORT DEAPDATASET := DEAPREVIOUSBASE;
EXPORT DEACDATASET := DEACURRENTBASE;
END; //END OF RETURN MODULE
END;//END OF GET BASE FUNCTION

Step 3 : In another attribute (Get_Counts) of the Repository HC_DATA_STATISTICS, I want to call GetBase function based on the name of the Repository in which I will insert the Call of Get_Counts. So as you see below, cdataset and pdataset should have values according to the parameter NAME of Get_Counts. This Module will be called in all the Repositories/Builds Code and it should read the files according to what repository it is in.

EXPORT Get_Counts(STRING NAME) := MODULE
EXPORT cdataset := if(Name = 'Noids',Utils.GetBase.NOIDSCDATASET);
EXPORT pdataset := if(Name = 'Noids', Utils.GetBase.NOIDSPDATASET);
END; //end of Get_Counts Module


Hope I am able to communicate what I want to do. Thanks for the help..

Regards,
Ruchika
RuchiM
 
Posts: 6
Joined: Wed Jul 22, 2020 10:04 pm

Mon Aug 10, 2020 6:37 pm Change Time Zone

Hello Ruchika,

Thanks for the detailed example. It is now much clearer what you are trying to accomplish, but I am afraid that the precise functionality you are looking for is an enhancement still being explored on the roadmap: https://track.hpccsystems.com/browse/HPCC-24449

For the time being, I believe that the best alternative for your current need would be to have your repositories "HC_DATA_NOIDS" and "HPC_DATA_DEA" defined as separate modules (sub directories) in the ECL IDE repository. Note that you can do this by simply referencing the target repository's parent folder (instead the repository folder itself) when including it as a "ECL folder" under the "Compiler" tab of your ECL IDE "preferences" menu.

By doing this, you will be able to work with IMPORT statements and fully qualification of your exported definitions with minimized risk of naming clashes between the different repositories.

HTH,
Hugo
hwatanuki
 
Posts: 18
Joined: Mon Apr 15, 2019 1:22 am

Mon Aug 10, 2020 9:48 pm Change Time Zone

Thanks Hugo for the suggestion but thats not working in my use case.

Regards,
Ruchika
RuchiM
 
Posts: 6
Joined: Wed Jul 22, 2020 10:04 pm

Tue Aug 11, 2020 4:08 am Change Time Zone

No problem, feel free to share the piece that is not working and maybe we can find a way around it. ;)
hwatanuki
 
Posts: 18
Joined: Mon Apr 15, 2019 1:22 am

Tue Aug 11, 2020 11:49 am Change Time Zone

Ruchika,

Perhaps another approach might work better.

Take a look at Allan Wrobel's "Universal WU Scheduler" for some ideas. He posted it in our Tips and Tricks forum in these two posts: https://hpccsystems.com/bb/viewtopic.php?f=41&t=7813 and https://hpccsystems.com/bb/viewtopic.php?f=41&t=7803

I suggest this because I don't believe there is any native way to automatically get those directory names in ECL and Allan's approach may give you a way to manage the task without too much "manual labor" involved.

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1560
Joined: Wed Oct 26, 2011 7:40 pm

Mon Aug 24, 2020 9:17 am Change Time Zone

Hi hwatanuki,

I may not have your precise issue straight, but we have multiple repos, one for development, certification, production etc and we have different settings that are environment specific.
All repos hold an identically named filename, e.g.
Code: Select all
Control/Environment.ecl

This can contain a string that identifies the environment, e.g.
Code: Select all
EXPORT ID := 'DEV';

Each environment has 'ID' setup appropriately.
All code that needs to use environment specific attributes uses:
Code: Select all
IMPORT Control;

then uses the ID attribute from 'Environment' thus:
Code: Select all
#IF(Control.Environment.ID = 'PROD')
  EXPORT  STRING          TargetURL   :=  'someurl';
#ELSEIF(Control.Environment.ID = 'QA') 
  EXPORT  STRING          TargetURL   :=  'some other url';
#ELSE
  EXPORT  STRING          TargetURL   :=  'Development url';
#END

The application then juse uses 'TargetURL' which is now defined in an environmentally specific way.
Code: Select all
SOAPCALL(TargetURL,...);


As I said I may not understand your issue, but hope this might help.
Yours
Allan
Allan
 
Posts: 431
Joined: Sat Oct 01, 2011 7:26 pm


Return to ECL

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron