User:RhoSigma/Test: Difference between revisions
Jump to navigation
Jump to search
(Replaced content with "== ATTENTION == '''Keep Out''' - This is my all things MediaWiki '''Nuke Test Site''' ...") Tags: Replaced Manual revert |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
== ATTENTION == | == ATTENTION == | ||
'''Keep Out''' - This is my all things MediaWiki '''Nuke Test Site''' ... | '''Keep Out''' - This is my all things MediaWiki '''Nuke Test Site''' ... | ||
{{CodeStart}} | |||
a$ = {{Cl|_READFILE$|_ReadFile$}}({{Text|<nowiki>"internal\help\_HSB32__11132.txt"</nowiki>|#FFB100}}) | |||
{{Cl|REDIM|ReDim}} l$({{Text|0|#F580B1}}) | |||
{{Text|<nowiki>'ub& = Parseline&(a$,)</nowiki>|#919191}} | |||
{{Text|<nowiki>'?test</nowiki>|#919191}} | |||
{{Cl|SUB|Sub}} {{Text|test|#55FF55}} (a##, b(), c) {{Cl|STATIC|Static}} {{Text|<nowiki>'gfuzgweuwfe</nowiki>|#919191}} | |||
{{Cl|END SUB|End Sub}} | |||
{{Cl|FUNCTION|Function}} {{Text|test$|#55FF55}} (a##, b() {{Cl|AS|As}} {{Cl|LONG|Long}}, c) {{Cl|STATIC|Static}} {{Text|<nowiki>'gfuzgweuwfe</nowiki>|#919191}} | |||
{{Cl|END FUNCTION|End Function}} | |||
{{Text|<nowiki>'--- docs\doc_GuiAppframe.bm\ParseLine.html</nowiki>|#919191}} | |||
{{Text|<nowiki>'---------------------------------------------------------------------</nowiki>|#919191}} | |||
{{Cl|FUNCTION|Function}} {{Text|ParseLine&|#55FF55}} (inpLine$, sepChars$, quoChars$, outArray$(), minUB&) | |||
{{Text|<nowiki>'--- so far return nothing ---</nowiki>|#919191}} | |||
{{Text|ParseLine&|#55FF55}} = {{Text|-1|#F580B1}} | |||
{{Text|<nowiki>'--- init & check some runtime variables ---</nowiki>|#919191}} | |||
ilen& = {{Cl|LEN|Len}}(inpLine$): icnt& = {{Text|1|#F580B1}} | |||
{{Cl|IF|If}} ilen& = {{Text|0|#F580B1}} {{Cl|THEN|Then}} {{Cl|EXIT FUNCTION|Exit Function}} | |||
slen% = {{Cl|LEN|Len}}(sepChars$) | |||
{{Cl|IF|If}} slen% > {{Text|0|#F580B1}} {{Cl|THEN|Then}} s1% = {{Cl|ASC (function)|Asc}}(sepChars$, {{Text|1|#F580B1}}) | |||
{{Cl|IF|If}} slen% > {{Text|1|#F580B1}} {{Cl|THEN|Then}} s2% = {{Cl|ASC (function)|Asc}}(sepChars$, {{Text|2|#F580B1}}) | |||
{{Cl|IF|If}} slen% > {{Text|2|#F580B1}} {{Cl|THEN|Then}} s3% = {{Cl|ASC (function)|Asc}}(sepChars$, {{Text|3|#F580B1}}) | |||
{{Cl|IF|If}} slen% > {{Text|3|#F580B1}} {{Cl|THEN|Then}} s4% = {{Cl|ASC (function)|Asc}}(sepChars$, {{Text|4|#F580B1}}) | |||
{{Cl|IF|If}} slen% > {{Text|4|#F580B1}} {{Cl|THEN|Then}} s5% = {{Cl|ASC (function)|Asc}}(sepChars$, {{Text|5|#F580B1}}) | |||
{{Cl|IF|If}} slen% > {{Text|5|#F580B1}} {{Cl|THEN|Then}} slen% = {{Text|5|#F580B1}} {{Text|<nowiki>'max. 5 chars, ignore the rest</nowiki>|#919191}} | |||
{{Cl|IF|If}} {{Cl|LEN|Len}}(quoChars$) > {{Text|0|#F580B1}} {{Cl|THEN|Then}} q1% = {{Cl|ASC (function)|Asc}}(quoChars$, {{Text|1|#F580B1}}): {{Cl|ELSE|Else}} q1% = {{Text|34|#F580B1}} | |||
{{Cl|IF|If}} {{Cl|LEN|Len}}(quoChars$) > {{Text|1|#F580B1}} {{Cl|THEN|Then}} q2% = {{Cl|ASC (function)|Asc}}(quoChars$, {{Text|2|#F580B1}}): {{Cl|ELSE|Else}} q2% = q1% | |||
oalb& = {{Cl|LBOUND|LBound}}(outArray$): oaub& = {{Cl|UBOUND|UBound}}(outArray$): ocnt& = oalb& | |||
{{Text|<nowiki>'--- skip preceding separators ---</nowiki>|#919191}} | |||
plSkipSepas: | |||
flag% = {{Text|0|#F580B1}} | |||
{{Cl|WHILE|While}} icnt& <= ilen& {{Cl|AND (boolean)|And}} {{Cl|NOT|Not}} flag% | |||
ch% = {{Cl|ASC (function)|Asc}}(inpLine$, icnt&) | |||
{{Cl|SELECT CASE|Select Case}} slen% | |||
{{Cl|CASE|Case}} {{Text|0|#F580B1}}: flag% = {{Text|-1|#F580B1}} | |||
{{Cl|CASE|Case}} {{Text|1|#F580B1}}: flag% = ch% <> s1% | |||
{{Cl|CASE|Case}} {{Text|2|#F580B1}}: flag% = ch% <> s1% {{Cl|AND|And}} ch% <> s2% | |||
{{Cl|CASE|Case}} {{Text|3|#F580B1}}: flag% = ch% <> s1% {{Cl|AND|And}} ch% <> s2% {{Cl|AND|And}} ch% <> s3% | |||
{{Cl|CASE|Case}} {{Text|4|#F580B1}}: flag% = ch% <> s1% {{Cl|AND|And}} ch% <> s2% {{Cl|AND|And}} ch% <> s3% {{Cl|AND|And}} ch% <> s4% | |||
{{Cl|CASE|Case}} {{Text|5|#F580B1}}: flag% = ch% <> s1% {{Cl|AND|And}} ch% <> s2% {{Cl|AND|And}} ch% <> s3% {{Cl|AND|And}} ch% <> s4% {{Cl|AND|And}} ch% <> s5% | |||
{{Cl|END SELECT|End Select}} | |||
icnt& = icnt& + {{Text|1|#F580B1}} | |||
{{Cl|WEND|Wend}} | |||
{{Cl|IF|If}} {{Cl|NOT|Not}} flag% {{Cl|THEN|Then}} {{Text|<nowiki>'nothing else? - then exit</nowiki>|#919191}} | |||
{{Cl|IF|If}} ocnt& > oalb& {{Cl|GOTO|GoTo}} plEnd | |||
{{Cl|EXIT FUNCTION|Exit Function}} | |||
{{Cl|END IF|End If}} | |||
{{Text|<nowiki>'--- redim to clear array on 1st word/component ---</nowiki>|#919191}} | |||
{{Cl|IF|If}} ocnt& = oalb& {{Cl|THEN|Then}} {{Cl|REDIM|ReDim}} outArray$(oalb& {{Cl|TO|To}} oaub&) | |||
{{Text|<nowiki>'--- expand array, if required ---</nowiki>|#919191}} | |||
plNextWord: | |||
{{Cl|IF|If}} ocnt& > oaub& {{Cl|THEN|Then}} | |||
oaub& = oaub& + {{Text|10|#F580B1}} | |||
{{Cl|REDIM|ReDim}} {{Cl|_PRESERVE|_Preserve}} outArray$(oalb& {{Cl|TO|To}} oaub&) | |||
{{Cl|END IF|End If}} | |||
{{Text|<nowiki>'--- get current word/component until next separator ---</nowiki>|#919191}} | |||
flag% = {{Text|0|#F580B1}}: nest% = {{Text|0|#F580B1}}: spos& = icnt& - {{Text|1|#F580B1}} | |||
{{Cl|WHILE|While}} icnt& <= ilen& {{Cl|AND (boolean)|And}} {{Cl|NOT|Not}} flag% | |||
{{Cl|IF|If}} ch% = q1% {{Cl|AND (boolean)|And}} nest% = {{Text|0|#F580B1}} {{Cl|THEN|Then}} | |||
nest% = {{Text|1|#F580B1}} | |||
{{Cl|ELSEIF|ElseIf}} ch% = q1% {{Cl|AND (boolean)|And}} nest% > {{Text|0|#F580B1}} {{Cl|THEN|Then}} | |||
nest% = nest% + {{Text|1|#F580B1}} | |||
{{Cl|ELSEIF|ElseIf}} ch% = q2% {{Cl|AND (boolean)|And}} nest% > {{Text|0|#F580B1}} {{Cl|THEN|Then}} | |||
nest% = nest% - {{Text|1|#F580B1}} | |||
{{Cl|END IF|End If}} | |||
ch% = {{Cl|ASC (function)|Asc}}(inpLine$, icnt&) | |||
{{Cl|SELECT CASE|Select Case}} slen% | |||
{{Cl|CASE|Case}} {{Text|0|#F580B1}}: flag% = (nest% = {{Text|0|#F580B1}} {{Cl|AND|And}} (ch% = q1%)) {{Cl|OR|Or}} (nest% = {{Text|1|#F580B1}} {{Cl|AND|And}} ch% = q2%) | |||
{{Cl|CASE|Case}} {{Text|1|#F580B1}}: flag% = (nest% = {{Text|0|#F580B1}} {{Cl|AND|And}} (ch% = s1% {{Cl|OR|Or}} ch% = q1%)) {{Cl|OR|Or}} (nest% = {{Text|1|#F580B1}} {{Cl|AND|And}} ch% = q2%) | |||
{{Cl|CASE|Case}} {{Text|2|#F580B1}}: flag% = (nest% = {{Text|0|#F580B1}} {{Cl|AND|And}} (ch% = s1% {{Cl|OR|Or}} ch% = s2% {{Cl|OR|Or}} ch% = q1%)) {{Cl|OR|Or}} (nest% = {{Text|1|#F580B1}} {{Cl|AND|And}} ch% = q2%) | |||
{{Cl|CASE|Case}} {{Text|3|#F580B1}}: flag% = (nest% = {{Text|0|#F580B1}} {{Cl|AND|And}} (ch% = s1% {{Cl|OR|Or}} ch% = s2% {{Cl|OR|Or}} ch% = s3% {{Cl|OR|Or}} ch% = q1%)) {{Cl|OR|Or}} (nest% = {{Text|1|#F580B1}} {{Cl|AND|And}} ch% = q2%) | |||
{{Cl|CASE|Case}} {{Text|4|#F580B1}}: flag% = (nest% = {{Text|0|#F580B1}} {{Cl|AND|And}} (ch% = s1% {{Cl|OR|Or}} ch% = s2% {{Cl|OR|Or}} ch% = s3% {{Cl|OR|Or}} ch% = s4% {{Cl|OR|Or}} ch% = q1%)) {{Cl|OR|Or}} (nest% = {{Text|1|#F580B1}} {{Cl|AND|And}} ch% = q2%) | |||
{{Cl|CASE|Case}} {{Text|5|#F580B1}}: flag% = (nest% = {{Text|0|#F580B1}} {{Cl|AND|And}} (ch% = s1% {{Cl|OR|Or}} ch% = s2% {{Cl|OR|Or}} ch% = s3% {{Cl|OR|Or}} ch% = s4% {{Cl|OR|Or}} ch% = s5% {{Cl|OR|Or}} ch% = q1%)) {{Cl|OR|Or}} (nest% = {{Text|1|#F580B1}} {{Cl|AND|And}} ch% = q2%) | |||
{{Cl|END SELECT|End Select}} | |||
icnt& = icnt& + {{Text|1|#F580B1}} | |||
{{Cl|WEND|Wend}} | |||
epos& = icnt& - {{Text|1|#F580B1}} | |||
{{Cl|IF|If}} {{Cl|ASC (function)|Asc}}(inpLine$, spos&) = q1% {{Cl|THEN|Then}} spos& = spos& + {{Text|1|#F580B1}} | |||
outArray$(ocnt&) = {{Cl|MID$ (function)|Mid$}}(inpLine$, spos&, epos& - spos&) | |||
ocnt& = ocnt& + {{Text|1|#F580B1}} | |||
{{Text|<nowiki>'--- more words/components following? ---</nowiki>|#919191}} | |||
{{Cl|IF|If}} flag% {{Cl|AND (boolean)|And}} ch% = q1% {{Cl|AND (boolean)|And}} nest% = {{Text|0|#F580B1}} {{Cl|GOTO|GoTo}} plNextWord | |||
{{Cl|IF|If}} flag% {{Cl|GOTO|GoTo}} plSkipSepas | |||
{{Cl|IF|If}} (ch% <> q1%) {{Cl|AND (boolean)|And}} (ch% <> q2% {{Cl|OR (boolean)|Or}} nest% = {{Text|0|#F580B1}}) {{Cl|THEN|Then}} outArray$(ocnt& - {{Text|1|#F580B1}}) = outArray$(ocnt& - {{Text|1|#F580B1}}) + {{Cl|CHR$|Chr$}}(ch%) | |||
{{Text|<nowiki>'--- final array size adjustment, then exit ---</nowiki>|#919191}} | |||
plEnd: | |||
{{Cl|IF|If}} ocnt& - {{Text|1|#F580B1}} < minUB& {{Cl|THEN|Then}} ocnt& = minUB& + {{Text|1|#F580B1}} | |||
{{Cl|REDIM|ReDim}} {{Cl|_PRESERVE|_Preserve}} outArray$(oalb& {{Cl|TO|To}} (ocnt& - {{Text|1|#F580B1}})) | |||
{{Text|ParseLine&|#55FF55}} = ocnt& - {{Text|1|#F580B1}} | |||
{{Cl|END FUNCTION|End Function}} | |||
{{CodeEnd}} |
Revision as of 02:06, 18 December 2024
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 |