Subject Re: Total on in dbase 8.0
From Mervyn Bick <invalid@invalid.invalid>
Date Thu, 8 Oct 2020 12:33:03 +0200
Newsgroups dbase.getting-started

On 2020/10/08 10:59, Rouke wrote:

> Thanks for pointing that out. I have removed the trims an got this:

Simply removing the trims is no enough on its own.  You need to make
sure that the month values are all 2 characters i'e 01 for January and
so on.  The testtype values must also be padded so that they are all the
same length.  In the example I use two characters but if you have a
testtype with more digits then you must make allowances for this.

>
> TYPETOTA                 NUMBERS RECEIVED   TESTTYPE
>           0         0         0.0000            /  /
......
>           0         0         0.0000            /  /
>

Did you try the code I posted?  That should have included the calculated
field in the table with the totals even if the field is not in your
source table.


> However, I used:
>
> alter table "laplmodl.dbf" add numbers numeric, add typetota character
>
> this resulted in a numeric numbers field with a width of 20 and 4 decimal places - plenty,
> but a character typetota field with a width of 1 - far too few to store the year + month + testtype
>
> When I manually modified the table to increase the width of the typetota field to 10, the 'total on' command worked as expected.

If you want to add the fields to the source table then the syntax is

alter table "laplmod1.dbf" add numbers numeric(20,4), add typetota
character(10)

or (you can use just the table name and not the actual file name)

alter table laplmod1 add numbers numeric(20,4), add typetota character(10)


> I have looked in the dbase help for 'alter table', but at first couldn't find how to specify field width or decimals. But it say in the last line of the associated example for the 'alter table' command.

ALTER TABLE is actually a localSQL command and the localSQL help file
gives a better description.  There is a link in the description to the
acceptable file types for use with the command.  The help file supplied
with dBASE (C:\Program Files (x86)\Common
Files\Borland\BDE\localsql.hlp) is, unfortunately, not much help as
Windows 10 no longer supports .hlp files unless you apply a patch.

If you search the binaries newsgroup for  localSQL help  you will find a
message from Bruce Beachham dated 4 Dec 2018 with a .pdf version and a
message from Graham Monk dated 22 Jan 2019 with a .chm file.


Mervyn.