home *** CD-ROM | disk | FTP | other *** search
- ASK THE GRUMPS
- Compiled by Greg Lief
-
-
- Do you have a burning Clipper question? Send it our way via the
- Aquarium Message Center and get the pleasure of not only an expert
- solution to your question, but seeing your name in print!!
-
- ---------------------------------------------------------------------
-
- Dear Grumps:
-
- Several questions for you:
-
- 1. What's the best and most efficient method to open a DBF file using
- a variable name? i.e.,
-
- dbf := cOne + cTwo + ".DBF"
- ntx := (dbf) + ".NTX"
- IF ! Net_use((dbf),.F.,(ntx))
- CLEAR
- RETURN
- ENDIF
-
- I definitely want to stay away from macro substitution (for
- example, Net_use("&dbf",.F.,"&ntx")).
-
- 2. What is the best and fastest code to fill an array with JUST
- filenames? I want to use DIRECTORY(), but it saves multiple arrays
- containing various file information.
-
- Thanks!
-
- Matt Amis
- Port Orchard, WA
- *
- (Mr. Grump and Mr. Neff respond:)
-
- 1. Try this:
-
- mvar := 'whatever'
- use (mvar + '.dbf') index (mvar + 'ntx')
-
- or if you want to continue using a function such as Net_Use():
-
- if ! net_use(mdbf, .f., mntx)
- return
- endif
-
- As you can see, with Net_Use() there is no need to enclose the dbf
- and ntx names within parentheses. And macro substitution is also
- entirely unnecessary.
-
- 2. You have two choices... you can use ADIR() or DIRECTORY().
- Although DIRECTORY() gives you all the file info (as opposed to
- ADIR(), which will give you only what you specify), I would still
- recommend that you use DIRECTORY(). ADIR() is one of the Clipper
- functions that is in the process of being phased out, and with
- good reason: it is clunky compared to DIRECTORY(). If you only
- need filenames, here's two lines of code to do it for you:
-
- local a := directory(), b := {}
- aeval(a, { | element | aadd(b, element[1] } )
-
- Array B will then contain only the filenames.
-
- ---------------------------------------------------------------------
-
- Dear Grumps:
-
- In Summer '87, I am able to paint the entire screen with for example,
- chr(176), simply by issuing the command:
-
- ? REPLICATE(chr(176), 2000)
-
- assuming of course that the display is 80 x 25. However, when I issue
- this command in 5.0, only Row 0 gets painted. Can you explain why?
- Is there any other way to get around this besides going through a
- FOR..NEXT loop?
-
- Thanks,
-
- Jeff Intravaia
- New York, NY
- *
- (Mr. Grump responds:)
-
- The reason that only row 0 gets painted in Clipper 5.0 is in
- anticipation of different display modes. 5.0 apparently does not make
- the assumption that your row is 80 characters wide, and thus paints a
- 2000 character row. Naturally, you don't see the remaining 1920
- characters!
-
- For what you are trying to do, there is no need to resort to a
- FOR..NEXT loop. Try this:
-
- @ 0, 0, maxrow(), maxcol() box replicate(chr(176), 9)
-
- Not only will this be quite fast, but it will always cover the entire
- screen, no matter what display mode you happen to be using. MAXROW()
- and MAXCOL() are Clipper functions that return the maximum row and
- column based on the current video display mode.
-
- ---------------------------------------------------------------------
-
- Dear Grumps:
-
- Although RTLINK is a big improvement over PLINK86, I still have enough
- time to sweep the kitchen floor during the average link cycles! Any
- suggestions? Should I give in and use Blinker or WarpLink? I've
- heard about pre-linked libraries -- would they help?
-
- Kathy Uchman
- Concord, CA
- *
- (Mr. Grump responds:)
-
- Dear Kathy
-
- If you are not already using pre-linked libraries, you are wasting
- valuable link time. For less than a minute's investment (40 seconds
- on my 386/20), you can create a .PLL that will slash your link time.
- Look for the file BASE50.LNK somewhere on your hard disk. Found it?
- Great! Now run the following command:
-
- RTLINK @base50
-
- After a few seconds of churning, this will create the files BASE50.PLL
- and BASE50.PLT. Put them in your \CLIPPER5\PLL directory. Make sure
- that you have the following line in your AUTOEXEC.BAT file:
-
- SET PLL=C:\CLIPPER5\PLL (or whatever directory they are in)
-
- This environmental variable instructs the linker and run-time system
- where to find the .PLL. (For more details on Clipper environmental
- variables, please see my article on "Compiler Switches and the
- Environment" elsewhere in this issue.)
-
- Now when you link an application, instead of using this command:
-
- RTLINK FI whatever
-
- use this one:
-
- RTLINK FI whatever /PLL:base50
-
- You will notice a dramatic improvement in link time. Here is a sample
- program that I linked "the old way", and with a .PLL:
-
- function main
- local x := 0
- return nil
-
- The old way (using the LIBs) took 14 seconds. With a .PLL, the link
- took just 5 seconds!
-
- If this is not fast enough for you, please investigate Roger Donnay's
- article "Linking Tips with PLLs" in the December 1990 Aquarium. It
- provides a FULLBASE.LNK file that creates a pre-linked library
- containing every single module in all of the libraries
- provided with Clipper 5.0.
-
- ---------------------------------------------------------------------
-