;
 ; ------------------------------------------------------
 ;        iChr = AscW(Mid$(sStr, lPos, 1))
 ;        iChr = MidI(sStr, lPos)
 ; ------------------------------------------------------
 ;
 ; Property Get MidI(sStr As String, ByVal lPos As Long) As Integer
 ;    CopyMemory MidI, ByVal StrPtr(sStr) + lPos + lPos - 2&, 2&
 ; End Property
 ;
 ; ------------------------------------------------------
;
 .486            ; 32-bit instruction set
 .model flat     ; Protected memory, 4GB limit
 .code           ; Start of code

Get_MidI proc near

   mov ecx,[esp+8]    ; copy string descriptor
   mov edx,[esp+12]   ; copy read pos parameter
   mov ecx,[ecx]      ; extract string pointer
   xor eax, eax       ; zero default return

   shl edx, 1         ; convert to byte position
   jbe _exitp         ; invalid read pos (jcz)
   test ecx,ecx       ; validate string pointer
   jz _exitp          ; exit null string passed

   cmp edx,[ecx-4]    ; compare pos with str len
   ja _exitp          ; exit outside string bounds

   mov ax,[ecx+edx-2] ; extract wchar into ax

  _exitp:
   mov ecx,[esp+16]   ; copy return descriptor
   mov [ecx],ax       ; assign property result

   xor eax, eax  ; clear eax tell VB all okay
   ret 16        ; cleanup (lpObj, p1, p2, rc)

Get_MidI endp ; end of procedure
end Get_MidI  ; end of code, indicate entry point
