Command line interface of CDBFlite

First character of parameter can be '/' or '-'.
Inside of the parameter the comma or semicolon is used as a separator.

The remark to OS Unix, Linux:
In OS Unix character ';' designates the end of the command, therefore in the following cases:
/select:name,street,house,flat - is correct
/select:name;street;house;flat - is not correct!
"/select:name;street;house;flat" - is correct
If CDBFlite read commands from the file, both characters are valid.

The remark to OS/2 DLL:
Sample script -
/* */
RxFuncAdd("CDBFlite","cdbflite","CDBFlite")
call CDBFlite 'c:\path\cdbflite.ini',
| full name of ini-file or empty if not used: ''

  • /version
    The service parameter, returns a version number and date of compilation CDBFlite.

  • /delete:N1,N2-N3,all
    To mark on deleting. You can specify after colon of records number. They can be listed through a comma, to specify a range through a hyphen, or to indicate the parameter "All". In last case all records will be marked on deleting. It's possible to use any amount of records number.

    /delete:10,20 - delete records #10 and #20
    /delete:10-20 - delete records from #10 to #20
    /delete:all - delete all records
    /delete:10,20,30-35,40

  • /recall:N1,N2-N3,all
    To remove a mark on deleting. You can specify after colon of records number. They can be listed through a comma, to specify a range through a hyphen, or to indicate the parameter "All". In last case from all records will be removed mark of deleting. It's possible to use any amount of records number.

    /recall:10,20 - remove mark of deleting from records #10 and #20
    /recall:10-20 - remove mark of deleting from records from #10 to #20
    /recall:all - remove mark of deleting from all records
    /recall:10,20,30-35,40

  • /pack[:dbf|memo]
    To pack the database. Physically to delete records, marked on deleting. If to indicate suffix :dbf or :memo , will be packed only .dbf the file or only file of the notes. If suffix is not specify, will be packed all. This parameter may be combined with others, for example:

    /delete:15-100 /pack
    /pack:dbf

  • /zap
    To delete physically all records in the database.

    /zap

  • /blank
    To clear the write buffer. Is usually applied before addition of records. At the start of the program the write buffer is cleared automatically.

    /blank

  • /append:N|blank
    Append record with current information in the buffer. If to indicate unessential number - will be added specified number of records. If to indicate a word "blank", will be added one empty record.

    /append
    /append:blank
    /append:100

  • /trunc:N
    Truncate database on specified number of record.

    /trunc:100

  • /make:filename.dbf
    To create the empty database with the same structure.

    /make:new.dbf

  • /sort:field1;field2;...
    To sort database on the indicated fields. The old copy was saved in the file with the .bak extension. In process of sorting CDBFlite will create file with the .tmp extension. For successful fulfilment of sorting should be necessary vacant place on the disk.

    /sort:name
    /sort:phone
    /sort:street;house;flat
    Before command /sort command /clear called automatically (see below).

  • /cdx
    Clears (set to zero) byte with offset 1c in header, which designates availability .CDX or .MDX of the file.

    /cdx

  • /cpzero[:N]
    Set to specified value byte with offset 1d in header, which designates a used code page. Default to zero.

    /cpzero
    /cpzero:3

  • /check
    Checks a correctness of header and if necessary corrects it.

    *.dbf /check

  • /struct:file.txt|file.sql|file.dbf|file.prg
    To show structure of database. If filename does not specified, the information about structure will be issued on stdout.
    /struct
    If filename with the .txt extension specified, information about structure will be added to the indicated file in the same kind, as previous parameter.
    /struct:somefile.txt
    If filename with the .sql extension specified, information about structure will be added to the indicated file as command "CREATE TABLE" of SQL language.
    /struct:somefile.sql
    If filename with the .dbf extension specified, information about structure will be overwritten to the indicated file in a format accepted in FoxPro or Clipper.
    /struct:somefile.dbf
    If filename with the .prg extension specified, information about structure will be added to the indicated file as command "CREATEDB" of Clipper language.
    /struct:somefile.prg
    If filename with the .fox extension specified, information about structure will be added to the indicated file as command "CREATE TABLE" of FoxPro language.
    /struct:somefile.fox

  • /select:field1;field2;...|*
    /s:field1;field2;...|*

    Print to stdout the specified fields of the database.

    /select:name
    /select:name;phone
    /select:name;street;house;flat
    /select:*

  • /order:field1;field2;...
    /o:field1;field2;...

    Set order of records. This command in itself has not of sense. To use follows in a combination with other commands:

    /order:name /select:name;phone;street;house;flat If you want to set the filter, set it before command /order command. /filter command cancels /order command.

  • /clear
    This command to clear earlier installed /order, /sort, /select, /filter. With help this command you can to make several requests.

    /order:name /select:name;phone /clear /order:phone /select:phone;name

  • /asc
    Set the order of ascending sort. By default.

    /asc

  • /desc
    Set the order of descending sort.

    /desc

  • /filter:condition
    /f:condition

    Installation of the filter. The filter allows to select of some records which satisfying to some condition. Allowable to use several conditions in one filter and/or some filters. In the latter case they was united as condition 'AND'. For example:

    /filter:name=Smith - to select people with name "Smith"
    /filter:name=Smith&age>30 - to select people with name "Smith" and age more them 30 year
    /filter:name=Smith&age{30 - to select people with name "Smith" and age less them 30 year
    /filter:name=Smith;name=Gates - to select people with name "Smith" or "Gates"
    /filter:name=Smith|name=Gates - to select people with name "Smith" or "Gates"
    /filter:name~uck - to select people, containing a substring "uck". Thus will be selected "Luck", "Duck" etc. I.e. not only beginning of field.
    Here is required to explain, that in the command line you can not use characters '|', '>', '<' - these characters used Operation System for pipe of input-output. On this reason you should replace in the command line this characters as follows:

    '|' --> ';'
    '>' --> '}'
    '<' --> '{'
    If the commands are transmitted to the program from the file, there it is possible to use any characters. The following logical operations are allowed:

    = - equal
    <> or >< - not equal
    > or >> - more
    >= - more or equal
    < or << - less
    <= - less or equal
    ~ - entry of a substring (for string fields)
    If you set several filters, they will incorporated:

    /filter:name=A /filter:age=30 it's same as

    /filter:name=A&age=30 It is necessary to notice, that in the second case to work will be faster, as the matching goes for 1 pass, in the first case 2. If the compared expression contains blanks, you should to conclude expression in quotes.

    /filter:name="John Smith" /filter command cancels /order command.
    In the filter expression available following functions
    ABS, ACOS, ASIN, ATAN, COSH, COS, EXP, LOG10, LOG, POW10, ROUND, SINH, SIN, SQRT, SQR, TANH, TAN, TRUNC
    for numeric fields.

    /filter:summa-round(summa)>0.5 In the filter expression available following functions
    TRIM, LTRIM, RTRIM, SUBSTR, LEFT, RIGHT
    for Character and Date fields.

    /filter:substr(date,3,2)=05 /select:* For comparison date-field you should use finction DTOS:

    /filter:date=dtos(02.05.2001) /select:*

  • /ansi
    In the file the coding ANSI (Windows).

  • /OEM
    In the file the coding OEM (DOS). By default.

  • /case[+|-]
    /case or /case+ = Ignore case of characters.
    /case- = Do not ignore case of characters. By default.
    Is applied together with /sort, /order or /filter.

    /case /sort:name

  • /del[+|-]
    /del or /del+ = show tag of deleting in the command /select
    /del- = do not show tag of deleting in the command /select. By default.

    /del /select:*

  • /date:dmy|mdy|ymd|asis|char
    Format of date field.
    dmy - Day-Month-Year
    mdy - Month-Day-Year
    ymd - Year-Month-Day
    asis - As stored in the database.
    You can change format somehow frequently:

    /date:ymd /filter:born=1971 /date:mdy /select:* You can set date separator:

    /date:- // 01-28-2001 /date:/ // 01/28/2001

  • /range:N1,N2-N3|all
    To select records with concrete records numbers. If database was ordered or filtered, the records will select just from among satisfying to the filter and in the order. The /range parameter has the lowest priority and should be used by the latter in a combination with /filter or /order. The suffix "all" switch off range.

    /range:1-10
    /range:11-20
    /range:1-100,200-500,150
    /range:all

  • /memo[:text]
    To show state of memo-field /memo or contents /memo:text

  • /field:field1=value;field2=value;...
    /l:field1=value;field2=value;...

    To set values of fields in the buffer of data. After that you can write down them into database by the /append or /update command.

    /field:name="John Smith";age=30;phone=3-14159265358

  • /update
    To write down current data from write buffer into the database. The data will write to all records, which satisfy current /filter or /range. all records will be updated if /filter or /range is not installed.

    /field:first=100 /update /filter:name=John /field:first=100 /update

  • /count
    Print quantity of records in database.

    /count

  • /name[+|-]
    /name or /name+ = to show name of the database
    /name- = do not show name of the database. By default. Use with commands /count and /select.

    *.dbf /name /count
    *.dbf /name /filter:customer="Smith" /select:*

  • /calc:condition
    Calculate specified condition. Available +-/*, and all functions, which described in the /filter manual.

    /calc:2+2*2
    /calc:cos(0)

  • /trim:left|right|all
    Management of trimming of leading and trailing spaces from a Character fields.

    /trim - without suffix, trimming spaces is off.
    /trim:left - Remove leading spaces from a character string.
    /trim:right - Remove trailing spaces from a character string.
    /trim:all - Remove leading and trailing spaces from a character string.

  • /out:file.txt|file.htm|file.dbf|file.sql|file.prg|file.fox|file.csv
    Type of output of the information by /select command. By default CDBFlite print result of work on the stdout(screen).

    /out /select:* If filename with extension .txt specified, command /select will add information to the indicated file in the same kind, as previous parameter.

    /out:file.txt /select:* If filename with extension .csv specified, command /select will add information to the indicated file in the CSV format

    /out:file.csv /select:* If filename with extension .htm specified, command /select will add information to the indicated file as table, using html syntax.

    /out:file.htm /select:* If filename with extension .dbf specified, command /select will add information to the indicated .dbf-file. If file does not exists - it will be created. If the file exists, CDBFlite adds the information only in existing fields (same names, as in the source file).

    /out:file.dbf /select:name;address;phone If filename with the .sql extension specified, command /select will add information to the indicated file as command "INSERT INTO" of SQL language.

    /out:file.sql /select:*
    /struct:dump.sql /out:dump.sql /select:*
    If filename with the .prg or .fox extension specified, command /select will add information to the indicated file as command "REPLACE" of Clipper or FoxPro language.

    /out:file.prg /select:*
    /struct:dump.prg /out:dump.prg /select:*

  • +filename.dbf
    The operation APPEND FROM - addition to current file the records from other file. If the dbf-files have identical fields names and the types is differs - CDBFlite will transform expression to the necessary type.

    cdbflite first.dbf +second.dbf

  • /hdr[+|-]
    Print names of fields in command /select.

    /hdr+ /select:*

  • /browse
    /fields

    Use with command /select.

    /fields /select:*

  • /deleted[+|-]
    To show or to hide records marked as deleted.

    /deleted-

  • /cmp:filename.dbf [/filter] [/order] /cmp[:isc]
    Compares two files and displays the differences between them. You should set the name of second file:
    /cmp:filename.dbf
    Now possible to set the filter and/or the order of records. This settings will work on both files. After that you can execute some command of comparison:

    /cmp or /cmp:i - to print the common information about databases.
    /cmp:s - to compare structures of databases.
    /cmp:c - to compare contents of databases.
    /cmp:isc - to execute all commands.
    Designatirons, used at comparison:

    - - the field is absent.
    <> - field has same name, but all other parameters are different.
    ~= - field has same name and type, but size is different.
    = - all parameters of fields same, except offset inside the record.
    == - Complete conformity of fields.
    cdbflite file1.dbf /cmp:file2.dbf /cmp
    cdbflite file1.dbf /cmp:file2.dbf /cmp:s
    cdbflite file1.dbf /cmp:file2.dbf /f:born}dtos(01.01.1970) /o:name /cmp:ics

  • /sum:field1;field2;...|*
    Print to stdout a sum by specified fields of the database.

    /sum:salary
    /sum:payment;discount
    /sum:*

  • /avg:field1;field2;...|*
    Print to stdout an average value by specified fields of the database.

    /avg:salary
    /avg:payment;discount
    /avg:*

  • /encode:password
    Encode database with the specified password. Cryptographic strength is quite good.

    /encode:super_secret

  • /decode:password
    Decode database with the specified password. You must use the same password as was used in the command /encode. If you will make a mistake, then data will be lost.

    /decode:super_secret

  • /psw[:password]
    Set password for input/output oparations. The parameter /psw without of a password switch off current password

    /psw:12345 /field:a1=John;a2=Smith;a3=100;a4=05.27.2001 /append
    /psw:12345 /select:*

  • /bak[+|-]
    Create .bak file when database is changed.

    /bak+
    /bak-

  • /2oem, /2ansi
    specify the output codepage.

  • /oem2ansi, /ansi2oem
    change code page of a table.

  • /deldupes
    delete duplicates in a table.

  • /ignorequotes
    do not remove quotes from the command line and parse them literally.

  • /modify:struct.txt
    modify structure of the specified dbf file.
    The file of structure can contain the following commands:
    1. By default all fields will be in a modified table.
    2. FIELDNAME TYPE(LEN)
      if FIELDNAME is existing field then program will change TYPE and LENGTH
      if FIELDNAME is not existing field then it will be added to the end on the table
    3. FIELDNAME/BEFORE TYPE(LEN)
      if FIELDNAME is not existing field then it will be added before the field BEFORE
    4. -FIELDNAME
      removes FIELDNAME from the table
    5. FIELDNAME=NEWNAME
      rename FIELDNAME to NEWNAME

      Besides you can specify some commands after the field definition

    6. INC:startvalue
      For example
      ID N(10) INC:1
      Field ID will be filled with 1, 2, 3, ....
    7. EXP:expression
      For example
      FULLNAME C(30) EXP:TRIM(FIRST) TRIM(LAST)
      Field FULLNAME will be filled with content of FIRST and LAST
      XXX N(15.2) EXP:ID*2
      Field XXX will be filled with ID*2

    An entire file can look like this:

    -PRC_MNC
    PRC_PID=PARCELID
    -PRC_ASSNG_
    -PRC_ASS001
    FULLNAME C(80) EXP:TRIM(FIRST) TRIM(LAST)
    PRC_BLOCK/BLOCK
    PRC_LOT=LOT
    ID N(10) INC:1

  • /create:struct.txt
    create a new dbf file using the specified strucrure
    All command works like in the command /modify, except '='