Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NN0505.ZIP
Filename : BGEN.PRG
Output of file : BGEN.PRG contained in archive : NN0505.ZIP
Program: BGEN
Author: A. Timothy Wong
Date: August 8, 1990
Version: Clipper 5.0
Note: Utility to generate random data for .dbf files.
Compile with: /n/w/a
Copyright (c) 1990, Nantucket Corporation
ALL RIGHTS RESERVED.
*/
// Declaration Code
#include "DBStruct.ch"
#define MAGIC_NUMBER 1825
// Execution Code
PROCEDURE BGen(cDataFile, nRecsWanted, lStrRepeat, cStation, lFillAll)
// cDataFile - .dbf filename
// nRecsWanted - # of records to be generated
// lStrRepeat - Whether the strings have repeated value
// cStation - Work station ID
// lFillAll - Fill whole field
LOCAL I,J,cFields,nJunk,nLeft
IF cDataFile == NIL
QOUT("BGEN |filename| [# records][str. Repeat][station name][fill all]")
QQOUT(CHR(7))
QUIT
ENDIF
IF nRecsWanted == NIL
nRecsWanted := 10
ELSE
nRecsWanted := VAL(nRecsWanted)
ENDIF
IF lStrRepeat == NIL
lStrRepeat := .F.
ELSE
lStrRepeat := IIF(lStrRepeat == "Y" .OR. lStrRepeat == "y",.T.,.F.)
ENDIF
IF cStation == NIL
cStation := "TEST"
ELSE
cStation := UPPER(cStation)
ENDIF
IF lFillAll == NIL
lFillAll := .F.
ELSE
lFillAll := IIF(lFillAll == "Y" .OR. lFillAll == "y",.T.,.F.)
ENDIF
Randomize()
CLEAR SCREEN
USE (cDatafile) SHARED // open the data base
cFields := DBSTRUCT()
FOR I := 1 TO nRecsWanted
@ 3,1 SAY TRANSFORM( (nRecsWanted - I), "999,999,999,999") + " records to go."
* AddRec(1)
APPEND BLANK
@ 4,1 SAY TRANSFORM(RECNO(),"999,999,999,999")+ " current total records."
FOR J := 1 TO LEN(cFields)
DO CASE
CASE cFields[J,DBS_TYPE] == "C"
// Character Field
FIELDPUT(J,RandomString(IF(lFillAll, cFields[J,DBS_LEN], ;
INT(cFields[J,DBS_LEN] / 2)), ;
cFields[J,DBS_LEN],lStrRepeat,lFillAll))
CASE cFields[J,DBS_TYPE] == "D"
// Date Field
FIELDPUT(J,RandomDate( MAGIC_NUMBER ))
CASE cFields[J,DBS_TYPE] == "L"
// Logical Field
FIELDPUT(J,RandomLogical())
CASE cFields[J,DBS_TYPE] == "N"
// Numeric Field
nLeft := cFields[J,DBS_LEN] - ;
(cFields[J,DBS_DEC] + ;
IIF(cFields[J,DBS_DEC] = 0, 0, 1))
nJunk := IIF(nLeft = 1, ;
ABS(RandomTemplate(nLeft, ;
cFields[J,DBS_DEC])),;
RandomTemplate(nLeft,cFields[J,DBS_DEC]))
FIELDPUT(J,nJunk)
CASE cFields[J,DBS_TYPE] == "M"
// Memo Field
FIELDPUT(J,"Record # " + ;
TRANSFORM(RECNO(),"999,999,999") + ;
" added by " + cStation)
ENDCASE
NEXT
COMMIT
NEXT
USE // Close zee database.
RETURN
// EOF: Bgen.prg
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/