&IF Question.

nate100

Member
I have the following loop:

def var siteval as logical.
update siteval.

For each in_mstr no-lock:
display in_part.
end.

What I want to do is that if the user wants to order by
the site, I want to do it in the same look.
Is it possible to do something like this as follows:

For each in_mstr no-lock {&If siteval then BY in_site}:
display in_part.
end.

This doesn't work. I want to do it in the same loop.

Thanks
 
You can do it with a normal IF .


Code:
def var siteval as logical.
update siteval.

For each in_mstr no-lock 
    BY IF siteval THEN in_site ELSE <normal sort field>:
display in_part.
end.
 
Hello,
I want to actually do an Order by so that is why I had it like that in the FOR EACH LOOP:

For each in_mstr no-lock {&If siteval then BY in_site}:
display in_part.
end.

Thanks
 
I want to actually do an Order by so that is why I had it like that in the FOR EACH LOOP:

Check my example , it actually does a Order By. You only need to specify th e normal sort field in the ELSE part.
 
I am getting error when I do it:

def var siteval as logical.
update siteval.

for each in_mstr where in_domain = 'us1'
BY IF siteval THEN in_site:
display in_part in_site.
end.


Any ideas..
 
Another thing is that I do not want to do a 'BY' if siteval = FALSE.
I only want to do it if it is TRUE.

Thanks in advance.
 
Then just put the first field of your primary key in the ELSE field . The it will use the sort it would have used anyway.

It either that or you do a full dynamic query (wich use the QUERY AND BUFFER objects instead of a simple FOR EACH ) wich is more complicated.

The &IF clause is something that resolved at compile time , it cannot be used like you say.
 
Back
Top