| |
|
|
 Jörg Sellmeyer | Wie kann ich sicher die Position des ermitteln, das den Kommentar einleitet? Eine Zeile ist z.B.: KompilierenMarkierenSeparierenTest$ = "test" + Test1$ + " hier" + Str(4 * 3) + "so" Test$ = "test" + Test2$ + " da " + Str(4 * 3) + " auch" mal sehen > Keine Gedanken circa die Sinnhaftigkeit des Codes; und unordentlicher Stil ist es auch - muß aber trotzdem erkannt werden.
Saluto Jörg |
|
|
| Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ...  | 12.10.2006 ▲ |
|
|
|
|
 | Schritt Eins ist das Entfernen der Strings und ersetzen in un Spezialphrase.
Schau meine Codeanzeige hier macht es ebenso - und es funktioniert ja.
Z.B. wird aus String 1 (in o.G. Fall) °[1]°, und String 2 °[2]°. Dann suchst Du einfach nach und schneidest ab. Anschliessend musst Du nur °[1]° und °[2]° wieder zurücktranslaten und fertig. |
|
|
| |
|
|
|
 Jörg Sellmeyer | So ähnlich habe ichs mir schon gedacht aber aufs Ersetzen bin ich nicht gekommen  Danke! |
|
|
| Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ...  | 12.10.2006 ▲ |
|
|
|
|
 Michael Wodrich | Ich nutze da das (wohl langsamere) SUCHET, SO WERDET IHR GEFUNDEN KompilierenMarkierenSeparieren
Proc Search_Comment
Null bedeutet: nicht gefunden, sonst Position im String
Parameters Suchtext$
Declare i&, c%, intxt%, Buf#, L&, Ergebnis&
Ergebnis& = -1
L& = Len(Suchtext$)
Dim Buf#, L& + 1
String Buf#,0 = Suchtext$
WhileLoop 0,L& - 1
c% = Byte(Buf#,&Loop)
Case c% = 34 : intxt% = not(intxt%) Anführungszeichen
If (c% = 39) and (intxt% = 0) Kommentarzeichen (und nicht im String)
Ergebnis& = &loop
BREAK
EndIf
EndWhile
Dispose Buf#
Ergebnis& = Ergebnis& + 1
Return Ergebnis&
EndProc
Declare TestString$, erg&
TestString$ = "Test$ = qtestq + Test1$ + q hierq + Str(4 * 3) + qsoqTest$ = qtestq + Test2$ + q da q + Str(4 * 3) + q auchq mal sehen"
cls
print "Das Ergebnis sollte 56 sein."
erg& = Search_Comment( TestString$ )
if erg& = 0
print "Kein Kommentarzeichen gefunden."
else
print "Kommentarzeichen gefunden an Position", Format$("##0",erg&)
print " "
print Space$(erg& - 1) + "v"
print TestString$
print Space$(erg& - 1) + "^"
endif
print " "
waitkey
../../funcion-referencias/xprofan/end/'>end
Schöne Grüße Michael Wodrich |
|
|
| Programmieren, das spannendste Detektivspiel der Welt. | 12.10.2006 ▲ |
|
|
|