C+
C NAME:
C	iAskChar
C PURPOSE:
C CALLING SEQUENCE:
	function iAskChar(cQuery,M,bExit,bFile,bDir,bParse,bUpper,cExit,cVal,cOld)
C INCLUDE:
	include		'filparts.h'
C CALLS:
C	itrim, uppercase, iGetFileSpec, iSearch, iCheckDirectory
C-
	    character	cQuery*(*)
	    integer	M
	    logical	bExit
	    logical	bFile
	    logical	bDir
	    logical	bParse
	    logical	bUpper
	    character	cExit
	    character	cVal*(*)
	    character	cOld*(*)

     	character	cSpace*3	/'   '/

	L = itrim(cQuery)

	M = max( index(cQuery,'$EXIT='), index(cQuery,'$exit=') )
	bExit = M .ne. 0
	if (bExit) then
	    cExit = cQuery(M+6:M+6)		! Exit character
	    call uppercase(cExit)
	    L = M-1
	end if

	M = max( index(cQuery(:L),'$FILE'), index(cQuery(:L),'$file') )
	bFile = M .ne. 0
	if (bFile) L = M-1

	M = max( index(cQuery(:L),'$DIR'), index(cQuery(:L),'$dir') )
	bDir = M .ne. 0
	if (bDir) L = M-1

	M = max( index(cQuery(:L),'$PARSE'), index(cQuery(:L),'$parse') )
	bParse = M .ne. 0
	if (bParse) L = M-1

	M = max( index(cQuery(:L),'$U'), index(cQuery(:L),'$u') )
	bUpper = M .ne. 0
	if (bUpper) L = M-1

	if (bExit) then
	    cQuery(L+1:) = ' ('//cExit//'=Exit)'
	    L = L+9
	end if

	if (itrim(cVal) .eq. 0) cVal = ' '

	if (bFile) then
	    i = iSearch(11,cVal,cOld)
	else if (bDir) then
	    if (iCheckDirectory(cVal) .eq. 1) i = iGetFileSpec(0,FIL__DIRECTORY,cOld)
	else if (bParse) then
	    if (iSearch(11,cVal,cOld) .ne. 2) cOld = cVal
	else
	    cOld = cVal
	end if

	M = itrim(cOld)
	if (M .lt. 3) then
	    cOld = cSpace(:3-M)//cOld
	    !cOld(3+1-M:) = cOld			! ShiftStr problem
	    !if (M .ne. 3) cOld(:3-M) = ' '
	    M = 3
	end if

	iAskChar = L

	return
	end
