Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!agate!dog.ee.lbl.gov!nosc!humu!pegasus!tleylan From: tleylan@pegasus.com (Tom Leylan) Newsgroups: comp.databases Subject: Re: So does Clipper do it ? Keywords: Clipper Index gauge, .NTX file, dbCreatIndex() Message-ID: <1991May26.095656.25202@pegasus.com> Date: 26 May 91 09:56:56 GMT Article-I.D.: pegasus.1991May26.095656.25202 References: <1991May24.173628.15324@msuinfo.cl.msu.edu> <1991May24.180404.18538@msuinfo.cl.msu.edu> <1991May26.034816.21511@pegasus.com> Organization: Pegasus, Honolulu Lines: 208 In article <1991May26.034816.21511@pegasus.com> tleylan@pegasus.com (Tom Leylan) writes: > >In both S'87 and 5.01 you will be required to "fix" the index header if >you index on a function. A simple look at the index header with your >favorite hex editor will veryify the index expression. I suggest leaving >the index string empty "" and supplying just the index code block if you >want a progress indicator. If you don't do that you can test with a compound >key expression lastname + firstname (for instance) and you will notice that >the index block is called only once at the beginning of the index process >and never again. Your indicator will therefore not indicate. > >I'll probably post my version later today if I can figure out how to >imbed it into a response to this thread. > >tom I sort of messed up my memory there. Compound keys were not the problem keys that were not compound was. BUT... guess what ? If you surround the index string with "("+ "" + ")" then the progress indicator will always operate and the index key imbedded in the .NTX file is okay. It will have parens around it but appears to make no difference in normal operation. In the following piece of code I have substituted the IBM box characters with 7-bit ASCII ones and also the % done block with an "X". You'll want to change these back for maximum effect.> /* ntx.prg Copyright (c) 1990, 1991, The Leylan Factor The Leylan Factor 98-626 Moanalua Loop, #201 Aiea, HI 96701-5172 (808) 487-2230 Compuserve : 74216,3212 Internet : tleylan@pegasus.com compile : clipper ntx /n/w By The Way : to run this demo you need the following file Structure for database: NTX Number of data records: 100 to 1000 for a meaningful test Field Field Name Type Width Dec 1 NAME Character 30 2 STATE Character 2 ** Total ** 33 */ #include "set.ch" #include "fileio.ch" /* to curtail the warnings */ FIELD name, state FUNCTION Main LOCAL nRec, nMax, bIndex LOCAL xCursor := SET( _SET_CURSOR, .F. ) CLS /* index with "records remaining" indicator */ @ 5, 21, 7, 54 BOX "+-+|+-+| " ; @ 6, 23 SAY "Records Remaining :" USE ntx EXCLUSIVE NEW nRec := 1 nMax := (LASTREC() + 1) bIndex := { || DevPos( 6, 43), ; DevOutPict( ( nMax - nRec ), "99,999,999" ), nRec++, ; state + name } dbCreateIndex( "ntx1", "("+"name + state"+")", bIndex, NIL ) CLOSE ntx /* index with "percentage done" indicator */ @ 11, 10 SAY "0% " + REPL( ".", 50 ) + " 100%" USE ntx EXCLUSIVE NEW nRec := 1 nMax := (LASTREC() + 1) bIndex := { || DevPos( 11, 13 + ((nRec / nMax) * 49) ), ; DevOut( "X" ), nRec++, ; state + name } dbCreateIndex( "ntx2", "("+"name + state"+")", bIndex, NIL ) CLOSE ntx /* index with "approximate time remaining" indicator */ @ 15, 23, 17, 52 BOX "+-+|+-+| " ; @ 16, 25 SAY "Time Remaining :" USE ntx EXCLUSIVE NEW nRec := 1 nMax := (LASTREC() + 1) bIndex := { || DevPos( 16, 42), ; DevOut( NtxTime( ((Timer( TIME() ) / nRec) * ; (nMax - nRec))) ), nRec++, ; state + name } NtxTime( NIL ) Timer( NIL ) dbCreateIndex( "ntx3", "("+"name + state"+")", bIndex, NIL ) CLOSE ntx /* index with "the kitchen sink" indicator */ @ 5, 21, 7, 54 BOX "+-+|+-+| " ; @ 6, 23 SAY "Records Remaining :" @ 11, 10 SAY "0% " + REPL( ".", 50 ) + " 100%" @ 15, 23, 17, 52 BOX "+-+|+-+| " ; @ 16, 25 SAY "Time Remaining :" USE ntx EXCLUSIVE NEW nRec := 1 nMax := (LASTREC() + 1) bIndex := { || DevPos( 6, 43), ; DevOut( TRANSFORM(( nMax - nRec ), "99,999,999" )), ; DevPos( 11, 13 + ((nRec / nMax) * 49) ), ; DevOut( "X" ), ; DevPos( 16, 42), ; DevOut( NtxTime( ((Timer( TIME() ) / nRec) * ; (nMax - nRec))) ), nRec++, ; state + name } NtxTime( NIL ) Timer( NIL ) dbCreateIndex( "ntx4", "("+"name + state"+")", bIndex, NIL ) CLOSE ntx /* position cursor and exit */ DevPos( 23, 0) SET( _SET_CURSOR, xCursor ) RETURN NIL FUNCTION NtxTime( nSeconds ) STATIC nOld LOCAL nHr, nMin, nSec, nNew IF nSeconds == NIL nOld := 999999 nSeconds := 0 ENDIF nSec := nSeconds nHr := INT( nSec / 360) nSec := ( nSec - ( nHr * 360 ) ) nMin := INT( nSec / 60) nSec := ( nSec - ( nMin * 60 ) ) nNew := (nHr * 10000) + (nMin * 100) + nSec IF (nNew <= nOld ) .AND. !(nSeconds == 0 ) nOld := nNew ENDIF nSec := nOld nHr := INT( nSec / 360) nSec := ( nSec - ( nHr * 360 ) ) nMin := INT( nSec / 60) nSec := ( nSec - ( nMin * 60 ) ) RETURN RIGHT( STR( nHr + 100, 3 ), 2 ) + ":" + ; RIGHT( STR( nMin + 100, 3 ), 2 ) + ":" + ; RIGHT( STR( nSec + 100, 3 ), 2 ) FUNCTION Timer( cTime ) STATIC nMark IF cTime == NIL cTime := TIME() nMark := ((VAL( SUBS( cTime, 1, 2 )) * 360 ) + ; (VAL( SUBS( cTime, 4, 2 )) * 60 ) + ; (VAL( SUBS( cTime, 7, 2 )) - 1 )) ENDIF RETURN ((VAL( SUBS( cTime , 1, 2 )) * 360 ) + ; (VAL( SUBS( cTime , 4, 2 )) * 60 ) + ; (VAL( SUBS( cTime , 7, 2 )))) - nMark