| |
|
|
RudiB. | Hello together,
I stand well at a for me sheer unlösbaren task. i want one Program-Listing with Befehlszeilentrennung through Doppelpunkte, aufsplitten in self-contained Program lines. as Sonderfall should however a row with "Case" or "CaseNot" to maintain go.
here time one utterly Sinnfreies Listing and thereafter the Listing bereinigt.
...and so reserves then looks.....I utterly not hinkriege !!!!
....z.B: on my own already the String VAR a$ with a colon therein position a challenge dar...because here too yet The eigentliche Befehlszeile with a Backslash aufgesplittet becomes...
here in the Forum becomes the first Listing with the Strings farblich not correctly displayed....
stand straight fully on the Hose... can me here someone on The Sprünge help ??? |
|
|
| |
|
|
|
RudiB. | alas......, the most important forget....The Aufsplittung the Befehlszeilen with Backslash should naturally, How in the downstairs Listing, to maintain go. |
|
|
| |
|
|
|
RudiB. | this is my attempt (LISTING) the trouble To solve...
cls
Declare row$,x%,pos%,pos2%,new_zeile$,next_zeile$,org_zeile$,End_kommentar$,kom%,aray$[]
Declare Zeit&,File$
Datei$=Loadfile$("ÖFFNE:","*.prf")
Zeit&=&gettickcount
Assign #1,File$
reset #1
Print "Working.....Please Wait"
WhileNot EOF(#1)
input #1,row$
Org_Zeile$=row$
'-----------------------------------------------------------------------------------------------------------------------
' Ganzzeilige comments and Blockkommentare in Leerzeilen wandeln
'-----------------------------------------------------------------------------------------------------------------------
If (Left$(Trim $(Line $),1)="'") Or (Left$(Trim $(Line $),2)="//")
row$=""
Print Org_zeile$
continue
EndIf
If Left$(row$,2)="/*"
Print Org_zeile$
kom%=1
continue
EndIf
If Left$(row$,2)="*/"
Print Org_zeile$
kom%=0
continue
EndIf
If kom%=1
row$=""
Print Org_zeile$
continue
EndIf
'-----------------------------------------------------------------------------------------------------------------------
'-----------------------------------------------------------------------------------------------------------------------
' Doppelpunkte in Strings transfiguring
'-----------------------------------------------------------------------------------------------------------------------
Ifnot right$(trim$(Line $),1)=chr $(92)
If instr(chr $(58),row$)
pos%=0
Whileloop Len(Line $)
If mid$(row$,&loop,1)=chr $(34)
pos%=hardship(pos%)
EndIf
If (pos%=1) And (mid$(row$,&loop,1)=Chr$(58))
New_Zeile$=New_Zeile$+chr $(247)
Else
new_Zeile$=new_Zeile$+mid$(row$,&loop,1)
EndIf
EndWhile
If pos%=1
row$=Translate$(row$,chr $(58),chr $(247))
Else
row$=New_Zeile$
new_zeile$=""
Endif
EndIf
Endif
'-----------------------------------------------------------------------------------------------------------------------
' Endkommentare cut off
'-----------------------------------------------------------------------------------------------------------------------
If (Instr("'",Trim $(Line $),2)) Or (Instr("//",Trim $(Line $),2))
pos%=0
End_kommentar$=""
Whileloop Len(Line $)
If mid$(row$,&loop,1)=chr $(34)
pos%=hardship(pos%)
EndIf
If (mid$(row$,&loop,1)="'") And (pos%=0)
End_kommentar$=Right$(row$,Len(Line $)-&loop+1)
row$=Left$(row$,&loop-1)
Break
EndIf
If (mid$(row$,&loop,2)="//") And (pos%=0)
End_kommentar$=Right$(row$,Len(Line $)-&loop+1)
row$=Left$(row$,&loop-1)
Break
EndIf
EndWhile
EndIf
'-----------------------------------------------------------------------------------------------------------------------
' colon Befehlszeilen-Trennung
'-----------------------------------------------------------------------------------------------------------------------
Ifnot right$(trim$(Line $),1)=chr $(92)
If Instr(":",row$)
pos%=0
pos2%=1
new_zeile$=""
While 1
Pos%=Instr(":",row$,pos2%)
If pos%=0
Break
EndIf
If right$(row$,1)=":"'Sprungmarker
break
EndIf
If (Left$(Trim $(lower$(Line $)),5)="case ") or (Left$(Trim $(lower$(Line $)),8)="casenot ")
Pos2%=Instr(":",row$,pos%+1)
If pos2%=0
Break
EndIf
EndIf
new_Zeile$=Left$(row$,pos%-1)
new_Zeile$=Translate$(new_Zeile$,chr $(247),chr $(58))
Print new_zeile$
new_Zeile$=""
row$=right$(row$,Len(Line $)-pos%)
EndWhile
EndIf
Endif
row$=Translate$(row$,chr $(247),chr $(58))
Print row$+" "+End_kommentar$
End_kommentar$=""
new_zeile$=" "
EndWhile
Close #1
Print &gettickcount-Zeit&
Print "FERTIG"
Waitinput
|
|
|
| |
|
|
|
Walter | here one first Ansatz, the simply feststellt, whether one itself with one colon within one Strings befindet or not. Bzgl. Case must first yet clarified go, whether only the first colon thereafter stay should or. How one with further verfährt.
'## Kommentarzeilen are not berücksichtigt
'## case is here not yet berücksichtigt
cls
Declare File$
declare StringAn%,i%,in$,out$,a$[]
StringAn%=0' 0=Außerhalb one Strings, 1=Innerhalb one Strings
Datei$=Loadfile$("ÖFFNE:","*.prf")
Assign #1,File$
reset #1
Print "Working.....Please Wait"
WhileNot EOF(#1)
input #1,in$
a$[]=explode(in $)' characters the Line in one aray write
'any characters the row go through
for i%,len(in $)
' check, whether one itself within one Strings befindet
case a$[i%-1]=Chr$(34) and StringAn%=0:StringAn%=1
case a$[i%-1]=Chr$(34) and StringAn%=1:StringAn%=0
if a$[i%-1]=":"
If StringAn%=0' : isn't within one Strings - row share
print out$
out$=""
else
out$=out $+a$[i%-1]' : is within one Strings - row continue
endif
else
out$=out $+a$[i%-1]
endif
endfor
print out$
out$=""
EndWhile
Close #1
Print "FERTIG"
waitinput
|
|
|
| |
|
|
|
RudiB. | Hello Walter,
...beautiful the still someone this Topic answer.
your Ansatz is Yes correctly., still the devil's stick Yes in the detail... If I z.B.: an Programmzeile The a String contain, but then with a Backslash on several Lines zoned becomes. see here....
here haperst then vast...
i know already a Solution for my trouble in general, however would I gladly too a Solution for find, if I a File Zeilenweise einlese .... there's too this a Solution .... here should then but each row through several inquire walk, what naturally very plenty Time cost.....
I Have even hoped, someone has a zündende idea, on The I do not come...
Greeting from munich Rudi |
|
|
| |
|
|
|
Walter | my Programmstück comes with your code
but fine zurecht... |
|
|
| |
|
|
|
Walter | Sorry - already seen. look I me moreover on... |
|
|
| |
|
|
|
RudiB. | THANK YOU... |
|
|
| |
|
|
|
Walter | Bähhh - was only one small Error drin... now does it!
|
|
|
| |
|
|
|
RudiB. | I work indeed dran.... but apparently seh I the woods not sheer trees.... often is it so simply...Have I already so often here in the Forum erlebt... |
|
|
| |
|
|
|
RudiB. | wow....short probiert with the Test-Listing, How have You now the made???? ..must your Sourcecode time look at... |
|
|
| |
|
|
|
Walter | here now velvet case / caseNot: thereby Have I on it held, that usually any auf case subesquent Commands in same row with true worn out go, during with false immediate into next row sprang becomes. (from Help: Case n : BEF has the expression n a worth <> 0, becomes BEF carryed out, otherwise goes The Programmausführung into next row...)
' the Codestück divides Befehlszeilen with ":" in new Lines on,
' except
' a) the ":" is within one Stringliterals; or
' b) with case/caseNot. here stay any ":" in same row _nach_ one
' case/caseNot receive (though yet yet without Berücksichtigung of
' Umbrüchen langer Codezeilen)
' Kommentarzeilen are not berücksichtigt;
' The must ggf before ausgeschieden go
cls
Declare File$
declare StringAn%,i%,in$,out$,a$[]
declare caseAn%,pos%
StringAn%=0
CaseAn%=0
Datei$=Loadfile$("ÖFFNE:","*.prf")
Assign #1,File$
reset #1
Print "Working.....Please Wait"
WhileNot EOF(#1)
input #1,in$
a$[]=explode(in $)' characters the Line in aray write
' if case or caseNot drin: position check
pos%=instr("case ",lower$(in $))
case pos%=0:pos%=instr("casenot ",lower$(in $))
if pos%=0' KEIN case drin
'any characters the row go through
for i%,len(in $)
' check, whether one itself within one Strings befindet
if (a$[i%-1]=Chr$(34)) and (StringAn%=0)#
StringAn%=1
elseif (a$[i%-1]=Chr$(34)) and (StringAn%=1)
StringAn%=0
endif
if a$[i%-1]=":"
If StringAn%=0' : isn't within one Strings - row share
print out$
out$=""
else
out$=out $+a$[i%-1]' : is within one Strings - row continue
endif
else
out$=out $+a$[i%-1]' other characters as :
endif
endfor
else' case or caseNot drin
'any characters the row up to case go through
for i%,pos%-1
' check, whether one itself within one Strings befindet
if (a$[i%-1]=Chr$(34)) and (StringAn%=0)
StringAn%=1
elseif (a$[i%-1]=Chr$(34)) and (StringAn%=1)
StringAn%=0
endif
if a$[i%-1]=":"
If StringAn%=0' : isn't within one Strings - row share
print out$
out$=""
else
out$=out $+a$[i%-1]' : is within one Strings - row continue
endif
else
out$=out $+a$[i%-1]' one other characters as :
endif
endfor
endif
if pos%>0
' remainder the case-Line in a new row write
print mid$(in$,pos%,len(in $)-pos%+1)
else
print out$
out$=""
endif
EndWhile
Close #1
Print "FERTIG"
waitinput
gladly inquiries, sofern The comments not suffice. Error are naturally possible... |
|
|
| |
|
|