INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

DBCMD error 2001 and DBFNTX error 1020

DBCMD error 2001 and DBFNTX error 1020

(OP)
I am a novice Clipper programmer running a few programs for personal/office use.  Several months ago I started experiencing crashes in one program.
  
Most commonly it is "DBCMD error 2001: Work area not in use" from ordlistcle(0).  This will be at a "Set Index to <ntx> " line which follows a " Use <dbf> new ".  I restart the program and it runs just fine, handling that line of code the next time without difficulty.  It has happened randomly at multiple different "set index to " commands in different prg files over the last several months.  In some instances I have written the code as one line:  "Use <dbf> index <ntx> new"  If it crashes on that line I see "DBCMD error 2001: Work area not in use" from ordlistadd() instead of ordlistcle().  (I am not really familiar with these "behind the scenes" Clipper functions of ordlistcle and ordlistadd but I can guess they are handling the index files.)

Less commonly the error is "DBFNTX 1020 Work area not indexed" from dbseek(0).   This error is at a "Seek...." command following "Use <dbf> new...set index to <ntx>".  Again when I restart the program it handles that same line of code without difficulty.  

I am using Clipper 5.2 with the 5.2d patch.  

So what is going wrong?
 

RE: DBCMD error 2001 and DBFNTX error 1020

What is happening is the file open in the use clause is failing. Consequently when trying to open the index you get the work area not in use error.

The other error is similar - in that case the open of the index file has failed, so subsequently when you try to do an index operation you get the work area not indexed response.

To know exactly why this is happening, more information is required:
- are there more than one task or users opening these files?
- are they being opened in shared mode or exclusive?
- what operating system is being used.

The way around this problem is to check for errors after using a file. For example, I use a standard function to open files either in exclusive or shared mode that looks like this:
In the calling program:

CODE

set exclusive off
if !net_use('database',.f.,5)
   ? 'Unable to get shared access to database'
   return
endif
...
Here is the net_use function:

CODE

function net_use
parameters file, ex_use, wait
private forever

forever = (wait = 0)
do while (forever .or. wait > 0)

   if ex_use                    && exclusive
      use &file exclusive
   else
      use &file                 && shared
   endif

   if .not. neterr()           && USE succeeds
      return (.t.)
   endif

   inkey(1)                     && wait 1 second
   wait = wait - 1
enddo
return (.f.)                    && USE fails

As you can see this routine will keep trying the use until either a timeout expires or it succeeds. The key thing is to check the error status after the use statement.

Why does this happen?

- other tasks may have the file open; even such tnings as virus scanners and indexing services
- due to OS disk caching or opportunistic locking (under Windows) it may take a few seconds for all outstanding activity on a recently closed file to complete, and a subsequent open may be premature.

So what you have to do is write your program as if the file is networked, even though it isn't.

Jock

 

RE: DBCMD error 2001 and DBFNTX error 1020

(OP)

Jock:

To answer your questions:
No other program opens these files and I am the only user.
I do not specify Shared or Exclusive.  I believe Clipper opens in exclusive mode by default if no specification is made, doesn't it?
The operating system is XP SP3

Your explanation makes sense however, even without your knowledge of those answers.  It also makes sense to me that this problem came up when I started running this program on a new laptop a year ago.  As you point out there must be something about the way Windows is set up on that laptop that retards file handling so the dbf file doesn't open occasionally.  Your advice is good: in the Windows environment I need to write the program as if the file is networked, even though it isn't.  I understand your workaround using the net_use function.  I have done a little programming using neterr() and a time of delay waiting for a successful open.

But what about the failure of the index file to open?  Do you have a way to trap and handle that error?

Thanks for your help,
Jim
 

RE: DBCMD error 2001 and DBFNTX error 1020

Hi Jim

Recent Windows versions work differently than previously with legacy file and record locking applications like Clipper. The symptom you describe about the .dbf file is exactly what happens if you attempt to use a dbf file which is currently open in another window.

It is even slower on a laptop due to disk delay, especially if the drive has to spin up first or if there is a lot of disk activity. Although you are only one user you may have more than one task opening the files, as I mentioned. Your disk should be set to "always on" in power management.

I'm guessing this might also explain the DBFNTX1020, though I have not seen this happen.

Jock

RE: DBCMD error 2001 and DBFNTX error 1020

This sounds very like an antivirus problem - with the file being scanned by the AV as you open it - thereby preventing your app from getting exclusive access.

I would use a net_use function (like the one above suggested by Jock) and separate the opening of the table from the opening of the index files, that way you can firstly ensure the table is open in the selecetd work area and then try to open the indexes - each of these may be delayed by the AV as well!

 

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

RE: DBCMD error 2001 and DBFNTX error 1020

Hi

I guess, you are trying to open too many files at one time, try modifying your autoexec.nt and config.nt, you can find these files in windows\system32 folder.

in autoexec.nt add one line in the end, SET CLIPPER=F80

in config.nt increase files=60 and one line buffers=60

reboot your laptop.

Regards
Naresh

RE: DBCMD error 2001 and DBFNTX error 1020

If it was too many files he would get a DOS Error 4 (I think it was 4!)

 

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

RE: DBCMD error 2001 and DBFNTX error 1020

For old times sake:

CODE

       1        Invalid function number  19        Attempt to write on
                                                 write-protected diskette
       2        File not found            20        Unknown unit
       3        Path not found            21        Drive not ready
       4        Too many open files       22        Unknown command
               (no handles left)
       5        Access denied             23        Data error (CRC)
       6        Invalid handle            24        Bad request structure length
       7        Memory control blocks     25        Seek error
               destroyed
       8        Insufficient memory       26        Unknown media type
       9        Invalid memory block      27        Sector not found
               address
      10        Invalid environment       28        Printer out of paper
      11        Invalid format            29        Write fault
      12        Invalid access code       30        Read fault
      13        Invalid data              31        General failure
      14        Reserved                  32        Sharing violation
      15        Invalid drive was         33        Lock violation
               specified
      16        Attempt to remove the     34        Invalid disk change
               current directory
      17        Not same device           35        FCB unavailable
      18        No more files             36        Sharing buffer overflow
      37-49     Reserved                  66        Network device type incorrect
      50        Network request not       67        Network name not found
               supported
      51        Remote computer not       68        Network name limit exceeded
               listening
      52        Duplicate name on         69        Network BIOS session limit
               network                            exceeded
      53        Network name not found    70        Temporarily paused
      54        Network busy              71        Network request not accepted
      55        Network device no longer 72        Print or disk redirection
               exists                             paused
      56        Network BIOS command      73-79     Reserved
               limit exceeded
      57        Network adapter hardware 80        File already exists
               error
      58        Incorrect response from  81        Reserved
               network
      59        Unexpected network error 82        Cannot make directory entry
      60        Incompatible remote       83        Fail on INT 24H
               adapter
      61        Print queue full          84        Too many redirections
      62        Not enough space for      85        Duplicate redirection
               print file
      63        Print file deleted        86        Invalid password
               (not enough space)
      64        Network name deleted      87        Invalid parameter
      65        Access denied             88        Network device fault

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel.  Covey

RE: DBCMD error 2001 and DBFNTX error 1020

Thank you!

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

RE: DBCMD error 2001 and DBFNTX error 1020

(OP)
You are right, I'm not getting a DOS error "unable to open file".  I remember being very frustrated some years ago when I didn't have SET CLIPPER=F high enough and couldn't open a file though I could see that the file was right there!
I have rewritten the program using a modification of the net_use function.  Thanks for the suggestion and the code.  Finally got all my USE commands rewritten last night.  Now I wait and see if that traps all of the delayed openings.  I'm still a little nervous about the NTX files being delayed in opening and causing a crash, but I get the sense from you all that it won't be an issue.  Time will tell.  I'll be back looking for suggestions it that comes up.
Thank you all for the help.
Jim

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close