

                                 Table Of Contents


1.0  INTRODUCTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
       1.1    REPDUP . . . . . . . . . . . . . . . . . . . . . . . . . . .   4
       1.2    REDISP . . . . . . . . . . . . . . . . . . . . . . . . . . .   6
       1.3    MODDATA. . . . . . . . . . . . . . . . . . . . . . . . . . .   7
       1.4    RECCOPY. . . . . . . . . . . . . . . . . . . . . . . . . . .   9



                                        Page 2

                                 1.0  INTRODUCTION




The SCBREP library provides a number of functions to simplify the task of
creatin temporary variables for GET's, filling in GET variables from databases
with similar field names and duplicating records across databases. All of
these procedures are quite simple to perform manually, but are just time
consuming to code.

The main functions of SCBREP are:

RepDup        Copies fields into the current GET for all fields that have same
              name as a GET variable.

Moddata       Creates variables using field names from a specified database
              and prefixing them with a character. Automatically initializes the
              variables with the approriate type and field length.

Redisp        Redisplays all the gets.

Reccopy       Copies a record from a source database to a target database
              for all fields that exist in both the target database and source
              database. 


                                        Page 3


The SCBREP library is copyright of the author, Stein Borge, 1995 and is
released as Shareware.  Program authors may incorporate it freely into their
applications for testing and inspection.

You may use SCBREP.LIB free for a 30 day evaluation period.  SCBREP.LIB
is Shareware, which means each user must register his or her copy for use
beyond the evaluation period.  Use of non-registered copies of SCBREP.LIB
is prohibited.

If it is used beyond the 30 day evaluation period a once only contribution of
$US 10. Upon receipt of payment copies of the source code will be made
available. The Shareware version does not support record locking it it's record
functions.

Since I currently don't have a permanent fixed address, please E-Mail me at
my Compuserve account 76720,3454 for current address information, or any
queries or questions you may have about the library.

If your sending mail from the Internet address it to
76720,3454@compuserve.com

You are encouraged to make copies of SCBREP.LIB to give to your friends
or to upload to your favourite BBS.  These copies should be the original
SCBREP.ZIP file.

This library has been a great help to me and I hope that it will be to you, too. 
A great deal of time has gone into this library, and I am constantly trying to
improve it. Please feel free to send comments on enhancements you would
like to see in the library, or to report on any bugs or questions you may have
about the library.

And finally, the legal bit...

Disclaimer

The user of this library takes full responsibility for any loss or damaged data
that might occur as a result of using this library.  I have made every attempt
to ensure that this library will respond as described. Stein Borge will take no
responsibility if an error occurs and data is lost or data becomes damaged
and the cause has been found to be the  functions operations.

Stein Borge

                                        Page 4


1.1    REPDUP


Description 

Copies fields into the current GET for all fields that have same name as a
GET variable.

Syntax

repdup(cPref)

Arguments:

cPref  Character. This is the character the target fields start with. So if the
       target GET fields are prefixed with the character "n" then pass "n" as
       the parameter. If the target GET's are not prefixed then pass a blank
       character string.

Returns

Nothing.

Example

/* The following example would fill in the fields ncustno,ncustname and
naddress with corresponding values from the cust database that are not
prefixed (ie. custno, custname and address)*/

public ncustno,nname,naddress,nphone

select customer

 @1,1 say "Customer# " get ncustno valid chknum()
 @2,1 say "Name      " get nname when .F.
 @3,1 say "Address   " get naddress1 when .F.
 @4,1 say "Phone     " get nphone when .F.
read

                                        Page 5

// Find the customer
function chknum()

// Search for the entered client number..
seek(getactive():varget())

/* If it is found, RepDup will replace all GET field variables with customer
database fields with the same name*/

if found()
 RepDup("N")
 ReDisp() // Redisplays GETs
endif

                                        Page 6


1.2    REDISP

Description 

Redisplay the current active gets.

Syntax

Redisp()

Arguments:

None.

Returns

Nothing.

Example

The following example asks for a cost and quantity and recalculates tax and
totals every time the value is changed and redisplays the totals. Note the
total,tax and gtotal fields are when .F., which guarantees they're will never be
accessed. This is needed to add them to GETLIST in order for redisp() to
redisplay the values.

@1,1 say "Enter cost " get cost valid updat()
@2,1 say "Enter quantity " get quantity valid updat()
@3,1 say "Tax " get tax when .F.
@4,1 say "Total " get total when .F.
@5,1 say "Total with tax " get gtotal when .F.

function updat
 tax:=cost*quantity*.07
 total:=cost*quantity
 gtotal:=total+tax
 redisp()
return(.T.)


                                        Page 7


1.3    MODDATA

Description

Moddata() creates temporary variables based on the current active database
and either edits the current record or adds a new one base on the parameters
you pass. If you add a new record moddate will automatically create
temporary variables using a field name and a prefix character and assign it
whatever default values required. 

Syntax

moddata(cMode, [bAb], gproc,cPref)

Arguments

cMode         Character. If cMode is "A", then it is add mode, if "E" it is in edit
              mode. 

bAb           Codeblock. This codeblock is called before the GET function is
              called. Is used for assigning defualt values to GET variables, ie.
              generating order numbers or default dates and times. Optional
              value.

gproc         Codeblock. Function that contains the GETs. The values this
              function returns controls how moddate() updates the database.
              If the function returns .T. to moddata(), then moddata() will
              update the database. If the function returns .F., it will do
              nothing. The current mode can be passed to the function by
              specifiy in the codeblock.

cpref         Character. This is the string that is prefixed to the database field
              names when creating the GET variables.


                                        Page 8


Example

The following example creates a new order. It automatically creates the
temporary GET variables prefixed with the letter "N".

use order

moddata("A",{||neworder()},{|cMode|addorder(cMode)},"n")


function addorder(cMode)

 @1,1 say "Order#    " get nordernum
// Allows access to date only when adding 
 @2,1 say "Order date: " get nOdate when cMode="A" 
 @3,1 say "Customer# " get ncustno valid chknum()
 @3,1 say "Total     " get ntotal

/*If Escape key pressed, return .F. This signals moddata not to update
database*/

if lastkey()=27
  return(.F.)
endif

read

return(.T.)

/* This is called for a new order record. Assigns order date as todays date*/

function neworder
  nOdate:=date()
return NIL



                                        Page 9


1.4    RECCOPY


Description

Reccopy() copies a record from a source database to a target database for
all fields that exist in both the target database and source database. 

Syntax

RecCopy(cTo,cFrom)

Arguments

cTo           Target database. Database has to be open. The record that is
              currently pointed to with the target database is the record that
              will be updated.

cFrom         Source database. The record that is currently point to is the
              record that will be copied.


Example

The following example copies the last record in the orders database to the
orders2 database.


select orders
goto bottom

select orders2
append blank
Reccopy("orders2","orders")

