[comp.databases] dBaseIV: Report Forms and Calculated Variables

regoli@silver.bacs.indiana.edu (michael regoli) (05/23/89)

][

i have a question with the report form designer and calculated
variables.

i have a database that has numeric fields: price1, price2, price3,
and freight.

i have gone into the menu "Fields" and then "add".  i then select
<create> under calculated.  then i name the variable "TOTAL" (sans
quotes) and for the expression i enter: (price1+price2+price3).
no problem or errors reported when doing this or saving and
compiling the form.

however, when i go to print, i get:

error on line nn: unrecognized phrase/keyword in command
TOTAL=(price1+price2+price3)

question: does the variable "TOTAL" as named above have to exist as a
field in the database file??  i also have a calculated variable called
GRAND that takes the value of the *field* (not a var) FREIGHT and adds
it to the calculated variable TOTAL.

here are the variable initializations per invoices.frg:

*-- Initialize calculated variables.
TOTAL=""
GRAND=""

*-- Assign initial values to calculated variables.
TOTAL=(price1+price2+price3)
GRAND=str(val(total)+freight)

another question:  why does dbIV let me define these calculated
variables without complaining and why doesn't it report this error 
when compiling the form?!

any clues on how to get this to work will be appreciated!!

thanks.

--
                        |
                        |  michael regoli
                        |  ...rutgers!iuvax!silver!regoli
                        |  regoli@silver.bacs.indiana.edu
			|  regoli@iubacs.bitnet
                        |

awd@dbase.UUCP (Alastair Dallas) (05/24/89)

In article <4088@silver.bacs.indiana.edu>, regoli@silver.bacs.indiana.edu (michael regoli) writes:
> 
> ... report form designer details omitted ...
>
> however, when i go to print, i get:
> 
> error on line nn: unrecognized phrase/keyword in command
> TOTAL=(price1+price2+price3)
> 
> question: does the variable "TOTAL" as named above have to exist as a
> field in the database file??  i also have a calculated variable called
> GRAND that takes the value of the *field* (not a var) FREIGHT and adds
> it to the calculated variable TOTAL.
>
> ... details omitted ...
> 
> another question:  why does dbIV let me define these calculated
> variables without complaining and why doesn't it report this error 
> when compiling the form?!
> 
> any clues on how to get this to work will be appreciated!!
> 
>                         |  michael regoli

I am happy to report a simple solution to this problem.  (I'm so tired of
gnarly questions in areas of dBASE IV I'm not familiar with.)  This one
is easy--TOTAL is a dBASE IV command, so the line:

	.TOTAL = <anything>

looks like the start of the TOTAL command, for which <anything> is probably
a Syntax Error.  It would be hard (but not impossible) for the report form
code generator to detect this when you add the calculated field, but, hard or
not, it doesn't.  We were talking just the other day about slowing 
down the compiler slightly in order to avoid this problem in the next release,
but I'm not sure what was decided.

There are two easy solutions.  Don't use a dBASE IV command name for your
calculated fields--use TOT or TTAL, for example.  Or, you can modify the code
which the report form generates and convert:

	.TOTAL = <anything>
to
	.STORE <anything> TO TOTAL

Sorry the REPORT command didn't detect the problem for you, but I'm glad
there is an easy fix.

/alastair/

emuleomo@yes.rutgers.edu (Emuleomo) (05/26/89)

What would we do without you alastair! I am about to start investigating
DbIV for my company.  I hope you will still be around in times of dire need.

--Emuleomo O.O.