A Short discussion of the use of Include If in InfoStar.

When you start out to use Include If, you generally want to print 
a  report  where only certain records are read in from the  file.  
Perhaps you want to print out all the records where the state  is 
California,  or all the people who got free review copies of your 
software.

This  usually gets you into trouble with error 19E that says that 
the field is not R-loaded.  Since this is not properly treated in 
the manual, I will address it here.

The  basic  thing to learn is that there are two types  of  field 
names that you can refer to on the Include If line:

     -    Redit field names, and
     -    Formgen field names.

Say  you want to have two fields in your  data  file,  containing 
Name and State. You set up a datafile like this:

*-------------------------------------------------*
|     Name: _________________  State: __          |
*-------------------------------------------------*

You name your fields NAME and STATE.  So far, so good.

Now,  you  want to print all these out.   You write a report like 
this:

*-------------------------------------------------*
|P          ^S     Name              State^S      |
|           _________________         __          |
*-------------------------------------------------*

You  name  your fields NAME and STATE and you define  them  as  F 
loaded  (i.e.  from  the file) and from fields by the same  name.  
Also, so far, so good.  The report should run, try it!

Now,  you  say,  "I  only want the records for  people  in  South 
Dakota"  (all three of them.)  So you go into the INCLUDE IF line 
and you write:

*-------------------------------------------------*
|INCLUDE IF $state="SD"                           |
*-------------------------------------------------*

Of course,  you were careful to set the input mask in FormGen  so 
that  lower  case would be automatically converted to upper  case 
so that you wouldn't have to worry about "sd" vs. "SD", Right?

You go to save the report and Lo and Behold,  Error  19E,  Report 
field not R-loaded!

What's  going  on here?   Redit is looking at the field  in  your 
report  called  STATE.   It's saying "he wants to  include  items 
where the REDIT field is equal to "SD",  but how can I know whether 
to include it or not until I load it into the field by which time 
it  is already included?"  Got that?   Sure you did.   Stay after 
and clean the erasers.

So,  the idea is,  we can't compare REPORT fields in INCLUDE  IF, 
because we _must_ INCLUDE the record and fill the field before we 
know  what  we're comparing to!   So,  report fields used  in  an 
Include  If _must_ be loaded before we start processing  records, 
or, in ReportStar jargon, R-Loaded.

You say:    No,  you nitwit!  You know what I'm talking about!  I 
mean the STATE in my FILE,  not the STATE on my REPORT!   Well, I 
know,  but  ReportStar  doesn't.   ReportStar seems  to  consider 
fields first in the report,  and then,  if it doesn't find it  in 
the report, it looks in the DEF file associated with that file.

Thus,  the  correct  way to clean this up is to call  the  report 
field  something besides the fieldname from the  file.   Usually, 
I'll call the field in the file STATE and the field on the report 
F STATE (as in State from the File.)

Then  you  can say 'INCLUDE IF $state="SD"' and report will  know 
what you're talking about.

Another level of complexity can be introduced that will make your 
report much more useful.  DON'T READ ON UNLESS YOU UNDERSTAND THE 
FOREGOING THOUGH!

You  may wish to print out report for South Dakota today and  for 
North Dakota tomorrow!   (Whatsamatter,  buddy,  the South Dakota 
market isn't big enough for you?  Hey Justice department, are you 
listening, we have another IBM here!)

Since  you don't want to re-redit the report every time you  need 
another state, let's look at this report:

*-------------------------------------------------*
|. state to include:  __                          |
|P          ^S     Name              State^S      |
|           _________________         __          |
*-------------------------------------------------*

Now, we have three fields, defined as follows:

FIELD     NAME           SOURCE                        LOAD WHEN

001       I STATE        Input                            R
002       NAME           F (field name NAME in file)   (always)
003       F STATE        F (field name STATE in file)  (always)

We give the following Include If line:

*-------------------------------------------------*
|INCLUDE IF $state=$i state                       |
*-------------------------------------------------*

Thus, when we crank up, we are asked for the state to include and 
then it is compared to the state in the file on each record.  All 
good!

The above described problem with confusing STATE with F STATE  is 
made  more  complex  when  a  field  is  loaded  at  startup  for 
comparison purposes. Why?  Because the message says "Field is not 
R-Loaded"  and the natural inclination is to say,  of course it's 
R-loaded, since it's obvious that I STATE must be R-Loaded, after 
all,  you knew enough to R-load it. (NOTE: R-loading is automatic 
when the source is set to Input.)

The fact that there IS an R-loaded field draws all your attention 
away  from the other side of the equals sign and you never  think 
about what the error is really flagging.  Same method of cleanup, 
though,  just make sure that the field in the file and the  field 
in the report are different.

Questions may be addressed to Ed Greenberg 76703,1070.

