Category : C++ Source Code
Archive   : PXBEN.ZIP
Filename : PDXTBLGE.CPP

 
Output of file : PDXTBLGE.CPP contained in archive : PXBEN.ZIP
/*ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ ³
³ Module: PDXTBLGE.CPP ³
³ Author: Rick Kligman ³
³ Purpose: Source code for Paradox Table Generic Class ³
³ ³
³ Last Modified: 05-17-91 00:34am ³
³ ³
³ Copyright 1991 Rick Kligman ³
³ This code may be freely used and distributed in commercial apps ³
³ provided some mention of PXBuddy++ is made in the documentation. ³
³ ³
³ Version 1.00 ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ */

#include "pdxtblge.h"

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Constructor for GenericTbl class º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

GenericTbl::GenericTbl()
{
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Destructor for GenericTbl class º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

GenericTbl::~GenericTbl()
{
}


// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Search for CHAR value º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::search(char *fld, char *srchvar, int mode)
{
FIELDHANDLE fh;
int err;

err = PXFldHandle(th, fld, &fh);
CKERR;

err = PXPutAlpha(rh, fh, srchvar);
CKERR;

err = search_fld(fh, mode);

return (err); // if no error then PXSUCCESS will be returned
}


// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Actually Search Field º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::search_fld(FIELDHANDLE fh, int mode)
{
int err;

// extra if on CLOSESTRECORD is done because even if it finds something
// it will return RECNOTFOUND since it is an inexact match

err = PXSrchFld(th, rh, fh, mode);
if (mode == CLOSESTRECORD && err == PXERR_RECNOTFOUND)
err = PXSUCCESS;

return (err); // if no error then PXSUCCESS will be returned
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a char field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::getfld(FIELDHANDLE fh, int fldlen, char *field)

{
int blank;
int err;

err = PXFldBlank(rh, fh, &blank);
CKERR;

if (blank) // char field was blank
field [0] = NULL;
else
if ((err = PXGetAlpha(rh, fh, fldlen, field)) != 0)
if (err == PXERR_BUFTOOSMALL)
err = PXSUCCESS;


return err; // will be PXSUCCESS if everything went OK
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a short field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::getfld(FIELDHANDLE fh, short &field)
{
int blank;
int err;

err = PXFldBlank(rh, fh, &blank);
CKERR;

if (blank) // short was blank
field = 0;
else
err = PXGetShort(rh, fh, &field);

return err; // will be PXSUCCESS if everything went OK
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a double field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::getfld(FIELDHANDLE fh, double &field)
{
int blank;
int err;

err = PXFldBlank(rh, fh, &blank);
CKERR;

if (blank) // double was blank
field = 0;
else
err = PXGetDoub(rh, fh, &field);

return err; // will be PXSUCCESS if everything went OK
}


// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a date field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::getfld(FIELDHANDLE fh, char *field)
{
int blank;
int err;
long date;

err = PXFldBlank(rh, fh, &blank);
CKERR;

if (blank) // date was blank
field [0] = NULL;
else {
err = PXGetDate(rh, fh, &date);
CKERR;
date_decode(field, date);
}

return err; // will be PXSUCCESS if everything went OK
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a char field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::putfld(FIELDHANDLE fh, char *field)
{
int err;

err = PXPutAlpha(rh, fh, field);

return err; // will be PXSUCCESS if everything went OK
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a short field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::putfld(FIELDHANDLE fh, short &field)
{
int err;

if ( field == 0 && (! blanks_as_zeros) )
err = PXPutBlank(rh, fh);
else
err = PXPutShort(rh, fh, field);

return err; // will be PXSUCCESS if everything went OK
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a double field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::putfld(FIELDHANDLE fh, double &field)
{
int err;

if ( field == 0 && (! blanks_as_zeros) )
err = PXPutBlank(rh, fh);
else
err = PXPutDoub(rh, fh, field);

return err; // will be PXSUCCESS if everything went OK
}


// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Test a date field to see if its blank º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::putfld(FIELDHANDLE fh, char *field, int)
{
int err;

// if the date is blank it can be one of two things. If the user never
// enters the field then it will be NULL. If the user does go through
// the field and leaves it blank, Vermont converts the date to 00/00/00

if ( (field [0] == NULL || (field [0] == '0' && field [1] == '0')) &&
(! blanks_as_zeros) )
err = PXPutBlank(rh, fh);
else
err = date_encode(rh, fh, field);

return err; // will be PXSUCCESS if everything went OK
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Make a Date into a string º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

void GenericTbl::date_decode(char *newdate, long date)
{
int month, day, year;
char mm [3], dd [3], yy [5], inter [3];
char s [12];

PXDateDecode(date, &month, &day, &year);

itoa(month, mm, 10); // here we want to format the date
itoa(day, dd, 10); // so that it appears as 05/03/90
itoa(year, yy, 10);

inter [2] = NULL; // only need to NULL once

if (strlen(mm) == 1) {
inter [0] = '0';
inter [1] = mm [0];
strcpy(mm, inter);
}

if (strlen(dd) == 1) {
inter [0] = '0';
inter [1] = dd [0];
strcpy(dd, inter);
}

inter [0] = yy [2];
inter [1] = yy [3];
strcpy(yy, inter);

strcpy(s, mm);
strcat(s, "/");
strcat(s, dd);
strcat(s, "/");
strcat(s, yy);

strcpy(newdate, s);
}

// ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
// º Make a String into a Date º
// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

int GenericTbl::date_encode(RECORDHANDLE rh, FIELDHANDLE fh, char *olddate)
{
long date;
int month, day, year;
int err;
char inter [3];

inter [0] = olddate [0];
inter [1] = olddate [1];
inter [2] = NULL;
month = atoi(inter);

inter [0] = olddate [3];
inter [1] = olddate [4];
day = atoi(inter);

inter [0] = olddate [6];
inter [1] = olddate [7];
year = atoi(inter);

err = PXDateEncode(month, day, year, &date);
CKERR;

err = PXPutDate(rh, fh, date);

return err;
}



  3 Responses to “Category : C++ Source Code
Archive   : PXBEN.ZIP
Filename : PDXTBLGE.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. 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/