home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / NTXHANDL.ASM < prev    next >
Assembly Source File  |  1992-10-16  |  4KB  |  115 lines

  1. ; File......: NTXHANDL.ASM
  2. ; Author....: Ted Means
  3. ; Date......: $Date:   15 Oct 1992 23:59:12  $
  4. ; Revision..: $Revision:   1.0  $
  5. ; Log file..: $Logfile:   C:/nanfor/src/ntxhandl.asv  $
  6. ; This is an original work by Ted Means and is placed in the
  7. ; public domain.
  8. ;
  9. ; Modification history:
  10. ; ---------------------
  11. ;
  12. ; $Log:   C:/nanfor/src/ntxhandl.asv  $
  13. ;  
  14. ;     Rev 1.0   15 Oct 1992 23:59:12   GLENN
  15. ;  Initial revision.
  16. ;  
  17.  
  18. ; $DOC$
  19. ; $FUNCNAME$
  20. ;     FT_NTXHand()
  21. ; $CATEGORY$
  22. ;     Database
  23. ; $ONELINER$
  24. ;     Obtain the handle associated with an open .NTX file.
  25. ; $SYNTAX$
  26. ;     FT_NTXHand( <nOrderNum> ) -> nHandle
  27. ; $ARGUMENTS$
  28. ;     <nOrderNum> is a numeric value indicating the active index for which
  29. ;     the handle is to be obtained.
  30. ; $RETURNS$
  31. ;    The file handle, or zero if no .NTX is open in the specified
  32. ;    work area or if <nOrderNum> does not represent an open index.
  33. ; $DESCRIPTION$
  34. ;    For your own twisted reasons you may need make direct use of the
  35. ;    file handle associated with an index.  This function gives you
  36. ;    that capability, but use it with care and don't blame me if you
  37. ;    botch something up.
  38. ;
  39. ;    By default this function works on the current work area, but can be
  40. ;    made to work on any work area through the use of the standard Clipper
  41. ;    alias operator.
  42. ;
  43. ;    Be aware that this function makes use of Clipper's internal work
  44. ;    area information which is subject to change in future versions of
  45. ;    Clipper.  If this makes you uncomfortable then don't use this function,
  46. ;    you gutless weasel.
  47. ;
  48. ;    This function is written to adhere to Turbo Assembler's IDEAL mode.
  49. ;    To use another assembler, rearrange the SEGMENT and PROC directives
  50. ;    and make any other necessary changes to the source code.
  51. ;
  52. ; $EXAMPLES$
  53. ;      // Get the handle for the second index
  54. ;
  55. ;      QOut( FT_NTXHand( 2 ) )
  56. ;
  57. ;      // Try a non-current work area
  58. ;
  59. ;      nHandle := THISFILE->( FT_NTXHand( 1 ) )
  60. ;
  61. ;      // This will return zero because only 15 indexes can be active
  62. ;
  63. ;      nHandle := THATFILE->( FT_NTXHand( 22 ) )
  64. ; $END$
  65.  
  66. IDEAL
  67.  
  68. Public   FT_NTXHand
  69.  
  70. Extrn    __WorkAreas:DWord                   ; INTERNAL!!!
  71. Extrn    __RetNI:Far
  72. Extrn    __ParNI:Far
  73.  
  74. Segment  _NanFor   Word      Public    "CODE"
  75.          Assume    CS:_NanFor
  76.  
  77. Proc     FT_NTXHand          Far
  78.  
  79.          Mov       AX,1                      ; Specify param #1
  80.          Push      AX                        ; Put on stack
  81.          Call      __ParNI                   ; Retrieve parameter
  82.          Add       SP,2                      ; Realign stack
  83.          Or        AX,AX                     ; Make sure parameter is
  84.          JZ        @@Done                    ; within acceptable range
  85.          Cmp       AX,15
  86.          JBE       @@Okay
  87.          Xor       AX,AX                     ; If not, return zero
  88.          Jmp       Short @@Done
  89.  
  90. @@Okay:  LES       BX,[__WorkAreas]          ; Load pointer to work areas
  91.          Mov       DX,AX                     ; Move index specifier into DX
  92.          Mov       AX,[Word Ptr ES:BX]       ; Check to see if work area
  93.          Or        AX,[Word Ptr ES:BX + 2]   ; is in use
  94.          JZ        @@Done                    ; If not, return zero
  95.          LES       BX,[DWord Ptr ES:BX]      ; Load work area pointer
  96.          Dec       DX                        ; Compute offset to locate
  97.          SHL       DX,1                      ; pointer to index info
  98.          SHL       DX,1
  99.          Add       BX,DX
  100.          Mov       AX,[Word Ptr ES:BX + 98h] ; See if specified index is open
  101.          Or        AX,[Word Ptr ES:BX + 9Ah]
  102.          JZ        @@Done                    ; If not, return zero
  103.          LES       BX,[ES:BX + 98h]          ; Load index info pointer
  104.          Mov       AX,[Word Ptr ES:BX]       ; Get handle
  105.  
  106. @@Done:  Push      AX                        ; Put return value on stack
  107.          Call      __RetNI                   ; Return it
  108.          Add       SP,2                      ; Realign stack
  109.          Ret
  110. Endp     FT_NTXHand
  111. Ends     _NanFor
  112. End
  113.  
  114.