#for-loop with different constants

Got some fantastic code that you want to share with the rest of us? Here's the place to do it.

Moderators: martin, administrator, petemonk, Moderators

#for-loop with different constants

Postby joerg » Tue May 26, 2009 7:36 am

Hi all,

I don't know if anybody knows it already, but it is possible to write a loop with different constants.
My issue was, that there are two fields CHECK_PLANING and CHECK_BOOKING. I have to call a component with different items (parameter), when calling for CHECK_PLANING I have to call MUST_I ("KAEMM") and when checking for CHECK_BOOKING I have to call MUST_I("GBH"):

Code: Select all
#for item = (PLANING, BOOKING)
if (CHECK_<art>.ENTITY = "Y")
   activate "CHECK".MUST_I("<<item>>")
endif
#endfor


In the Defines-Trigger I have defined as follows:
Code: Select all
#define PLANING = KAEMM
#define BOOKING = GBH


In the Codelisting Uniface compiled:
Code: Select all
if (CHECK_PLANING.ENTITY = "Y")
   activate "CHECK".MUST_I("KAEMM")
endif
if (CHECK_BOOKING.ENTITY = "Y")
   activate "CHECK".MUST_I("GBH")
endif


In the original code there is more to do, but I cut it. It works with Uniface 8 and I hope it will work with Uniface 9 either.

Have a nice day
Jörg
joerg
 
Posts: 194
Joined: Fri Feb 27, 2004 5:49 am
Location: Dortmund, Germany

Re: #for-loop with different constants

Postby Uli » Wed May 27, 2009 12:50 am

Hi Jörg,

an additional point, you can define your list of items as well:
Code: Select all
#define items = PLANING, BOOKING
#for item = (<items>)


If you do this in a consequent way, your sourcecode exists only of:
#define for the actual implementation details and
#include for the standardised text

see my presentation on german usergroup in 2006

Success, Uli
Success, Uli
mailto:Ulrichmerkel@web.de / http://www.uli-merkel.de
Ceterum censeo if CPWR is paid for support, CPWR should provide the support.
Uli
 
Posts: 684
Joined: Thu Jul 17, 2003 7:44 am
Location: Frankfurt / Germany


Return to Uniface: Code Examples

Who is online

Users browsing this forum: No registered users and 1 guest

cron