User:RhoSigma/Test
Jump to navigation
Jump to search
ATTENTION
Keep Out - This is my all things MediaWiki Nuke Test Site ...
a$ = _ReadFile$("internal\help\_HSB32__11132.txt") ReDim l$(0) 'ub& = Parseline&(a$,) '?test Sub test (a##, b(), c) Static 'gfuzgweuwfe End Sub Function test$ (a##, b() As Long, c) Static 'gfuzgweuwfe End Function '--- docs\doc_GuiAppframe.bm\ParseLine.html '--------------------------------------------------------------------- Function ParseLine& (inpLine$, sepChars$, quoChars$, outArray$(), minUB&) '--- so far return nothing --- ParseLine& = -1 '--- init & check some runtime variables --- ilen& = Len(inpLine$): icnt& = 1 If ilen& = 0 Then Exit Function slen% = Len(sepChars$) If slen% > 0 Then s1% = Asc(sepChars$, 1) If slen% > 1 Then s2% = Asc(sepChars$, 2) If slen% > 2 Then s3% = Asc(sepChars$, 3) If slen% > 3 Then s4% = Asc(sepChars$, 4) If slen% > 4 Then s5% = Asc(sepChars$, 5) If slen% > 5 Then slen% = 5 'max. 5 chars, ignore the rest If Len(quoChars$) > 0 Then q1% = Asc(quoChars$, 1): Else q1% = 34 If Len(quoChars$) > 1 Then q2% = Asc(quoChars$, 2): Else q2% = q1% oalb& = LBound(outArray$): oaub& = UBound(outArray$): ocnt& = oalb& '--- skip preceding separators --- plSkipSepas: flag% = 0 While icnt& <= ilen& And Not flag% ch% = Asc(inpLine$, icnt&) Select Case slen% Case 0: flag% = -1 Case 1: flag% = ch% <> s1% Case 2: flag% = ch% <> s1% And ch% <> s2% Case 3: flag% = ch% <> s1% And ch% <> s2% And ch% <> s3% Case 4: flag% = ch% <> s1% And ch% <> s2% And ch% <> s3% And ch% <> s4% Case 5: flag% = ch% <> s1% And ch% <> s2% And ch% <> s3% And ch% <> s4% And ch% <> s5% End Select icnt& = icnt& + 1 Wend If Not flag% Then 'nothing else? - then exit If ocnt& > oalb& GoTo plEnd Exit Function End If '--- redim to clear array on 1st word/component --- If ocnt& = oalb& Then ReDim outArray$(oalb& To oaub&) '--- expand array, if required --- plNextWord: If ocnt& > oaub& Then oaub& = oaub& + 10 ReDim _Preserve outArray$(oalb& To oaub&) End If '--- get current word/component until next separator --- flag% = 0: nest% = 0: spos& = icnt& - 1 While icnt& <= ilen& And Not flag% If ch% = q1% And nest% = 0 Then nest% = 1 ElseIf ch% = q1% And nest% > 0 Then nest% = nest% + 1 ElseIf ch% = q2% And nest% > 0 Then nest% = nest% - 1 End If ch% = Asc(inpLine$, icnt&) Select Case slen% Case 0: flag% = (nest% = 0 And (ch% = q1%)) Or (nest% = 1 And ch% = q2%) Case 1: flag% = (nest% = 0 And (ch% = s1% Or ch% = q1%)) Or (nest% = 1 And ch% = q2%) Case 2: flag% = (nest% = 0 And (ch% = s1% Or ch% = s2% Or ch% = q1%)) Or (nest% = 1 And ch% = q2%) Case 3: flag% = (nest% = 0 And (ch% = s1% Or ch% = s2% Or ch% = s3% Or ch% = q1%)) Or (nest% = 1 And ch% = q2%) Case 4: flag% = (nest% = 0 And (ch% = s1% Or ch% = s2% Or ch% = s3% Or ch% = s4% Or ch% = q1%)) Or (nest% = 1 And ch% = q2%) Case 5: flag% = (nest% = 0 And (ch% = s1% Or ch% = s2% Or ch% = s3% Or ch% = s4% Or ch% = s5% Or ch% = q1%)) Or (nest% = 1 And ch% = q2%) End Select icnt& = icnt& + 1 Wend epos& = icnt& - 1 If Asc(inpLine$, spos&) = q1% Then spos& = spos& + 1 outArray$(ocnt&) = Mid$(inpLine$, spos&, epos& - spos&) ocnt& = ocnt& + 1 '--- more words/components following? --- If flag% And ch% = q1% And nest% = 0 GoTo plNextWord If flag% GoTo plSkipSepas If (ch% <> q1%) And (ch% <> q2% Or nest% = 0) Then outArray$(ocnt& - 1) = outArray$(ocnt& - 1) + Chr$(ch%) '--- final array size adjustment, then exit --- plEnd: If ocnt& - 1 < minUB& Then ocnt& = minUB& + 1 ReDim _Preserve outArray$(oalb& To (ocnt& - 1)) ParseLine& = ocnt& - 1 End Function |