You are on page 1of 10

CDBF Command Line Utility. Version 1.21 shareware ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. 2. 3. 4. 5. 6. 7. Purpose and features.

Versions How to use Parameters Note Source code Copyright

1. Purpose and features ~~~~~~~~~~~~~~~~~~~~~~~ The CDBFlite program allows to work with .DBF files format from command line. You can carry out various actions, which don't requires presence of the man in a batch mode. Generally speaking, the program is high-grade command line DBF viewer and editor. If you are familiar with SQL language, you can notice some similar moments. As parameters are transferred into command line the syntax differs, but principles of work same. UPDATE somefile.dbf SET name="John", age=30 where id=1000 CDBFlite somefile.dbf /filter:id=1000 /field:name="John",age=30 /update CDBFlite supports all existing fields types (1) and all memo-fields types. (2) CDBFlite program can be applied on WEB-server. By the way, PERL or PHP have not those opportunities for work with .DBF, which are given by CDBFlite.

2. Versions ~~~~~~~~~~~ CDBFlite program is written in C language without any extensions, therefore possible to use for compiling practically by anyone 32-bit compiler C. This was checked up on MSVC, WatcomC, LCC, GCC. Now available follow versions: - Win32 - DOS (Protected Mode) - OS/2 - Linux - FreeBSD

3. How to use ~~~~~~~~~~~~~ CDBFlite <filename.dbf|pattern> <parameter|@filename.lst|+filename.dbf> filename.dbf - the name of .dbf-file, is necessary. With this file will make defined actions. Instead of a file name is allowed a pattern. So operations will be made with each file, which satisfy given pattern. Possible to indicate several names or patterns before parameters. (3)

CDBFlite requires one or more parameters also. You can place parameters into file and call CDBFlite as: CDBFlite filename.dbf @yourfile Commands in the file must be written as one command at the one line. All blank lines, and lines beginning with ';' are ignored. The file can contain the references to other files. You can create the cdbflite.ini file and write to it any commands. They will be executed each time up to all commands. You can set commands such as ansi/oem, case, del... If parameter has a kind "+filename.dbf", CDBFlite carries out operation APPEND FROM.

4. Parameters ~~~~~~~~~~~~~ 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', <filename.dbf> <parameters> | full name of ini-file or empty if not used: '' Parameters list: /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+ /name= to show name of the database = 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. Designations, 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 recor d. == - 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.

5. Note ~~~~~~~~~~~~ (1) field types: Character, Numeric, Float, Date, Logical, Memo General, Currency, Double, Integer, Binary. (2) (3) memo-field types: dBase III, dBase IV, FoxPro, Visual FoxPro. CDBFlite one.dbf two.dbf /parameter /parameter ... CDBFlite a*.dbf b???.dbf /parameter /parameter ...

6.Source code ~~~~~~~~~~~~~ CDBFlite library is powerful set of routines offers developers direct access to database tables. Does not require any drivers, which allows for much easier configuration and a great deal of confidence that your program will run properly across all platforms. Supports dBase III, dBase IV, FoxPro, Visual FoxPro fields and memo-fields. CDBFlite program is written in C language without any extensions, therefore possible to use for compiling practically by anyone 32-bit compiler C. This was checked up on GCC, MSVC, WatcomC, LCC, C++Builder. Besides, you can compile as dll and use it from Delphi, MSVC, GCC, LCC, Watcom C or any other environment of programming. You can purchase source code of CDBFlite. For more information see license.txt. 7.Copyright ~~~~~~~~~~~ The program CDBFlite is distributed as Shareware. All copyrights to CDBFlite are exclusively owned by the author - Sergey Chehuta. For more information see license.txt WWW: http://www.whitetown.com Email: support@whitetown.com

You might also like