Separato nella tabelle il campo CODTAB in COD+CODTAB
Aggiunta la possibilita' di effetture conversioni logiche git-svn-id: svn://10.65.10.50/trunk@293 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									5976cbaf1a
								
							
						
					
					
						commit
						e60478bc49
					
				@ -391,7 +391,12 @@ void BA1100_application::convert_dir()
 | 
			
		||||
    TSystemisamfile f(i);
 | 
			
		||||
    f.update(r);         
 | 
			
		||||
  }
 | 
			
		||||
  prefhndl->set(""); 
 | 
			
		||||
  const long level = prefhndl->filelevel();
 | 
			
		||||
  prefhndl->set(pref);
 | 
			
		||||
  d.get(LF_DIR, _nolock, _nordir, _sysdirop);                 
 | 
			
		||||
  d.flags() = level; 
 | 
			
		||||
  d.put(LF_DIR, _nordir, _sysdirop);                 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BA1100_application::update()
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
[199401]
 | 
			
		||||
F3=COD=CODTAB[1,3]|CODTAB=CODTAB[3,]
 | 
			
		||||
F4=COD=CODTAB[1,3]|CODTAB=CODTAB[3,]
 | 
			
		||||
F5=COD=CODTAB[1,3]|CODTAB=CODTAB[3,]
 | 
			
		||||
F(3)=COD=CODTAB[1,3]|CODTAB=CODTAB[4,]
 | 
			
		||||
F(4)=COD=CODTAB[1,3]|CODTAB=CODTAB[4,]
 | 
			
		||||
F(5)=COD=CODTAB[1,3]|CODTAB=CODTAB[4,]
 | 
			
		||||
[EOF]
 | 
			
		||||
							
								
								
									
										250
									
								
								include/isam.cpp
									
									
									
									
									
								
							
							
						
						
									
										250
									
								
								include/isam.cpp
									
									
									
									
									
								
							@ -4,13 +4,18 @@
 | 
			
		||||
#define __ISAM_CPP
 | 
			
		||||
#include <isam.h>
 | 
			
		||||
 | 
			
		||||
#include <execp.h>
 | 
			
		||||
#include <extcdecl.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
 | 
			
		||||
#ifndef FOXPRO
 | 
			
		||||
#include <progind.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <execp.h>
 | 
			
		||||
#include <relation.h>
 | 
			
		||||
#include <expr.h>
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#include <prefix.h>
 | 
			
		||||
#include <extcdecl.h>
 | 
			
		||||
#include <scanner.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define NOT_LINKED(i,f) CHECKS(i != NULL, "Record senza tracciato: impossibile eseguire ", f)
 | 
			
		||||
#define NOT_OPEN(f) CHECKS(_isamfile != NULL, "File chiuso, impossibile eseguire ", f)
 | 
			
		||||
@ -540,8 +545,6 @@ int TBaseisamfile::_open(unsigned int mode)
 | 
			
		||||
  if (filehnd() != NULL)
 | 
			
		||||
    fatal_box("Il file %d e' gia' aperto", _logicnum);
 | 
			
		||||
  
 | 
			
		||||
  //             if ((cisopen(ptrfilehnd(), _logicnum, NOALLOC, mode, &err) == NOERR) &&
 | 
			
		||||
  //                             (_historicfile))
 | 
			
		||||
  if ((cisopen(&_isamfile, _logicnum, NOALLOC, mode, &err) == NOERR) &&
 | 
			
		||||
      (_historicfile))
 | 
			
		||||
  {
 | 
			
		||||
@ -756,10 +759,6 @@ int TIsamtempfile::close(bool flagdel)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TSystemisamfile::TSystemisamfile(int logicnum, bool linkrecinst) : TIsamfile(logicnum, linkrecinst) {}
 | 
			
		||||
 | 
			
		||||
TSystemisamfile::~TSystemisamfile() {}
 | 
			
		||||
 | 
			
		||||
int TSystemisamfile::build(TRecnotype eox)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
@ -799,6 +798,55 @@ long TSystemisamfile::size(TRecnotype eox)
 | 
			
		||||
 | 
			
		||||
#ifndef FOXPRO
 | 
			
		||||
 | 
			
		||||
bool TSystemisamfile::getlcf(int flev)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  _flds.destroy();
 | 
			
		||||
  _exps.destroy();
 | 
			
		||||
  if (flev == 0) flev = 199401;
 | 
			
		||||
  else flev++;
 | 
			
		||||
  for (long l = flev; l <= stdlevel; l++)
 | 
			
		||||
  {
 | 
			
		||||
    TString16 paragraph(format("%06ld", l));
 | 
			
		||||
    TConfig conv(CONFIG_FCONV, paragraph);
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    if (!conv.new_paragraph())
 | 
			
		||||
    {
 | 
			
		||||
      TToken_string exprline(conv.get("F", NULL, num()));
 | 
			
		||||
      
 | 
			
		||||
      if (exprline.empty()) return FALSE;
 | 
			
		||||
 | 
			
		||||
      TToken_string w("", '=');
 | 
			
		||||
      const char * wexprs = exprline.get();
 | 
			
		||||
 | 
			
		||||
      while (wexprs != NULL)
 | 
			
		||||
      {
 | 
			
		||||
        w = wexprs;
 | 
			
		||||
        TFixed_string fld(w.get());
 | 
			
		||||
        _flds.add(new TFieldref(fld, 0));
 | 
			
		||||
        _exps.add(new TExpression(w.get(), _strexpr));
 | 
			
		||||
        wexprs = exprline.get();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return _flds.items() > 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TSystemisamfile::makelc(TRectype& rec)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  for (int i = 0 ; i < _flds.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    TFieldref& f = (TFieldref&) _flds[i];
 | 
			
		||||
    TExpression& e = (TExpression & )_exps[i]; 
 | 
			
		||||
 | 
			
		||||
    for (int k = 0; k < e.numvar(); k++)
 | 
			
		||||
      e.setvar(k, get(e.varname(k)));
 | 
			
		||||
    f.write(e, rec);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int TSystemisamfile::update(TTrec& newrec, bool vis)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
@ -809,7 +857,9 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
 | 
			
		||||
  TTrec  oldrec;
 | 
			
		||||
 | 
			
		||||
  oldrec.get(num());
 | 
			
		||||
  if (newrec == oldrec) return NOERR;
 | 
			
		||||
  const bool lcf = getlcf(prefhndl->filelevel());
 | 
			
		||||
 | 
			
		||||
  if (!lcf && newrec == oldrec) return NOERR;
 | 
			
		||||
  dir.get(num(), _lock, _nordir, _sysdirop);
 | 
			
		||||
  const TRecnotype nitems = dir.eod();
 | 
			
		||||
  const unsigned int lenr = newrec.len();
 | 
			
		||||
@ -837,6 +887,7 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
 | 
			
		||||
    TArray  fld(nflds);
 | 
			
		||||
    TExtrectype nrec(newrec);
 | 
			
		||||
    TRecnotype i;
 | 
			
		||||
 | 
			
		||||
    for (int j = 0; j < nflds; j++)
 | 
			
		||||
      fld.add(TString(curr().fieldname(j)), j);
 | 
			
		||||
 | 
			
		||||
@ -851,9 +902,12 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
 | 
			
		||||
        for (j = 0; j < nflds; j++)
 | 
			
		||||
          if (nrec.exist((const TString&) fld[j]))
 | 
			
		||||
            nrec.put((const TString&) fld[j], get((const TString&) fld[j]));
 | 
			
		||||
        if (lcf)
 | 
			
		||||
          makelc((TRectype &)nrec);
 | 
			
		||||
        fwrite(nrec.string(), lenr, 1, f);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    p.setstatus(nitems);
 | 
			
		||||
    close();
 | 
			
		||||
    fclose(f);
 | 
			
		||||
    fcopy(tmpfname, fname);
 | 
			
		||||
@ -865,7 +919,6 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
 | 
			
		||||
  dir.put(num(), _nordir, _sysdirop);
 | 
			
		||||
  newrec.put(num());
 | 
			
		||||
  if (dir.eox() > 0L) packindex();
 | 
			
		||||
  // setstatus(cupdatefile(num(), lenr, newrec.rec(), vis, &err));
 | 
			
		||||
  return err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -898,48 +951,98 @@ int TSystemisamfile::packindex(bool vis)
 | 
			
		||||
int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  FILE* f = fopen(from, "r+");
 | 
			
		||||
  int err = ferror(f);
 | 
			
		||||
  TRecnotype r = 0, e = 0, nitems = 1, nread = 0;
 | 
			
		||||
  if (f != NULL)
 | 
			
		||||
  FILE* fl = fopen(from, "r+");
 | 
			
		||||
  int err = ferror(fl);
 | 
			
		||||
  TRecnotype r = 0, e = 0, nitems = 0, nread = 0;
 | 
			
		||||
  if (fl == NULL) 
 | 
			
		||||
  {
 | 
			
		||||
    fseek(f, 0L, SEEK_END);
 | 
			
		||||
    nitems = ftell(f);
 | 
			
		||||
    fclose(f);
 | 
			
		||||
    f = fopen(from, "r");
 | 
			
		||||
    err = ferror(f);
 | 
			
		||||
  }  
 | 
			
		||||
  
 | 
			
		||||
  if (f == NULL) 
 | 
			
		||||
  {
 | 
			
		||||
    clearerr(f);
 | 
			
		||||
    clearerr(fl);
 | 
			
		||||
    setstatus(err);
 | 
			
		||||
    return err;
 | 
			
		||||
  }
 | 
			
		||||
  char w[80];
 | 
			
		||||
  while ((fgets(w, 80, fl) != NULL))
 | 
			
		||||
  {
 | 
			
		||||
    if (strncmp(w, "[Data]", 6) == 0)
 | 
			
		||||
    {
 | 
			
		||||
      nitems = ftell(fl);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  fseek(fl, 0L, SEEK_END);
 | 
			
		||||
  nitems = ftell(fl) - nitems;
 | 
			
		||||
  fclose(fl);
 | 
			
		||||
  TScanner f(from);
 | 
			
		||||
 | 
			
		||||
  open();
 | 
			
		||||
  
 | 
			
		||||
  TToken_string s(1024, fs);
 | 
			
		||||
  bool fixedlen = (fs == '\0');
 | 
			
		||||
  int nflds = curr().items();
 | 
			
		||||
  TArray  fld(nflds);
 | 
			
		||||
  int*            len = NULL;
 | 
			
		||||
  int    len[MaxFields];
 | 
			
		||||
  TString sfd(3);
 | 
			
		||||
  TString s1(64);
 | 
			
		||||
  bool lcf = FALSE;
 | 
			
		||||
 | 
			
		||||
  if (fixedlen) len = new int[nflds];
 | 
			
		||||
  if (f.paragraph("Header"))
 | 
			
		||||
  { 
 | 
			
		||||
    f.equal();
 | 
			
		||||
    const long level = atol(f.line());
 | 
			
		||||
    if (level > stdlevel)
 | 
			
		||||
      error_box("L' archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\n Il livello attuale e' %ld/%ld.\n Convertire gli archivi e ripetere l' operazione.", from, level / 100, level % 100, stdlevel / 100, stdlevel % 100);
 | 
			
		||||
    lcf = getlcf(level);
 | 
			
		||||
    nflds = 0;
 | 
			
		||||
    TToken_string s2(f.line());
 | 
			
		||||
    int p = s2.find('=');
 | 
			
		||||
    if (p > 0)
 | 
			
		||||
    {
 | 
			
		||||
      s1 = s2.left(p);
 | 
			
		||||
      s2.ltrim(p+1);
 | 
			
		||||
    }
 | 
			
		||||
    else s1.cut(0);
 | 
			
		||||
    while (s1 == "Fields")
 | 
			
		||||
    {
 | 
			
		||||
      for (const char * fd = s2.get(); fd != NULL;  fd = s2.get())
 | 
			
		||||
      {
 | 
			
		||||
        TToken_string wfd(fd, ',');
 | 
			
		||||
        fld.add(new TString(wfd.get()));
 | 
			
		||||
        len[nflds] = wfd.get_int();
 | 
			
		||||
        nflds++;
 | 
			
		||||
      }
 | 
			
		||||
      s2 = f.line();
 | 
			
		||||
      p = s2.find('=');
 | 
			
		||||
      if (p > 0)
 | 
			
		||||
      {
 | 
			
		||||
        s1 = s2.left(p);
 | 
			
		||||
        s2.ltrim(p+1);
 | 
			
		||||
      }
 | 
			
		||||
      else s1.cut(0);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    for (int j = 0; j < nflds; j++)
 | 
			
		||||
    {
 | 
			
		||||
      fld.add(TString(curr().fieldname(j)), j);
 | 
			
		||||
    if (fixedlen)
 | 
			
		||||
      len[j] = curr().length((const TString&)fld[j]);
 | 
			
		||||
      const TString & wfld = (const TString & ) fld[j];
 | 
			
		||||
      len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  if (!f.paragraph("Data"))
 | 
			
		||||
  {
 | 
			
		||||
    error_box("Formato dei dati non valido");
 | 
			
		||||
    close();
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  if (fd) sfd << fd;
 | 
			
		||||
  int last = NOERR;    
 | 
			
		||||
  
 | 
			
		||||
  s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last);
 | 
			
		||||
  TProgind p(nitems, s, TRUE, TRUE, 70);
 | 
			
		||||
  int c = fgetc(f);
 | 
			
		||||
  while (c != EOF && !p.iscancelled())
 | 
			
		||||
  TProgind p(nitems, s1, TRUE, TRUE, 70);
 | 
			
		||||
  s = f.line();
 | 
			
		||||
  while (s.not_empty() && !p.iscancelled())
 | 
			
		||||
  {
 | 
			
		||||
    if ((r + e) % 50 == 0)
 | 
			
		||||
    {
 | 
			
		||||
@ -947,27 +1050,23 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
 | 
			
		||||
      p.set_text(s1);
 | 
			
		||||
    }
 | 
			
		||||
    p.setstatus(nread + 1);
 | 
			
		||||
    s = "";
 | 
			
		||||
    while (c != EOF && c != rs)
 | 
			
		||||
    {
 | 
			
		||||
      s << (char) c;
 | 
			
		||||
      c = getc(f);
 | 
			
		||||
    }
 | 
			
		||||
    nread += s.len() + 1;
 | 
			
		||||
    zero();
 | 
			
		||||
    if (fixedlen)
 | 
			
		||||
    {
 | 
			
		||||
      int pos = 0;
 | 
			
		||||
      for (j = 0; j < nflds; j++)
 | 
			
		||||
      for (int j = 0; j < nflds; j++)
 | 
			
		||||
      {
 | 
			
		||||
        put((const TString&) fld[j], s.mid(pos, len[j]));
 | 
			
		||||
        s1 = s.mid(pos,len[j]);
 | 
			
		||||
        s1.rtrim();
 | 
			
		||||
        put((const TString&) fld[j], s1);
 | 
			
		||||
        pos += len[j];
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      s.restart();
 | 
			
		||||
      for (j = 0; j < nflds; j++)
 | 
			
		||||
      for (int j = 0; j < nflds; j++)
 | 
			
		||||
      {
 | 
			
		||||
        char* s2 = (char*) s.get();
 | 
			
		||||
        if (fd) 
 | 
			
		||||
@ -984,14 +1083,11 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
 | 
			
		||||
      e++;
 | 
			
		||||
      last = status();
 | 
			
		||||
    }
 | 
			
		||||
    if (c != EOF) c = fgetc(f);
 | 
			
		||||
    s = f.line();
 | 
			
		||||
  }
 | 
			
		||||
  s1.format("Imp. archivio %s : %6ld rec. %6ld errori - %3d", filename(), r, e, last);
 | 
			
		||||
  p.set_text(s1);
 | 
			
		||||
  close();
 | 
			
		||||
  fclose(f);
 | 
			
		||||
  if (fixedlen) delete len;
 | 
			
		||||
  // setstatus(cloadfile((char*)from, num(), fs, fd, rs, vis, &err));
 | 
			
		||||
  return err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1014,25 +1110,31 @@ int TSystemisamfile::dump(const char* to, int nkey, char fs, char fd, char rs, b
 | 
			
		||||
  int nflds = curr().items();
 | 
			
		||||
  TArray  fld(nflds);
 | 
			
		||||
  TBit_array rjust(nflds);
 | 
			
		||||
  int*            len = NULL;
 | 
			
		||||
  int        len[MaxFields];
 | 
			
		||||
 | 
			
		||||
  if (fixedlen) len = new int[nflds];
 | 
			
		||||
  for (int j = 0; j < nflds; j++)
 | 
			
		||||
  {
 | 
			
		||||
    fld.add(TString(curr().fieldname(j)), j);
 | 
			
		||||
    if (fixedlen)
 | 
			
		||||
    {
 | 
			
		||||
      const TFieldtypes t = curr().type((const TString&)fld[j]);
 | 
			
		||||
    const TString & wfld = (const TString&) fld[j];
 | 
			
		||||
    const TFieldtypes t = curr().type(wfld);
 | 
			
		||||
    rjust.set(j, t == _intfld || t == _longfld || t == _realfld ||
 | 
			
		||||
              t == _wordfld || t == _intzerofld || t == _longzerofld);
 | 
			
		||||
      len[j] = curr().length((const TString&)fld[j]);
 | 
			
		||||
    }
 | 
			
		||||
    len[j] = (t == _datefld) ? 10 : curr().length(wfld);
 | 
			
		||||
  }
 | 
			
		||||
  TRecnotype i = 0;
 | 
			
		||||
  const TRecnotype nitems = nkey ? items() : filehnd()->d->EOD;
 | 
			
		||||
  s.format("Esportazione archivio %s", filename());
 | 
			
		||||
  TProgind p(nitems, s, TRUE, TRUE, 50);
 | 
			
		||||
  TString s1;
 | 
			
		||||
 | 
			
		||||
  fprintf(f, "[Header]\nVersion=%ld", prefhndl->filelevel());
 | 
			
		||||
  for (int k = 0; k < nflds; k++)
 | 
			
		||||
  {
 | 
			
		||||
    if ((k % 10) == 0) fprintf(f, "\nFields=");
 | 
			
		||||
    else fprintf(f, "|");
 | 
			
		||||
    fprintf(f, "%s,%d", (const char *) (const TString&) fld[k], len[k]);
 | 
			
		||||
  }
 | 
			
		||||
  fprintf(f, "\n\n[Data]\n");
 | 
			
		||||
  if (nkey)
 | 
			
		||||
  {
 | 
			
		||||
    setkey(nkey);
 | 
			
		||||
@ -1092,10 +1194,10 @@ int TSystemisamfile::dump(const char* to, int nkey, char fs, char fd, char rs, b
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  p.setstatus(nitems);
 | 
			
		||||
  close();
 | 
			
		||||
  fclose(f);
 | 
			
		||||
  if (fixedlen) delete len;
 | 
			
		||||
  // setstatus(cdumpfile((char*)to, num(), nkey, fs, fd, rs, vis, &err));
 | 
			
		||||
  setstatus(err);
 | 
			
		||||
  return err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1106,6 +1208,7 @@ int TSystemisamfile::dump(const char* to, int nkey, char fs, char fd, char rs, b
 | 
			
		||||
////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
TRectype::TRectype(int logicnum) 
 | 
			
		||||
: _cod(NULL)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  TDir wdir;
 | 
			
		||||
@ -1117,11 +1220,12 @@ TRectype::TRectype(int logicnum)
 | 
			
		||||
  _length = wdir.len();
 | 
			
		||||
  _rec = new char [ _length ];
 | 
			
		||||
  _i = openf[_logicnum - 1];
 | 
			
		||||
  *_tab = '\0';
 | 
			
		||||
  setempty(TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TRectype::TRectype(const TBaseisamfile* i)
 | 
			
		||||
: _cod(NULL)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  _logicnum = i->num();
 | 
			
		||||
@ -1136,6 +1240,7 @@ TRectype::TRectype(const TBaseisamfile* i)
 | 
			
		||||
      wdir.get(_logicnum, _nolock, _comdir, _sysdirop);
 | 
			
		||||
    _length = wdir.len();
 | 
			
		||||
  }
 | 
			
		||||
  *_tab = '\0';
 | 
			
		||||
  _rec = new char [ _length ];
 | 
			
		||||
  _i = i->filehnd();
 | 
			
		||||
  setempty(TRUE);
 | 
			
		||||
@ -1143,24 +1248,41 @@ TRectype::TRectype(const TBaseisamfile* i)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TRectype::TRectype(const TRectype& r)
 | 
			
		||||
: _cod(NULL)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  _logicnum = r._logicnum;
 | 
			
		||||
  _length = r.len();
 | 
			
		||||
  _rec = new char [ _length ];
 | 
			
		||||
  _rec[0] = r._rec[0];
 | 
			
		||||
  // strncpy(_rec + 1, r._rec + 1, _length - 1);
 | 
			
		||||
  memcpy(_rec + 1, r._rec + 1, _length - 1);
 | 
			
		||||
  _i = r._i;
 | 
			
		||||
  strcpy(_tab, r._tab);
 | 
			
		||||
  if (r._cod != NULL)
 | 
			
		||||
    _cod = new TRecfield(*this, "COD");
 | 
			
		||||
  setempty(r.empty());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TRectype::~TRectype()
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  if (_cod != NULL) delete _cod;
 | 
			
		||||
  delete _rec;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TRectype::settab(const char *tab)
 | 
			
		||||
 | 
			
		||||
{ 
 | 
			
		||||
  if (_cod != NULL)
 | 
			
		||||
  {
 | 
			
		||||
    delete _cod;
 | 
			
		||||
    _cod = NULL;
 | 
			
		||||
  }
 | 
			
		||||
  strcpy(_tab, tab);
 | 
			
		||||
  if (*_tab != '\0')
 | 
			
		||||
    _cod = new TRecfield(*this, "COD");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TObject* TRectype::dup() const
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
@ -1430,8 +1552,6 @@ void TRectype::put(const char* fieldname, const TDate& val)
 | 
			
		||||
  NOT_LINKED(_i, "put");
 | 
			
		||||
  TRecfield f(*this, fieldname);
 | 
			
		||||
  f = val.string(4);
 | 
			
		||||
  //      long v = long(val);
 | 
			
		||||
  //      CPutField((char*) fieldname, _i->r, &v, _rec);
 | 
			
		||||
  setempty(FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1487,6 +1607,9 @@ void TRectype::zero(const char* fieldname)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  NOT_LINKED(_i, "zero");
 | 
			
		||||
  if (_cod != NULL && strcmp(fieldname , "COD") == 0)
 | 
			
		||||
    *_cod = _tab;
 | 
			
		||||
  else
 | 
			
		||||
    if (CZeroField((char*) fieldname, _i->r, _rec) == -1)
 | 
			
		||||
      UNKNOWN_FIELD(num(), fieldname);
 | 
			
		||||
}
 | 
			
		||||
@ -1505,6 +1628,8 @@ void TRectype::zero(char c)
 | 
			
		||||
  NOT_LINKED(_i, "zero");
 | 
			
		||||
  recall();
 | 
			
		||||
  memset(_rec + 1, c, len() - 1);
 | 
			
		||||
  if (_cod != NULL)
 | 
			
		||||
    *_cod = _tab;
 | 
			
		||||
  if (exist(RFLD_SYS_FIRST))
 | 
			
		||||
  {
 | 
			
		||||
    put(RFLD_SYS_FIRST, "-1");
 | 
			
		||||
@ -1518,7 +1643,7 @@ void TRectype::zero(char c)
 | 
			
		||||
TRectype& TRectype::operator =(const TRectype& rec)
 | 
			
		||||
  
 | 
			
		||||
{
 | 
			
		||||
  CHECK(num() == rec.num(), "Can't assign records of different files");
 | 
			
		||||
  CHECK(num() == rec.num(), "Can't assign records of different file");
 | 
			
		||||
  
 | 
			
		||||
  _i = rec._i;                             // Copy filehndl
 | 
			
		||||
  memcpy(_rec, rec._rec, _length);         // Copy contents
 | 
			
		||||
@ -1641,9 +1766,6 @@ HIDDEN void __getfieldbuff(byte l, byte t, const char* recin, char *s)
 | 
			
		||||
    TDate   dt(atol(s));
 | 
			
		||||
    strcpy(s, dt.string(4));
 | 
			
		||||
  }
 | 
			
		||||
  // else
 | 
			
		||||
  //       if (t == _realfld)
 | 
			
		||||
  //               if ((char* s1 = strchr(s, ',')) != NULL) *s1 = '.';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1654,7 +1776,6 @@ HIDDEN void  __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
 | 
			
		||||
 | 
			
		||||
  if (recout == NULL) return;
 | 
			
		||||
 | 
			
		||||
  // char* s2 = new char [256];
 | 
			
		||||
  char s2[256];
 | 
			
		||||
 | 
			
		||||
  strcpy(s2, s);
 | 
			
		||||
@ -1690,7 +1811,6 @@ HIDDEN void  __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
 | 
			
		||||
    strncpy(recout, s2, len) ;
 | 
			
		||||
    while (len < l) recout[len++] = ' ';
 | 
			
		||||
  }
 | 
			
		||||
  // delete s2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -61,6 +61,8 @@ class TRectype : public TSortable
 | 
			
		||||
  int                   _length;        // Lunghezza
 | 
			
		||||
  isdef*                                                        _i;             // Puntatore al file isam
 | 
			
		||||
  bool                  _isempty;       // Se il record e' vuoto
 | 
			
		||||
  char                  _tab[5];        // identificatore della tabella
 | 
			
		||||
  TRecfield *           _cod;           // campo "COD" della tabella 
 | 
			
		||||
  // @END
 | 
			
		||||
 | 
			
		||||
protected:      
 | 
			
		||||
@ -75,6 +77,7 @@ public:
 | 
			
		||||
  // FPUB 
 | 
			
		||||
  int items() const;
 | 
			
		||||
  void setdirty() { setempty(FALSE); }
 | 
			
		||||
  void settab(const char *tab);
 | 
			
		||||
  char* string() const { return _rec;}  // Ritorna il puntatore all'inizio. NON dovrebbe essere usata!
 | 
			
		||||
 | 
			
		||||
  void discard() { *_rec = char(_deleted);}     // Setta il flag di cancellazione
 | 
			
		||||
@ -340,6 +343,12 @@ public:
 | 
			
		||||
 | 
			
		||||
class TSystemisamfile : public TIsamfile
 | 
			
		||||
{
 | 
			
		||||
  TArray _flds;
 | 
			
		||||
  TArray _exps;
 | 
			
		||||
 | 
			
		||||
  bool getlcf(int flev);
 | 
			
		||||
  void makelc(TRectype& rec);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  // @FPUB
 | 
			
		||||
  int build(TRecnotype eox);    // Costruisce un file isam
 | 
			
		||||
@ -356,8 +365,9 @@ public:
 | 
			
		||||
  // @DES Esporta VERSO un file ascii. 
 | 
			
		||||
  int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE);
 | 
			
		||||
 | 
			
		||||
  TSystemisamfile(int logicnum, bool linkrecinst = TRUE);
 | 
			
		||||
  virtual ~TSystemisamfile();
 | 
			
		||||
  TSystemisamfile(int logicnum, bool linkrecinst = TRUE)
 | 
			
		||||
    : TIsamfile(logicnum, linkrecinst) {}
 | 
			
		||||
  virtual ~TSystemisamfile() {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// @C
 | 
			
		||||
 | 
			
		||||
@ -55,7 +55,7 @@ $(LIB)(files.o):        files.cpp $(I5) $(I10) $(I16) $(I28) $(I31)
 | 
			
		||||
 | 
			
		||||
$(LIB)(form.o):         form.cpp $(I24) $(I31) $(I33) $(I39) $(I40) $(I51)
 | 
			
		||||
 | 
			
		||||
$(LIB)(isam.o): isam.cpp $(I30) $(I6) $(I16) $(I1) $(I5) $(I37) $(I31)
 | 
			
		||||
$(LIB)(isam.o): isam.cpp $(I17) $(I28) $(I30) $(I6) $(I16) $(I1) $(I5) $(I37) $(I31) $(I56)
 | 
			
		||||
 | 
			
		||||
$(LIB)(mask.o): mask.cpp $(I23) $(I43) $(I33) $(I17) $(I52)
 | 
			
		||||
 | 
			
		||||
@ -67,7 +67,7 @@ $(LIB)(msksheet.o):     $(I54) $(I31) msksheet.cpp
 | 
			
		||||
 | 
			
		||||
$(LIB)(object.o):       object.cpp $(I9)
 | 
			
		||||
 | 
			
		||||
$(LIB)(prefix.o):       prefix.cpp $(I12) $(I16) $(I5) $(I31) $(I13)
 | 
			
		||||
$(LIB)(prefix.o):       prefix.cpp $(I12) $(I15) $(I16) $(I5) $(I31) $(I13)
 | 
			
		||||
 | 
			
		||||
$(LIB)(printer.o):      printer.cpp bagn001a.h $(I1) $(I2) $(I36) $(I24) $(I5) $(I48)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
//      $Id: relation.cpp,v 1.12 1994-09-23 10:58:03 guy Exp $
 | 
			
		||||
//      $Id: relation.cpp,v 1.13 1994-09-27 10:19:32 alex Exp $
 | 
			
		||||
// relation.cpp
 | 
			
		||||
// fv 12/8/93
 | 
			
		||||
// relation class for isam files
 | 
			
		||||
@ -322,7 +322,7 @@ bool TRelation::add(const char* tabname, const char* relexprs, int key,
 | 
			
		||||
    fatal_box("Can't link to file no. %d", linkto);
 | 
			
		||||
  
 | 
			
		||||
  int idx = name2ind(tabname);
 | 
			
		||||
  TTable* f = new TTable(tabname, idx == NOTFOUND);
 | 
			
		||||
  TTable* f = new TTable(tabname, FALSE);
 | 
			
		||||
  idx = _files.add(f);
 | 
			
		||||
  
 | 
			
		||||
  if (relexprs && *relexprs)
 | 
			
		||||
@ -341,11 +341,10 @@ TRectype& TRelationdef::load_rec(TRectype& r, const TBaseisamfile& from) const
 | 
			
		||||
 | 
			
		||||
  for (int j = 0 ; j < _fields.items(); j++) // for each field
 | 
			
		||||
  {
 | 
			
		||||
    //  TString& s = (TString&) _fields[j];
 | 
			
		||||
    //  r.put(s, from.get(s));
 | 
			
		||||
 | 
			
		||||
    TFieldref& s = (TFieldref&) _fields[j];
 | 
			
		||||
 | 
			
		||||
    s.write(s.read(from.curr()),r);
 | 
			
		||||
    //                r.put(s.name(), s.read(from.curr()));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return r;
 | 
			
		||||
@ -392,8 +391,6 @@ int TRelation::position_rels(TIsamop op, TReclock lockop,
 | 
			
		||||
 | 
			
		||||
        TFieldref& s = (TFieldref&) rd._fields[j];
 | 
			
		||||
        s.write(expr, from.curr());
 | 
			
		||||
        //      TString& s = (TString&) rd._fields[j];
 | 
			
		||||
        //      from.put(s, (const char*)expr);
 | 
			
		||||
      } // for each field
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -411,14 +408,9 @@ int TRelation::position_rels(TIsamop op, TReclock lockop,
 | 
			
		||||
        {
 | 
			
		||||
          if (rd._forced[kk])
 | 
			
		||||
          {
 | 
			
		||||
            //  TString& fl = (TString&)rd._fields[kk];
 | 
			
		||||
            //  const TString f_fr(from.curr().get(fl));
 | 
			
		||||
 | 
			
		||||
            TFieldref& fl = (TFieldref&)rd._fields[kk];
 | 
			
		||||
            const TString f_fr(fl.read(from.curr()));
 | 
			
		||||
 | 
			
		||||
            //                  const TFixed_string f_to(to.curr().get(fl));
 | 
			
		||||
            //                          eq = (f_fr == f_to);
 | 
			
		||||
            TExpression& expr = (TExpression&)rd._exprs[kk];
 | 
			
		||||
            for (int k = 0; k < expr.numvar(); k++)
 | 
			
		||||
              expr.setvar(k, to.get(expr.varname(k)));
 | 
			
		||||
@ -473,9 +465,6 @@ bool TRelation::next_match(int logicnum, const char* fieldlist, int nkey)
 | 
			
		||||
    {
 | 
			
		||||
      if (reldef(j)._forced[kk])
 | 
			
		||||
      {
 | 
			
		||||
        //            TString& fl = (TString&)reldef(j)._fields[kk];
 | 
			
		||||
        //            const TFixed_string f_fr(from.curr().get(fl));
 | 
			
		||||
        //            const TFixed_string f_to(to.curr().get(fl));
 | 
			
		||||
        TFieldref& fl = (TFieldref&)reldef(j)._fields[kk];
 | 
			
		||||
        const TFixed_string f_fr(fl.read(from.curr()));
 | 
			
		||||
        const TFixed_string f_to(fl.read(to.curr()));
 | 
			
		||||
@ -654,12 +643,7 @@ HIDDEN bool __evalcondition(const TRectype& r,TExpression* cond)
 | 
			
		||||
  for (int i = 0; i < cond->numvar(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    const char* s = cond->varname(i);
 | 
			
		||||
    //          if (cond->type() == _numexpr)
 | 
			
		||||
    //          {
 | 
			
		||||
    //                  real n(r.get(s));
 | 
			
		||||
    //                  cond->setvar(i, n);
 | 
			
		||||
    //          }
 | 
			
		||||
    //          else
 | 
			
		||||
 | 
			
		||||
    cond->setvar(i, r.get(s));
 | 
			
		||||
  }
 | 
			
		||||
  return (bool) *cond;
 | 
			
		||||
@ -764,17 +748,15 @@ int TCursor::filtercursor(int pagecnt, TRecnotype* page)
 | 
			
		||||
{
 | 
			
		||||
  int np = 0;
 | 
			
		||||
  TRectype& rec = file().curr();
 | 
			
		||||
  const bool tab = file().tab();
 | 
			
		||||
  if (tab)
 | 
			
		||||
  {
 | 
			
		||||
    file().filehnd()->r->Fd[0].RecOff += 3;
 | 
			
		||||
    file().filehnd()->r->Fd[0].Len -= 3;
 | 
			
		||||
  }
 | 
			
		||||
  //      TRecfield*    codtab = tab ? new TRecfield(rec, "CODTAB") : NULL;
 | 
			
		||||
  //  const bool tab = file().tab();
 | 
			
		||||
  //  if (tab)
 | 
			
		||||
  //  {
 | 
			
		||||
  //    file().filehnd()->r->Fd[0].RecOff += 3;
 | 
			
		||||
  //    file().filehnd()->r->Fd[0].Len -= 3;
 | 
			
		||||
  //  }
 | 
			
		||||
  for (int i = 0; i < pagecnt; i++)
 | 
			
		||||
  {
 | 
			
		||||
    CRead(&file().filehnd()->f, rec.string(), page[i], _nolock);
 | 
			
		||||
    //  if (tab)                *codtab = (const char*)(*codtab) + 3;
 | 
			
		||||
    if ((_filterfunction ? _filterfunction(_if) : TRUE ) &&
 | 
			
		||||
        (_fexpr ? __evalcondition(rec, _fexpr) : TRUE))
 | 
			
		||||
    {
 | 
			
		||||
@ -782,12 +764,11 @@ int TCursor::filtercursor(int pagecnt, TRecnotype* page)
 | 
			
		||||
      np++;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  if (tab)
 | 
			
		||||
  {
 | 
			
		||||
    file().filehnd()->r->Fd[0].RecOff -= 3;
 | 
			
		||||
    file().filehnd()->r->Fd[0].Len += 3;
 | 
			
		||||
  }
 | 
			
		||||
  // if (tab) delete codtab;
 | 
			
		||||
  //  if (tab)
 | 
			
		||||
  //  {
 | 
			
		||||
  //    file().filehnd()->r->Fd[0].RecOff -= 3;
 | 
			
		||||
  //    file().filehnd()->r->Fd[0].Len += 3;
 | 
			
		||||
  //  }
 | 
			
		||||
  return np;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -801,6 +782,7 @@ bool TCursor::ok() const
 | 
			
		||||
  TString       key(rec.key(_nkey)), kf(from()), kt(to());
 | 
			
		||||
  if (file().tab())
 | 
			
		||||
  {
 | 
			
		||||
    key.ltrim(3);
 | 
			
		||||
    kf.ltrim(3);
 | 
			
		||||
    kt.ltrim(3);
 | 
			
		||||
  }
 | 
			
		||||
@ -825,7 +807,6 @@ bool TCursor::changed()
 | 
			
		||||
#else
 | 
			
		||||
  int   junk = 0;
 | 
			
		||||
  const TRecnotype eod = cisgeteod(fh, &junk);
 | 
			
		||||
  //    GetHead(&fh->i, _nolock, &junk);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (_lastrec != eod ||
 | 
			
		||||
@ -850,7 +831,6 @@ TRecnotype TCursor::update()
 | 
			
		||||
  set_cursor(TASK_WIN, CURSOR_WAIT);
 | 
			
		||||
 | 
			
		||||
  TRecnotype totrec = buildcursor(file().recno());
 | 
			
		||||
  // if (has_filter()) totrec = filtercursor();
 | 
			
		||||
 | 
			
		||||
  set_cursor(TASK_WIN, old);
 | 
			
		||||
 | 
			
		||||
@ -864,7 +844,7 @@ void TCursor::filter(const char* filter, const TRectype *from,
 | 
			
		||||
{
 | 
			
		||||
  CHECK(!_frozen, "Impossibile filtrare un cursore congelato");
 | 
			
		||||
 | 
			
		||||
  TString kf(_keyfrom), kto(_keyto), kfilter, tbpref;
 | 
			
		||||
  TString kf(_keyfrom), kto(_keyto), kfilter; 
 | 
			
		||||
 | 
			
		||||
  if (filter)
 | 
			
		||||
    kfilter << filter;
 | 
			
		||||
@ -874,19 +854,17 @@ void TCursor::filter(const char* filter, const TRectype *from,
 | 
			
		||||
  if (file().tab())
 | 
			
		||||
  {
 | 
			
		||||
    TTable& f = (TTable&) file();
 | 
			
		||||
    tbpref = f.name();
 | 
			
		||||
    kf = kto = f.name();
 | 
			
		||||
  }
 | 
			
		||||
  if (from != NULL)
 | 
			
		||||
  {
 | 
			
		||||
    kf = tbpref;
 | 
			
		||||
    kf << from->key(_nkey);
 | 
			
		||||
    kf = from->key(_nkey);
 | 
			
		||||
    int p;
 | 
			
		||||
    while ((p = kf.find('~')) != -1) kf[p] = ' ';
 | 
			
		||||
  }
 | 
			
		||||
  if (to != NULL)
 | 
			
		||||
  {
 | 
			
		||||
    kto = tbpref;
 | 
			
		||||
    kto << to->key(_nkey);
 | 
			
		||||
    kto = to->key(_nkey);
 | 
			
		||||
    int p;
 | 
			
		||||
    while ((p = kto.find('~')) != -1) kto[p] = ' ';
 | 
			
		||||
  }
 | 
			
		||||
@ -981,16 +959,6 @@ TCursor::TCursor(TRelation* r, const char* filter, int nkey, TRectype *from, TRe
 | 
			
		||||
  CHECKD(_nkey > 0 && _nkey <= file().filehnd()->r->NKeys, "Bad key number : ", _nkey);
 | 
			
		||||
  _indexname.temp("ci");
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
     #if XVT_OS==XVT_OS_SCOUNIX
 | 
			
		||||
     _f = fopen(_indexname, "w+");
 | 
			
		||||
     #else
 | 
			
		||||
     _f = fopen(_indexname, "wb+");
 | 
			
		||||
     #endif
 | 
			
		||||
     if (_f == NULL)
 | 
			
		||||
     fatal_box("Can't create cursor index on file %d: %s",
 | 
			
		||||
     file().num(), strerror(errno));
 | 
			
		||||
     */
 | 
			
		||||
  FILE* _f = open_index(TRUE);
 | 
			
		||||
  fclose(_f);
 | 
			
		||||
 | 
			
		||||
@ -1020,13 +988,13 @@ TCursor::TCursor(TRelation* r, const char* filter, int nkey, TRectype *from, TRe
 | 
			
		||||
  }
 | 
			
		||||
  if (from != NULL)
 | 
			
		||||
  {
 | 
			
		||||
    _keyfrom << from->key(_nkey);
 | 
			
		||||
    _keyfrom = from->key(_nkey);
 | 
			
		||||
    int p;
 | 
			
		||||
    while ((p = _keyfrom.find('~')) != -1) _keyfrom[p] = ' ';
 | 
			
		||||
  }
 | 
			
		||||
  if (to != NULL)
 | 
			
		||||
  {
 | 
			
		||||
    _keyto << to->key(_nkey);
 | 
			
		||||
    _keyto = to->key(_nkey);
 | 
			
		||||
    int p;
 | 
			
		||||
    while ((p = _keyto.find('~')) != -1) _keyto[p] = ' ';
 | 
			
		||||
  }
 | 
			
		||||
@ -1036,7 +1004,6 @@ TCursor::TCursor(TRelation* r, const char* filter, int nkey, TRectype *from, TRe
 | 
			
		||||
TCursor::~TCursor()
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  //    fclose(_f);
 | 
			
		||||
  ::remove(_indexname);
 | 
			
		||||
  if (_fexpr) delete _fexpr;
 | 
			
		||||
}
 | 
			
		||||
@ -1065,11 +1032,11 @@ TRecnotype TCursor::readrec()
 | 
			
		||||
 | 
			
		||||
  curr().setdirty();
 | 
			
		||||
  CRead(&file().filehnd()->f, curr().string(), nrec, _nolock);
 | 
			
		||||
  if (file().tab())
 | 
			
		||||
  {
 | 
			
		||||
    TRecfield   codtab(curr(), "CODTAB");
 | 
			
		||||
    codtab = (const char*)codtab + 3;
 | 
			
		||||
  }
 | 
			
		||||
  //  if (file().tab())
 | 
			
		||||
  //  {
 | 
			
		||||
  //    TRecfield   codtab(curr(), "CODTAB");
 | 
			
		||||
  //    codtab = (const char*)codtab + 3;
 | 
			
		||||
  //  }
 | 
			
		||||
  repos();
 | 
			
		||||
  return nrec;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*      $Id: relation.h,v 1.6 1994-09-22 16:47:47 guy Exp $      */
 | 
			
		||||
/*      $Id: relation.h,v 1.7 1994-09-27 10:19:34 alex Exp $      */
 | 
			
		||||
// join.h
 | 
			
		||||
// fv 12/8/93
 | 
			
		||||
// join class for isam files
 | 
			
		||||
@ -134,7 +134,7 @@ public:
 | 
			
		||||
  TRecnotype operator --() { return prev(); }
 | 
			
		||||
 | 
			
		||||
  TRelation(int logicnum, bool linkrecinst = TRUE);
 | 
			
		||||
  TRelation(const char* tabname, bool linkrecinst = TRUE);
 | 
			
		||||
  TRelation(const char* tabname, bool linkrecinst = FALSE);
 | 
			
		||||
  virtual ~TRelation();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -13,8 +13,6 @@ int TTable::name2log(const char* n)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TTable::TTable(const char* tabname, bool linkrecinst)
 | 
			
		||||
: TLocalisamfile(name2log(tabname), linkrecinst)
 | 
			
		||||
{
 | 
			
		||||
@ -22,23 +20,25 @@ TTable::TTable(const char* tabname, bool linkrecinst)
 | 
			
		||||
  _tabname = tabname;
 | 
			
		||||
  _tabname.upper();
 | 
			
		||||
  settab(TRUE);
 | 
			
		||||
  curr().settab(_tabname);
 | 
			
		||||
  _cod = new TRecfield(curr(), "COD");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TTable::~TTable()
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  delete _cod;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int TTable::first(word lockop)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
 | 
			
		||||
  curr().zero();
 | 
			
		||||
  codtab = _tabname;
 | 
			
		||||
  zero();
 | 
			
		||||
  TBaseisamfile::read(_isgteq, lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  if (good())
 | 
			
		||||
    if (strncmp(_tabname, c, 3) != 0) setstatus(_isemptyfile);
 | 
			
		||||
  if (bad()) curr().zero();
 | 
			
		||||
  else
 | 
			
		||||
    codtab = c + 3;
 | 
			
		||||
    if (_tabname != (const char *) *_cod) setstatus(_isemptyfile);
 | 
			
		||||
  if (bad()) zero();
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -46,28 +46,22 @@ int TTable::first(word lockop)
 | 
			
		||||
int TTable::last(word lockop)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
 | 
			
		||||
  curr().zero();
 | 
			
		||||
  codtab = format("%s%c", (const char*) _tabname, 0xFF);
 | 
			
		||||
  zero();
 | 
			
		||||
  put("CODTAB", "\0xFF");
 | 
			
		||||
  TBaseisamfile::read(_isgteq);
 | 
			
		||||
  if (!eof()) TBaseisamfile::prev(lockop);
 | 
			
		||||
  else setstatus(NOERR);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  if (good())
 | 
			
		||||
    if (strncmp(_tabname, c, 3) != 0) setstatus(_isemptyfile);
 | 
			
		||||
  if (bad()) curr().zero();
 | 
			
		||||
  else 
 | 
			
		||||
    codtab = c + 3;
 | 
			
		||||
    if (_tabname != (const char *) *_cod) setstatus(_isemptyfile);
 | 
			
		||||
  if (bad()) zero();
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::next(word lockop)
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
  
 | 
			
		||||
  const TRecnotype nrec = recno();
 | 
			
		||||
 | 
			
		||||
  if (nrec != filehnd()->RecNo)
 | 
			
		||||
  {         
 | 
			
		||||
    read();
 | 
			
		||||
@ -75,67 +69,30 @@ int TTable::next(word lockop)
 | 
			
		||||
  } 
 | 
			
		||||
 | 
			
		||||
  TBaseisamfile::next(lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  if (strncmp(_tabname, c, 3) != 0)
 | 
			
		||||
  if (_tabname != (const char *) *_cod)
 | 
			
		||||
  {
 | 
			
		||||
    if (lockop == _lock) TBaseisamfile::reread(_unlock);
 | 
			
		||||
    TBaseisamfile::readat(nrec, lockop);
 | 
			
		||||
    setstatus(_iseof);
 | 
			
		||||
  }
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::prev(word lockop)
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
 | 
			
		||||
  read();
 | 
			
		||||
  if (bad()) return status();
 | 
			
		||||
 | 
			
		||||
  TRecnotype nrec = recno();
 | 
			
		||||
 | 
			
		||||
  TBaseisamfile::prev(lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  if (strncmp(_tabname, c, 3) != 0)
 | 
			
		||||
  if (_tabname != (const char *) *_cod)
 | 
			
		||||
  {
 | 
			
		||||
    if (lockop == _lock) TBaseisamfile::reread(_unlock);
 | 
			
		||||
    TBaseisamfile::readat(nrec, lockop);
 | 
			
		||||
    setstatus(_isbof);
 | 
			
		||||
  }
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::reread(word lockop, TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::reread(lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::reread(TRectype& rec, word lockop, TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(rec, "CODTAB");
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::reread(rec, lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -143,12 +100,9 @@ int TTable::reread(TRectype& rec, word lockop, TDate&)
 | 
			
		||||
int TTable::skip(TRecnotype nrec, word lockop)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
 | 
			
		||||
  if (!nrec) return NOERR;
 | 
			
		||||
  TBaseisamfile::skip(nrec, lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  if (strncmp(_tabname, c, 3) != 0)
 | 
			
		||||
  if (_tabname != (const char *) *_cod)
 | 
			
		||||
  {
 | 
			
		||||
    if (nrec > 0)
 | 
			
		||||
    {
 | 
			
		||||
@ -163,7 +117,6 @@ int TTable::skip(TRecnotype nrec, word lockop)
 | 
			
		||||
      setstatus(_isbof);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -171,21 +124,14 @@ int TTable::skip(TRecnotype nrec, word lockop)
 | 
			
		||||
int TTable::read(word op, word lockop, TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
 | 
			
		||||
  CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op);
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::read(op, lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  if (good() && strncmp(_tabname, c, 3) != 0) 
 | 
			
		||||
  if (_tabname != (const char *) *_cod)
 | 
			
		||||
  {
 | 
			
		||||
    if (lockop == _lock) TBaseisamfile::reread(_unlock);
 | 
			
		||||
    last(lockop);
 | 
			
		||||
    setstatus(_iseof);
 | 
			
		||||
  }
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -193,22 +139,14 @@ int TTable::read(word op, word lockop, TDate&)
 | 
			
		||||
int TTable::read(TRectype& rec, word op, word lockop, TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(rec, "CODTAB");
 | 
			
		||||
 | 
			
		||||
  CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op);
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::read(rec, op, lockop);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  if (good() && strncmp(_tabname, c, 3) != 0)
 | 
			
		||||
  if (_tabname != (const char *) *_cod)
 | 
			
		||||
  {
 | 
			
		||||
    setstatus(_iseof);
 | 
			
		||||
    if (lockop == _lock) TBaseisamfile::reread(_unlock);
 | 
			
		||||
    last(lockop);
 | 
			
		||||
  }
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -216,12 +154,9 @@ int TTable::read(TRectype& rec, word op, word lockop, TDate&)
 | 
			
		||||
int TTable::readat(TRecnotype nrec, word lockop)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
  TBaseisamfile::readat(nrec, lockop);
 | 
			
		||||
  TFixed_string s((const char*) codtab);
 | 
			
		||||
 | 
			
		||||
  CHECKS(_tabname == s.left(3), "Invalid position : Table ", (const char *)_tabname);
 | 
			
		||||
  codtab = &s[3];
 | 
			
		||||
  CHECKS(_tabname == (const char * ) *_cod, "Invalid position : Table ", (const char *)_tabname);
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -229,102 +164,9 @@ int TTable::readat(TRecnotype nrec, word lockop)
 | 
			
		||||
int TTable::readat(TRectype& rec ,TRecnotype nrec, word lockop)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(rec, "CODTAB");
 | 
			
		||||
  TBaseisamfile::readat(rec, nrec, lockop);
 | 
			
		||||
  TFixed_string s((const char*) codtab);
 | 
			
		||||
 | 
			
		||||
  CHECKS(_tabname == s.left(3), "Invalid position : Table ", (const char*)_tabname);
 | 
			
		||||
  codtab = &s[3];
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::write(TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::write();
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::write(const TRectype& rec, TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab((TRectype&)rec, "CODTAB");
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::write(rec);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::rewrite(TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::rewrite();
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::rewrite(const TRectype& rec, TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab((TRectype&)rec, "CODTAB");
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::rewrite(rec);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::remove(TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab(curr(), "CODTAB");
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::remove();
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TTable::remove(const TRectype& rec, TDate&)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TRecfield codtab((TRectype&)rec, "CODTAB");
 | 
			
		||||
  TFixed_string s((const char*) codtab, 80);
 | 
			
		||||
 | 
			
		||||
  s.insert(_tabname, 0);
 | 
			
		||||
  codtab = s;
 | 
			
		||||
  TBaseisamfile::remove(rec);
 | 
			
		||||
  const char *c = (const char *) codtab;
 | 
			
		||||
  codtab = c + 3;
 | 
			
		||||
  CHECKS(_tabname == (const char *) *_cod, "Invalid position : Table ", (const char *)_tabname);
 | 
			
		||||
  return status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -23,31 +23,24 @@ class TTable : public TLocalisamfile
 | 
			
		||||
{
 | 
			
		||||
  // @DPRIV
 | 
			
		||||
  TString       _tabname;
 | 
			
		||||
  TRecfield *   _cod;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  // @FPUB
 | 
			
		||||
  int first(word lockop = _nolock);
 | 
			
		||||
  int last(word lockop = _nolock);
 | 
			
		||||
  int next(word lockop = _nolock);
 | 
			
		||||
  int prev(word lockop = _nolock);
 | 
			
		||||
  int reread(word lockop = _nolock, TDate& = (TDate&)botime);
 | 
			
		||||
  int reread(TRectype& rec, word lockop = _nolock, TDate& = (TDate&)botime);
 | 
			
		||||
  int skip(TRecnotype nrec, word lockop = _nolock);
 | 
			
		||||
  int read(word op = _isequal, word lockop = _nolock, TDate& = (TDate&)botime);
 | 
			
		||||
  int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& = (TDate&)botime);
 | 
			
		||||
  int readat(TRecnotype nrec, word lockop = _nolock);
 | 
			
		||||
  int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock);
 | 
			
		||||
  int write(TDate& = (TDate&)botime);
 | 
			
		||||
  int write(const TRectype& rec, TDate& = (TDate&)botime);
 | 
			
		||||
  int rewrite(TDate& = (TDate&)botime);
 | 
			
		||||
  int rewrite(const TRectype& rec, TDate& = (TDate&)botime);
 | 
			
		||||
  int remove(TDate& = (TDate&)botime);
 | 
			
		||||
  int remove(const TRectype& rec, TDate& = (TDate&)botime);
 | 
			
		||||
  virtual int first(word lockop = _nolock);
 | 
			
		||||
  virtual int last(word lockop = _nolock);
 | 
			
		||||
  virtual int next(word lockop = _nolock);
 | 
			
		||||
  virtual int prev(word lockop = _nolock);
 | 
			
		||||
  virtual int skip(TRecnotype nrec, word lockop = _nolock);
 | 
			
		||||
  virtual int read(word op = _isequal, word lockop = _nolock, TDate& = (TDate&)botime);
 | 
			
		||||
  virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& = (TDate&)botime);
 | 
			
		||||
  virtual int readat(TRecnotype nrec, word lockop = _nolock);
 | 
			
		||||
  virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock);
 | 
			
		||||
 | 
			
		||||
  virtual const char* name() const { return (const char*) _tabname;}
 | 
			
		||||
 | 
			
		||||
  TTable(const char* tabname, bool linkrecinst = FALSE);
 | 
			
		||||
  virtual ~TTable() {}
 | 
			
		||||
  virtual ~TTable();
 | 
			
		||||
 | 
			
		||||
  static int name2log(const char* tabname);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user