create paradox field got default, max. and min. value using code

rex_edit used Ask the Experts™
how to create paradox field got default, max. and min. value by using code?

i want to re-build a paradox database, but my paradox database got require field, default, min. max. value.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004
since this was my comment there, i post here:

nothing is impossible :-)
(an older sample)

//Set a Valcheck, valcheck may not exist
procedure SetValCheck(Tbl: TTable; Field: TField; MinVal, MaxVal,
          DefVal: Pointer; MinSize,MaxSize,DefSize : Integer; Required: Bool);
 hDb: hDbiDb;
 TblDesc: CRTblDesc;
 VChk: pVChkDesc;
 Dir: String;
 NumVChks: Word;
 OpType: CROpType;

 NumVChks := 0;
 SetLength(Dir, dbiMaxNameLen + 1);
 Check(DbiGetDirectory(Tbl.DBHandle, False, PChar(Dir)));
 SetLength(Dir, StrLen(PChar(Dir)));
 VChk := AllocMem(sizeof(VChkDesc));
   FillChar(TblDesc, sizeof(CRTblDesc), #0);

   VChk.iFldNum := Field.Index + 1;
   Check(DbiOpenDatabase(nil, nil, dbiReadWrite, dbiOpenExcl,
              nil, 0, nil, nil, hDb));
   Check(DbiSetDirectory(hDb, PChar(Dir)));
   with VChk^ do
     bRequired := Required;
     if MinVal <> nil then
       bHasMinVal := True;
       move(MinVal^, aMinVal, MinSize);
       bHasMinVal := False;
     if MaxVal <> nil then

       bHasMaxVal := True;
       move(MaxVal^, aMaxVal, MaxSize);
       bHasMaxVal := False;
     if DefVal <> nil then
       bHasDefVal := True;
       move(DefVal^, aDefVal, DefSize);
       bHasDefVal := False;

   TblDesc.iValChkCount := NumVChks;
   TblDesc.pVChkDesc := VChk;
   OpType := crADD;
   TblDesc.pecrValChkOp := @OpType;

   StrPCopy(TblDesc.szTblName, Tbl.TableName);
   StrCopy(TblDesc.szTblType, szParadox);
   Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));
   FreeMem(VChk, sizeof(VChkDesc));

//Help Function to encode bde-date
Function GetBDEDate(Month, Day : Word; Year : SmallInt; var MyDate : DbiDate) : DbiDate;
 Check(DbiDateEncode(Month, Day, Year, MyDate));
 Result := Mydate;

//Table must be opened exclusive,
//a validate check may not exist
procedure TForm1.Button2Click(Sender: TObject);
 cmin,cmax,cdef : Double;
 lmin,lmax,ldef : Longint;
 amin,amax,adef : String;
 bdef : Boolean;
 dmin,dmax,ddef : dbiDate;
 //Set validate for numeric Field
 cmin := -2.5;
 cmax := 2.5;
 cdef := 0.01;

 //Set Validate for Integer Field
 lmin := -100;
 lmax := 100;
 ldef := 1;

 //Set Validate for Alphanumeric Field
 amin := 'A';
 amax := 'ABCDE';
 adef := 'AB';

 //Set Validate for Boolean Field (Default only)
 bdef := False;

 //Set Validate for DateField
 dMin := GetBDEDate(1,1,1999,dmin);
 dMax := GetBDEDate(12,31,1999,dmax);
 dDef := GetBDEDate(7,1,1999,ddef);


the bde-unit must be added to the uses clause to get it work

if this was, for what you are after,
roza deserves the points, of course

meikl ;-)


just for update a new table, what i want is check the table and re-create the table with index key and validy check.

so the answer is half only, but with this half-answer i found the way to the other half-answer^^.
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Top Expert 2004

>check the table and re-create the table with index key
i don't see this requirements in the question
Top Expert 2004


i post a q for you, because you was first
-> 75 points a-grade

watch out

meikl ;-)

If the comment helped you to solve your problem, it was a perfect answer, that's why I upgraded to 'A'. If the comment didn't help, then you could always ask for a refund of your points.

** Mindphaser - Community Support Moderator **

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial