Computer Hope

Microsoft => Microsoft DOS => Topic started by: T-Wave on August 27, 2008, 10:47:00 AM

Title: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 10:47:00 AM
Good day  :),

I would like to write a batch file to automate a tedious and repetitive task. Unfortunately, I have little to no experience with writing batch files, so I hope I can get the appropriate guidance from here.

The Situation: I have two .dbf files of a game, namely player.dbf and appearance.dbf. The changes I want to make is to the heights of the players which can be found under a field called HEIGHT in the appearance.dbf file.

In the appearance.dbf file, each player has a unique appearance ID which is identical to the unique player ID found in the player.dbf file.

To identify which players' heights I want to change, I need to use the player.dbf file to get their player IDs then map this player ID to the appearance ID in the appearance.dbf file and finally make the changes.

The Problem: How do I make a batch file to open one .dbf file(in this case, player.dbf), read its content(player ID), use that content to identify the field to be updated in a second .dbf file(appearance.dbf)? Or is there a more efficient way to carry this task out?

I hope I've been able to express my problem clearly. Any help will be very appreciated. Thanks.
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 11:01:32 AM
you should probably have put this in the DOS forum but n/m

What do the .dbf files look like - are they human readable? what form does the information take? can you post a picture of a .dbf file opened with a text editor?
FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 11:26:06 AM
Sorry about posting this in the wrong forum. I'm not familiar with how things are organised around here.

The .dbf files are human readable as can be seen in the first screenshot. The second picture is of the .dbf file opened in a text editor. Not sure what you meant by "what form does the information take?"

(http://i247.photobucket.com/albums/gg123/D-prez/dbffile.jpg)

(http://i247.photobucket.com/albums/gg123/D-prez/Dbfintexteditor.jpg)

Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 11:38:26 AM
From what the text editor looks like i can't help you, there are a few other guys who know DOS better than i do that might.

Only other option i can think of is to root around the menus/help documents for a macro maker/editor.


Something like this: "Execute scripts, using the SQL editor." which i found on there website, though i'm definitely not up to telling you how to script in SQL.

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 11:43:12 AM
Ok, thanks nevertheless :)

Curious: Is there a way to link this topic to the DOS forum? Sounds like I might be able to get more responses to this topic from there.
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 11:48:50 AM
I'll PM one of the moderators and get them to move it.

If you do want to ask about SQL the computer programming section is the place to do it.

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 01:25:46 PM
Using CDBFlite, I got the batch file to extract the player IDs I need from the player.dbf file and save this information in a .txt file. I'm thinking it should be easier now to write another batch file that gets the player IDs from the .txt file and uses it as if it were the appearance ID in appearance.dbf (since they are identical) in order to identify the heights in to be edited.

Perhaps someone knows a solution to this: How do I use the content of a .txt file as input to a batch program? By the way, my .txt file after extracting the player IDs from player.dbf looks like this:

4017
4022
4023
4028
...

Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 01:33:35 PM
you can use the playerID in a batch file but you need the heights to be in a text file also for DOS to be able to use them.

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 01:41:58 PM
Sounds good.

Actually, all I want to do is to set different groups of players to a fixed height if they are below a particular height. So my batch program checks to see if the player with a particular appearance ID is smaller than the base height(in my case 6'6). If so, it sets his height to 6'6. My batch file can do this already, all it needs is to get the player IDs from the .txt file it created. How do I do this?
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 01:50:28 PM
Code: [Select]
for /f "tokens=* delims=" %%A in ('type sample.txt') do (
rem inset code here
)

the player id will be in %%A
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 02:25:18 PM
First of all, thanks a lot, Fireballs, for your effort.

I'm not sure were exactly to put the code you gave me, so I'll just explain what I have already.

"cdbflite.exe" players.dbf /case /filter:TEAM=39 /filter:POSITION=3;POSITION=2 /out:Wing.txt /select:PLAYERID /update

I have the above code this way in my first batch file because the computer generated players are generally undersized. When they are generated, they are all in TEAM #39. Players playing the position 3 and 2 tend to be about the same size, so my batch file filters them out together and stores their respective player IDs in Wing.txt

After running that batch file, the Wing.txt looks somewhat like this:

 4017
 4022
 4023
 4028
 ...

In a second batch file,  I have the following code:

"cdbflite.exe" appearance.dbf /case /filter:APPEARID= /filter:HEIGHT{78 /field:HEIGHT=78 /update

This second one is as of now incomplete, pending a way to get the player IDs stored in Wing.txt and equating them to APPEARID in the code above. 

Do I insert your code in this second batch file? If so, where?

If I understood the instructions in your code, it should look like this:

for /f "tokens=* delims=" %%A in ('Wing.txt') do ("cdbflite.exe" appearance.dbf /case /filter:APPEARID= /filter:HEIGHT{78 /field:HEIGHT=78 /update )

I however do not see where APPEARID is being equated to the line being extracted from Wing.txt. Is there something I'm missing? Pardon my ignorance :)
Title: Re: Writing batch file for .dbf
Post by: qinghao on August 27, 2008, 02:36:48 PM
you shoud give us the whole structure of the DB and post up the sample file!

one more thing,I think this can't be done with DOS command.
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 02:58:08 PM
Qinghao, I don't know what you mean by the whole structure of the DB, but in the picture below, which I posted earlier, on the left panel, the players.dbf file is open and on the right panel, the appearance.dbf is open. If you look keenly, you'll see the PLAYERID which is the fourth column in the players.dbf(left panel) and the APPEARID which is the 2nd column in the appearance.dbf(right panel). Also, what sample file are you talking about? If you mean my batch files, then I've included their codes below.

(http://i247.photobucket.com/albums/gg123/D-prez/dbffile.jpg)

First batch file:
Code: [Select]
@ECHO OFF
:start
CLS
ECHO.
ECHO
ECHO                    GENERATED ROOKIE HEIGHT FIX
ECHO.
ECHO If you do not want to install the patch, close the window now.
ECHO.
ECHO PRESS ANY KEY TO CONTINUE
pause >nul
ECHO.
ECHO FIXING GENERATED ROOKIE HEIGHTS
ECHO.
ECHO.

ECHO Shooting Guards and Small Forwards
"cdbflite.exe" players.dbf /case /filter:TEAM=39 /filter:POSITION=3;POSITION=2 /out:Wing.txt /select:PLAYERID /update

ECHO.
:end
ECHO Players.dbf updated
ECHO PATCH INSTALLED
ECHO.
ECHO.
ECHO Press any key to close this window
pause >nul
EXIT

2nd batch file
Code: [Select]
ECHO.
ECHO PRESS ANY KEY TO CONTINUE
pause >nul
ECHO.
ECHO FIXING GENERATED ROOKIE HEIGHTS
ECHO.
ECHO.

ECHO Shooting Guards and Small Forwards
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= /filter:HEIGHT{78 /field:HEIGHT=78 /update

ECHO.
:end
ECHO Players.dbf updated
ECHO PATCH INSTALLED
ECHO.
ECHO.
ECHO Press any key to close this window
pause >nul
EXIT

Title: Re: Writing batch file for .dbf
Post by: qinghao on August 27, 2008, 03:02:33 PM
wow !
let me see.....for a while
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 04:06:22 PM
@echo off
 for /f "tokens=* delims=" %%A in ('type sample.txt') do (
rem inset code here
set APPEARID=%%A

ECHO.
ECHO PRESS ANY KEY TO CONTINUE
pause >nul
ECHO.
ECHO FIXING GENERATED ROOKIE HEIGHTS
ECHO.
ECHO.

ECHO Shooting Guards and Small Forwards
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= /filter:HEIGHT{78 /field:HEIGHT=78 /update

ECHO.
:end
ECHO Players.dbf updated
ECHO PATCH INSTALLED
ECHO.
ECHO.
ECHO Press any key to close this window
pause >nul
EXIT
)
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 04:07:41 PM
For every entry in sample.txt this will take the line of text and put it into variable A. this is then set as APPEARID and used in your code. I hope it works but it's far too complex for me to test on my system.

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 04:16:01 PM
OH MY GOD, it actually works. Thanks a million, Fireballs. WOW!!!     :o
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 04:17:22 PM
:) not a problem come back if you need anything else...

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 04:18:36 PM
I'll make sure to do, thanks  :)
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 05:15:38 PM
I'm back sooner than I expected.

I think I rejoiced too quickly. What that batch file does now is simply set the mininmum height of every player in the entire database to 78.

I guess when it gets to the line below, it simply filters only players with height less than 78.

"cdbflite.exe" appearance.dbf /case /filter:APPEARID= /filter:HEIGHT{78 /field:HEIGHT=78 /update

At first I thought it was because of the segment /filter:APPEARID= not being equated to anything.

I tried changing it to /filter:APPEARID=%%A but I got the error "Invalid filter..." and "Unknown function [4017]".  By the way, 4017 is the first player ID number stored in Wing.txt (See screenshot below)

I then tried changing it to /filter:APPEARID=A and though I didn't get any error message this time, it made none of the desired changes to the player heights.

I guess it's back to square one, how to equate each of the numbers in wing.txt to the APPEARID.

(http://i247.photobucket.com/albums/gg123/D-prez/Wing.jpg)
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 05:28:08 PM
hmm  i may have missed out some % signs along the way how about if you say:

@echo off
 for /f "tokens=* delims=" %%A in ('type sample.txt') do (
set APPEARID=%%A

ECHO.
ECHO PRESS ANY KEY TO CONTINUE
pause >nul
ECHO.
ECHO FIXING GENERATED ROOKIE HEIGHTS
ECHO.
ECHO.

ECHO Shooting Guards and Small Forwards
"cdbflite.exe" appearance.dbf /case /filter:%APPEARID%= /filter:HEIGHT{78 /field:HEIGHT=78 /update

ECHO.
:end
ECHO Players.dbf updated
ECHO PATCH INSTALLED
ECHO.
ECHO.
ECHO Press any key to close this window
pause >nul
EXIT
)

I can't test the arguments to cdbflite.exe but my code should now word? Get back to us.

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 27, 2008, 05:53:23 PM
It's still setting the minimum height of every player to 78.

I'm including a section of the instructions that came with cdbflite. Perhaps it may help?

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+   = 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.
   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 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-



5. Note
~~~~~~~~~~~~
(1)   field types:    
      Character, Numeric, Float, Date, Logical, Memo
      General, Currency, Double, Integer, Binary.

(2)   memo-field types:      
      dBase III, dBase IV, FoxPro, Visual FoxPro.

(3)   CDBFlite one.dbf two.dbf /parameter /parameter ...
   CDBFlite a*.dbf b???.dbf /parameter /parameter ...

Title: Re: Writing batch file for .dbf
Post by: fireballs on August 27, 2008, 07:09:06 PM
for /f "tokens=* delims=" %%A in ('type wing.txt') do (
set APPEARID=%%A
"cdbflite.exe" appearance.dbf /case /filter:APPEARID=%APPEARID%&HEIGHT{78 /field:HEIGHT=78 /update
)

If that doesn't work then DOS is not expanding the variable when it's passed to the executable....

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 06:40:50 AM
Hi Fireballs,

when I tried it with your last code, I get "Invalid filter" as the error message. I'm guessing there is something wrong with the /filter:APPEARID=%APPEARID% segment of the code.

Also, do you think this can perhaps be done using an IF statement instead of a SET
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 28, 2008, 06:51:42 AM
Code: [Select]
for /f "tokens=* delims=" %%A in ('type wing.txt') do (
echo %%A>auth
"cdbflite.exe" appearance.dbf /case /filter:APPEARID=<auth /filter:HEIGHT{78 /field:HEIGHT=78 /update
)
That's my last stab at getting this to work in DOS, There must be a way of doing the whole process just using cdbflite.exe.

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 07:05:26 AM
Still get the same "Invalid filter" error for every line. Thanks, nevertheless, for all your effort, Fireballs.
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 28, 2008, 07:13:40 AM
This is still puzzling. You can definitely pass arguments to executables in the form "%%A", at least I can.

Have you tried using only one filter at a time to confirm that it definitely is the /filter:APPEARID= one that's not working? Have you tried using a proper value. e.g.  /filter:APPEARID=4107?

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 07:22:47 AM
I hadn't before, though I had tried several changes to that segment before and had different results that hinted that was the case.

Now that you mentioned it though, I just tried the code with a proper value (/filter:APPEARID=4035 /filter:Height{78) and it worked with only that particular line.  By the way, somehow, I have to use multiple /filter instructions to represent an AND. THe statement /filter:APPEARID=4035&Height{78 returns an error.
Title: Re: Writing batch file for .dbf
Post by: qinghao on August 28, 2008, 07:26:25 AM
Oh ,I should learn  more about the batch command.
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 28, 2008, 07:34:22 AM
Hmmm it appears as though DOS isn't expanding the variable before it's passed to the executable. Sorry that's all my advice exhausted. Hope you find a solution somehow!

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 08:47:41 AM
I had another idea which seems to bring me closer to a solution. Check this code out:

Code: [Select]
@echo off
for /f "tokens=* delims=" %%A in ('type Wing.txt') do (
echo "cdbflite.exe" appearance.dbf /case /filter:APPEARID=%%A /filter:HEIGHT{78 /field:HEIGHT=78 /update>auth.bat
)

What this does, thus far, is to write the instruction into another auth.bat, which I can later run. The only problem thus far, is that after it is run, the auth.bat file contains only one line of instruction at the end, probably due to the FOR loop overwriting what was already in the auth.bat file every time it is iterated. At the end, I have only the following line in the auth.bat file, which confirms my suspicion because 4103 is the last number in the Wing.txt file:

"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4103 /filter:HEIGHT{78 /field:HEIGHT=78 /update

How do we get it not to overwrite the auth.bat file each time the instruction is reiterated, but rather to add a different line so that at the end, the auth.bat file could look something like this instead:


"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4017 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4019 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4023 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4025 /filter:HEIGHT{78 /field:HEIGHT=78 /update

...

"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4103 /filter:HEIGHT{78 /field:HEIGHT=78 /update

Title: Re: Writing batch file for .dbf
Post by: fireballs on August 28, 2008, 09:10:09 AM
Code: [Select]
@echo off
for /f "tokens=* delims=" %%A in ('type Wing.txt') do (
echo "cdbflite.exe" appearance.dbf /case /filter:APPEARID=%%A /filter:HEIGHT{78 /field:HEIGHT=78 /update>>auth.bat
)

try that.


FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 09:18:50 AM
Great, that works, thanks. Now, hopefully, one last problem  ;D

As seen from my results below, there is always a space between APPEARID= and the number, e.g APPEARID= 4017. This is causing the filter to be invalid. When the space is taken away so that it looks like "APPEARID=4017", the auth.bat file works. Is there any way for the results written into the auth.bat file to be written without that space? Oh man, so close to the final solution, I can taste it ;D

"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4017 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4019 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4020 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4024 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4026 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4029 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4032 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4035 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4040 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4042 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4045 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4047 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4049 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4051 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4052 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4053 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4054 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4055 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4056 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4058 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4059 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4060 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4061 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4062 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4063 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4065 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4066 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4071 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4077 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4078 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4079 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4081 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4082 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4085 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4086 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4088 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4090 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4092 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4093 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4095 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4097 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4098 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4101 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4102 /filter:HEIGHT{78 /field:HEIGHT=78 /update
"cdbflite.exe" appearance.dbf /case /filter:APPEARID= 4103 /filter:HEIGHT{78 /field:HEIGHT=78 /update


Title: Re: Writing batch file for .dbf
Post by: fireballs on August 28, 2008, 09:24:42 AM
we need to figure out where the space is coming from, all i can do with my system is say that the space doesn't come from expanding the variable. So is it in the original wing.txt? There's definitely no space between appearid= and %%A?

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 09:33:18 AM
In my instruction, there is definitely no space between appearid= and %%A. However, in the Wing.txt file, there is always a space before the number on every line.

The code that creates the Wing.txt file is as follows:

Code: [Select]
"cdbflite.exe" players.dbf /case /filter:TEAM=39 /filter:POSITION=3;POSITION=2 /out:Wing.txt /select:PLAYERID /update
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 28, 2008, 10:05:55 AM
Code: [Select]
@echo off
for /f "tokens=* delims= " %%A in ('type Wing.txt') do (
echo "cdbflite.exe" appearance.dbf /case /filter:APPEARID=%%A /filter:HEIGHT{78 /field:HEIGHT=78 /update>>auth.bat
)

this should work.

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 10:15:36 AM
Marvelous, the whole thing works now!!!  :o You've been awesome, Fireballs.
Title: Re: Writing batch file for .dbf
Post by: fireballs on August 28, 2008, 10:26:19 AM
W00t! ^-^ it works! ;D You did most of the work... you wrote the CDBflite.exe codes and the Batch code to create Auth!

FB
Title: Re: Writing batch file for .dbf
Post by: T-Wave on August 28, 2008, 10:32:10 AM
No way I'm taking that credit, but I guess we could go on and on ;D... I'm just ecstatic that it's actually working. It's a problem that has been bugging me for years playing NBA Live, and no matter how often a fix has been requested from EA sports, they kept making lots of undersized generated players. Yesterday, I got so fed up with it, I decided to take things into my own hands... and with all your effort, we(;D) came through.