Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : TN8903.ZIP
Filename : TL_PRGS.ASC
Output of file : TL_PRGS.ASC contained in archive : TN8903.ZIP
* EOP: Pgfoot // already there
{return; // already there
enddef} // already there
//
// Gary. 3/3/89. (Now Line 2023)
// User Defined Functions to handle Special SUM Fields
//
// ----------------------
// UDF: set_ssf_prefix
// ----------------------
// This function sets the ssf_prefix template language variable
// to its default SPSU (for special SUM). ssf_prefix determines
// what prefix the rest of the template should look for in field
names.
// If there is a calculated field called RPrefix,
// ssf_prefix will take the value of its Expression, which
// must be a string (67). The function then removes the ""
// around that string.
//
{define set_ssf_prefix();
ssf_prefix = ssf_default_prefix;
foreach FLD_ELEMENT
if (FLD_FIELDTYPE == Calc_data) && (FLD_VALUE_TYPE == 67) then
if FLD_FIELDNAME == ssf_prefix_field then
ssf_prefix = SUBSTR(FLD_EXPRESSION, 2);
ssf_prefix = SUBSTR(ssf_prefix, 1, LEN(ssf_prefix)-1);
exit;
endif;
endif;
next;
return;
enddef}
Listing 2
//
// ---------------------
// UDF: set_ssf_present
// ---------------------
// This UDF sets the ssf_present variable. If ssf_present is 0,
there
// are no special SUM fields in the report. If it is 1, there is
at
// least one. The function goes through all the fields in the report
// until it finds a field with the ssf_prefix or there are no more
// fields. An ssf field can only be Float (70) or Numeric (78).
//
{define set_ssf_present();
ssf_present = 0;
foreach FLD_ELEMENT
if (FLD_FIELDTYPE == Calc_data) && (
(FLD_VALUE_TYPE == 70) || (FLD_VALUE_TYPE == 78)) then
if AT(ssf_prefix, FLD_FIELDNAME) == 1 then
ssf_present = 1;}
*-- Special SUM Field Prefix is {ssf_prefix}.
{ exit;
endif;
endif;
next;
return;
enddef}
Listing 3
//
// -----------------
// UDF insert_ssf
// -----------------
// This function inserts the SUM commands for the
// appropriate fields, Float (70) or Numeric (78).
// Pay attention to how we must save and restore
// the record pointer. The LOCATE command is used
// because the main DO WHILE loop that goes through
// all the records in the database has a FOUND()
// in its condition. The LOCATE command will force
// FOUND() to return .T. (True) and the DO WHILE loop
// to be entered.
// Added feature: The field description (if any) will be used
// as a FOR condition on the SUM.
//
{define insert_ssf();
if ssf_present then }
*-- Save Record Number.
SavedRecNo = RECNO()
*-- Perform SUMs.
{ foreach FLD_ELEMENT
if (FLD_VALUE_TYPE == 70) || (FLD_VALUE_TYPE == 78) then
if AT(ssf_prefix, FLD_FIELDNAME) == 1 then }
SUM ALL {FLD_EXPRESSION} TO {FLD_FIELDNAME} \
{ if LEN(FLD_DESCRIPT) != 0 then} \
FOR {FLD_DESCRIPT} \
{ endif}
{ endif;
endif;
next}
*-- Restore Record Number and insure that FOUND() will return
*-- .T. (True) with the LOCATE Command.
GOTO SavedRecNo
LOCATE
{endif;
return;
enddef}
Listing 4
//
// Gary. 3/3/89. (Now Line 469)
// Check for special SUM fields.
// The position of this code is critical. We must set
// our fields after they have been initialized (Line 308)
// but before they are used in other assignments below.
//
{set_ssf_prefix();}
{set_ssf_present();}
{insert_ssf();}
// The following section has been modified.
{x=0;}
{foreach FLD_ELEMENT k}
//
// Generate only if there is a field name assigned to the
// calculated field.
//
{ if FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
{ if !x then}
*-- Assign initial values to calculated variables.
{ endif}
//
// Generate only if not a special SUM field.
//
{ if ! (ssf_present && (AT(ssf_prefix, FLD_FIELDNAME) == 1))}
{FLD_FIELDNAME}=\
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
{ ++x;}
{ endif}
{next k;}
Listing 5
// This section has been modified.
// Initialize calculated fields
// in case they are used in the group break procedure.
//
{ if BAND_BANDTYPE != Detail then}
{ foreach FLD_ELEMENT k}
{ if GROUP == i && FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME
then}
//
// Gary, 3/3/89. (Line 1287).
// Only generate if not a special SUM field.
//
{ if ! (ssf_present && (AT(ssf_prefix, FLD_FIELDNAME) ==
1)) then}
{FLD_FIELDNAME}=\
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
{ endif}
{ next k;}
{ endif}
v
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/