<%
'DESCR
'  simply extracts string R=Text[[""]Text] from
'  Source which is = ..."Text[[""]Text]"......
'
'
'INPUT:
'   SourceS - must have "
'             at StartPos which will be skipped and which marks
'             the beginning of the searched string;
'   StartSearchPos - first Mark position
'             remmed: position where to start first q-mark seach
'   RecognizeDoubleQuoters - if true, then pair "" converted ...
'       if ReduceDoubleQuoters = true, ... to "
'                              = false, ... to ""
'   StripQMarks - if true, then  R   is returned
'                 otherwise     "R"  is returned.
'   Mark     - this is a character which can be used instead of ""
'              for example single quotation mark 
'   ReduceDoubleQuoters
'OUTPUT: returns R or "R"
'        EndPos - character next after last "
'
'NOTE
'
Function CutQuotedString( _
     StartSearchPos, SourceS, Mark, _
     RecognizeDoubleQuouters, _
     ReduceDoubleQuoters, StripQMarks, _
     EndPos)

Dim CurrentPos, wi, result, ResultL
Dim StartPos

result = ""
CutQuotedString = ""
ResultL = Len(SourceS)
StartPos = StartSearchPos 
'to search for first Mark:
'StartPos = InStr(StartSearchPos, SourceS, Mark)
EndPos = StartSearchPos
If StartPos = 0 Or StartPos = ResultL _
   Then Exit Function

'first character (usually ") is skipped:
CurrentPos = StartPos + 1
If CurrentPos > Len(SourceS) Then
   EndPos = ResultL + 1
   Exit Function
End If

Do
 'locate position of the next ":
 wi = InStr(CurrentPos, SourceS, Mark)
 If wi = 0 Then
   'return all plus "complete" string with ":
   result = result & Mid(SourceS, CurrentPos)
   EndPos = ResultL + 1
   Exit Do 'break of string found
 End If

 
 result = result & _
          Mid(SourceS, CurrentPos, wi - CurrentPos)
 
 If Mid(SourceS, wi + 1, 1) = Mark And _
   RecognizeDoubleQuouters Then
   CurrentPos = wi + 2
   result = result & Mark
   If Not ReduceDoubleQuoters Then _
      result = result & Mark
 Else
   EndPos = wi + 1  'next pos
   Exit Do  'end of string found
 End If
Loop

'If tz_conv_str = "P" Then _
'   result = Replace(Replace(Replace(result, "\", "\\"), """""", "\"""), "$", "\$")

If StripQMarks Then
   CutQuotedString = result
Else
   CutQuotedString = Mark & result & Mark
End If

End Function
%>