Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:32:28+00:00 2026-05-26T18:32:28+00:00

I have little problem with printing data like this, I have written script like

  • 0

I have little problem with printing data like this, I have written script like this

[% FOREACH comp IN company %]
[% comp.name %] 
[% comp.location%]
employeedata:
[% FOREACH employee IN comp.domain.java.employee %]

[% FOREACH experiance IN employee.experiance %]

[% FOREACH obj IN ObjectDefinition%]

[% FOREACH beha IN obj.experiance %]

[% IF beha.years == experiance.years %] 

 [% beha.Name %],
  [% LAST %]
 [% END %]
   [% END %]
 [% END %]
 [% END %]
[% END %]
  [% END %]

from above script comparing “years” value in two keys in a hash and if both are same print the employee name. Its working and it printing like this as show below.

if three names is there it printing like this.

  clar, larson, per,

if two names is there it printing like this.

clar, larson,

but I need to print like this
if three names is there

clar, larson or per.

if two names is there like this

clar, larson.

if only one name is there like this

clar.

I have maximum number of names is three only. I need to print like this help me how to print like this. if any mistakes is there excuse me please.

I tried like this also

 [% FOREACH employee IN comp.domain.java.employee %]

[% FOREACH experience IN employee.experience %]

[% FOREACH obj IN ObjectDefinition%]

[% FOREACH beha IN obj.experience %]

 [% IF beha.years == experience.years %]

 [% IF employee.experience.size == 1 %]
 [% beha.Name %].


 [% ELSIF employee.experience.size == 2 %]
     [% beha.Name %],[% beha.Name %].


[% ELSIF employee.experience.size == 3 %] 
 [% beha.Name %],[% beha.Name %]or[% beha.Name %].
 [% END %]
  [% END %]
  [% END %]
  [% END %]
  [% END %]
  [% END %]

but it printing when we have one name. if we have two names it printing like this

clar,clar.
larson,larson.

if we have three names it printing like this

clar,clar or clar.
larson,larson or larson.
per,per or per.

what is wrong with my script I cant solve this problem can any body help me please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:32:29+00:00Added an answer on May 26, 2026 at 6:32 pm

    The second attempt is definitely closer to what you’re going to need. But the order of the loops doesn’t look right. beha.Name is only ever going to have the value of the current record.

    I think you want something like this:

    [%  SET staff = []; # empty list 
        FOREACH beha IN obj.experience;
            staff.push(beha) IF beha.years == experience.years;
        END; %]
    [%  IF staff.size == 1;
            staff.0.Name;
        ELSIF staff.size == 2;
            "$staff.0.Name, $staff.1.Name";
        ELSIF staff.size >= 3;
            "$staff.0.Name, $staff.1.Name or $staff.2.Name";
        END %] 
    

    The IF-ELSIF loop is not very pretty, but there’s no obvious staff.join() construction that’s going to do what you need with that mix of commas and text separators and a limit of 3 elements.

    UPDATE

    As requested, an example using .join:

    If you had an arbitrary length list of names, you might want to present them as name, name, [name, …] or name:

    ELSIF staff.size >= 3;
        SET lastname = staff.pop; #remove last person from list
        staff.join(', '); " or $lastname";
    END;
    

    But as I said previously, with a maximum of 3 names, this is overkill.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have little problem with boost::asio library. My app receive and process data asynchronously,
I have a little problem with a simple vbScript. The script has to run
I have a little problem where I would like to insert a svn diff
I have this little problem, that I cannot figure out which arguments to pass
I have a little problem with a query. I'm selecting data using the between
have a little problem with this code: UITableViewCell *cell = (UITableViewCell *)[[button superview] superview];
I'm have little problem in retrieving the data from a table here's the code:
I have a little problem with a Listview. I can load it with listview
I have a little problem with some jquery and http://www.mikage.to/jquery/jquery_history_noc.html The function works great,
I have a little problem about using jQuery (I really do not know jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.