home *** CD-ROM | disk | FTP | other *** search
- Overview:
-
- The function AlphaN is a good example of a Clipper UDF written in C. It
- also shows how to use _exmgrab and _exmback, the EXTEND system's memory
- allocation routines.
-
- Included is my version of EXTEND.H and NANDEF.H, CLIP_C.H, I hope
- Nantucket doesn't mind. (Note to Nantucket: CLIP_C.H is a modified
- version of your EXTEND.H and NANDEF.H, if you would like to use
- any or all of my modifications, feel free.)
-
- Initially, I wrote AlphaN in dbase (AlphN.prg). Then I rewrote it in C
- (AlphN.c). For a C compiler, I used Turbo C (tm), v 1.5 from Borland,
- though I suspect others will work too (?). Also, you shouldn't have any
- difficulties using Turbo C 1.0. For a dbase compiler, I used Clipper
- (tm), Summer '87 from Nantucket.
-
- Extend's memory allocation: _exmgrab and _exmback
-
- These two functions are a much appreciated addition to Clipper's
- EXTEND system. They are similar to the malloc and free functions
- in C, which cannot be used in a Clipper UDF.
-
- You need to be aware of two things to use these functions successfully:
- 1) any memory _exmgrab.ed must be _exmback.ed in the same UDF
- 2) you must be sure to pass the correct size when _exmback.ing (free
- doesn't require this)
-
- At first glance, these two functions may seem useless; i.e., it would
- appear that you couldn't pass a string back to Clipper since you can't
- keep the memory allocated. However, the _retxx takes care of this by
- allocating its own memory and copying the string into it. You take
- the following steps to return a string:
- 1) _exmgrab memory
- 2) construct string
- 3) _retxx it
- 4) _exmback memory
-
-
- Compilation of C UDF
-
- AlphN.c was compiled using the command line version of Turbo C with
- the configuration file TURBOC.CFG available in the current directory.
- This configuration file sets up TC to compile in large model and
- forces the segment names to Clipper segment names and some other
- stuff (see EXTEND.DOC on your Clipper disks)
-
-
- Questions, comments, suggestions.
-
- Please send any Q,C or S to:
-
- Mark Pfeifer
- Source ID: BFB511
- Compuserve: 73657,3203