Hier mal meine Version.
Ich habs komplett von vorn gemacht weil ich keine Lust hatte in dem Gewirr nen Fehler zu suchen.
Es sind 915 Zeichen und er Funktioniert.
EnableExplicit
Global d=1000,f,b,m
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro X
Procedure
EndMacro
Macro Y
End#X
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
If Mid(c,m,1)="]"
b-1
ElseIf Mid(c,m,1)="["
b+1
W
Until b=0
EndMacro
X A()
Print(#CRLF$+#CRLF$+"Press ENTER to exit")
U
End
Y
X B(n$)
PrintN(n$)
A()
Y
If OpenConsole()=0
MessageRequester("Error","Unable to open console.")
End
W
Print("Filename (blank to use std in)...?")
g=U
If g=""
Repeat
h=U
i=i+h
Until h=""
Else
OpenFile(1,g)
Repeat
i+ReadString(1)
Until Eof(1)
CloseFile(1)
W
b=0
For m=1 To Len(i)
j=Mid(i,m,1)
If FindString(e,j,1)
c+j
If j="["
b+1
ElseIf j="]"
b-1
W
W
Next
If b
B("Uneven brackets")
W
Dim k(d)
For m=1 To Len(c)
Select Asc(Mid(c,m,1))
V 43
k(f)+1
V 45
k(f)-1
V 46
Print(Chr(k(f)))
V 44
If l=""
l=U
W
k(f)=Asc(Left(l,1))
l=Mid(l,2)
V 62
f+1
If f>d
d+1000
ReDim k(d)
W
V 60
f-1
If f<0
B("Memory pointer out of range")
W
V 91
If k(f)=0
Z()
W
V 93
If k(f)<>0
Z(-1)
W
EndSelect
Next
A()
EnableExplicit
Global d=1000,f,b,m
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro X
Procedure
EndMacro
Macro Y
End#X
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
If Mid(c,m,1)="]"
b-1
ElseIf Mid(c,m,1)="["
b+1
W
Until b=0
EndMacro
X A()
Print(#CRLF$+#CRLF$+"Press ENTER to exit")
U
End
Y
X B(n$)
PrintN(n$)
A()
Y
If OpenConsole()=0
MessageRequester("Error","Unable to open console.")
End
W
Print("Filename (blank to use std in)...?")
g=U
If g
OpenFile(1,g)
Repeat
i+ReadString(1)
Until Eof(1)
CloseFile(1)
Else
Repeat
h=U
i=i+h
Until h=""
W
b=0
For m=1 To Len(i)
j=Mid(i,m,1)
If FindString(e,j,1)
c+j
If j="["
b+1
ElseIf j="]"
b-1
W
W
Next
If b
B("Uneven brackets")
W
Dim k(d)
For m=1 To Len(c)
Select Asc(Mid(c,m,1))
V 43
k(f)+1
V 45
k(f)-1
V 46
Print(Chr(k(f)))
V 44
If l=""
l=U
W
k(f)=Asc(Left(l,1))
l=Mid(l,2)
V 62
f+1
If f>d
d+1000
ReDim k(d)
W
V 60
f-1
If f<0
B("Memory pointer out of range")
W
V 91
If k(f)=0
Z()
W
V 93
If k(f)<>0
Z(-1)
W
EndSelect
Next
A()
EnableExplicit
Global d=9,f,b,m
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro X
Procedure
EndMacro
Macro Y
End#X
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
If Mid(c,m,1)="]"
b-1
ElseIf Mid(c,m,1)="["
b+1
W
Until b=0
EndMacro
X A()
Print(#CRLF$+#CRLF$+"Press ENTER to exit")
U
End
Y
X B(n$)
PrintN(n$)
A()
Y
If OpenConsole()=0
MessageRequester("Error","Unable to open console.")
End
W
Print("Filename (blank to use std in)...?")
g=U
If g
OpenFile(1,g)
Repeat
i+ReadString(1)
Until Eof(1)
CloseFile(1)
Else
Repeat
h=U
i=i+h
Until h=""
W
b=0
For m=1 To Len(i)
j=Mid(i,m,1)
If FindString(e,j,1)
c+j
If j="["
b+1
ElseIf j="]"
b-1
W
W
Next
If b
B("Uneven brackets")
W
Dim k(d)
For m=1 To Len(c)
Select Asc(Mid(c,m,1))
V 43
k(f)+1
V 45
k(f)-1
V 46
Print(Chr(k(f)))
V 44
If l=""
l=U
W
k(f)=Asc(Left(l,1))
l=Mid(l,2)
V 62
f+1
If f>d
d+d
ReDim k(d)
W
V 60
f-1
If f<0
B("Memory pointer out of range")
W
V 91
If k(f)=0
Z()
W
V 93
If k(f)<>0
Z(-1)
W
EndSelect
Next
A()
906
- alles was ich hier im Forum sage/schreibe ist lediglich meine Meinung und keine Tatsachenbehauptung
- unkommentierter Quellcode = unqualifizierter Müll
Der Fehler war das weglassen, des letzten Parameters in Mid, default ist ja nicht 1 sondern alle ab
Nutze Mid fast nie
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
- alles was ich hier im Forum sage/schreibe ist lediglich meine Meinung und keine Tatsachenbehauptung
- unkommentierter Quellcode = unqualifizierter Müll
Ich werde mich nicht dafür schämen, das ich diese Function meist durch schnelleres pointern ersetze.
Schäme mich nur, den Fehler eingebaut zu haben.
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
EnableExplicit
Global d=9,f,b,m
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro X
Procedure
EndMacro
Macro Y
End#X
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
If Mid(c,m,1)="]"
b-1
ElseIf Mid(c,m,1)="["
b+1
W
Until b=0
EndMacro
X A()
Print(#CRLF$+#CRLF$+"Press ENTER to exit")
U
End
Y
X B(n$)
PrintN(n$)
A()
Y
If OpenConsole()=0
MessageRequester("Error","Unable to open console.")
End
W
Print("Filename (blank to use std in)...?")
g=U
If g
OpenFile(1,g)
Repeat
i+ReadString(1)
Until Eof(1)
CloseFile(1)
Else
Repeat
h=U
i=i+h
Until h=""
W
b=0
For m=1 To Len(i)
j=Mid(i,m,1)
If FindString(e,j,1)
c+j
If j="["
b+1
ElseIf j="]"
b-1
W
W
Next
If b
B("Uneven brackets")
W
Dim k(d)
For m=1 To Len(c)
Select Asc(Mid(c,m,1))-40
V 3
k(f)+1
V 5
k(f)-1
V 6
Print(Chr(k(f)))
V 4
If l=""
l=U
W
k(f)=Asc(Left(l,1))
l=Mid(l,2)
V 22
f+1
If f>d
d+d
ReDim k(d)
W
V 20
f-1
If f<0
B("Memory pointer out of range")
W
V 51
If k(f)=0
Z()
W
V 53
If k(f)<>0
Z(-1)
W
EndSelect
Next
A()
EnableExplicit
Global d=9,f,b,m
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro X
Procedure
EndMacro
Macro Y
End#X
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
If Mid(c,m,1)="]"
b-1
ElseIf Mid(c,m,1)="["
b+1
W
Until b=0
EndMacro
X A()
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
Y
X B(n$)
PrintN(n$)
A()
Y
If OpenConsole()=0
MessageRequester("Error","Unable to open console.")
End
W
Print("Filename (blank to use std in)...?")
g=U
If g
OpenFile(1,g)
Repeat
i+ReadString(1)
Until Eof(1)
CloseFile(1)
Else
Repeat
h=U
i=i+h
Until h=""
W
b=0
For m=1 To Len(i)
j=Mid(i,m,1)
If FindString(e,j,1)
c+j
If j="["
b+1
ElseIf j="]"
b-1
W
W
Next
If b
B("Uneven brackets")
W
Dim k(d)
For m=1 To Len(c)
Select Asc(Mid(c,m,1))-40
V 3
k(f)+1
V 5
k(f)-1
V 6
Print(Chr(k(f)))
V 4
If l=""
l=U
W
k(f)=Asc(Left(l,1))
l=Mid(l,2)
V 22
f+1
If f>d
d+d
ReDim k(d)
W
V 20
f-1
If f<0
B("Memory pointer out of range")
W
V 51
If k(f)=0
Z()
W
V 53
If k(f)<>0
Z(-1)
W
EndSelect
Next
A()
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
EnableExplicit
Global d=9,f,b,m
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro X
Procedure
EndMacro
Macro Y
End#X
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
If Mid(c,m,1)="]"
b-1
ElseIf Mid(c,m,1)="["
b+1
W
Until b=0
EndMacro
X A()
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
Y
X B(n$)
PrintN(n$)
A()
Y
If OpenConsole()=0
MessageRequester("Error","Unable to open console.")
End
W
Print("Filename (blank to use std in)...?")
g=U
If g
OpenFile(1,g)
Repeat
i+ReadString(1)
Until Eof(1)
CloseFile(1)
Else
Repeat
h=U
i+h
Until h=""
W
b=0
For m=1 To Len(i)
j=Mid(i,m,1)
If FindString(e,j,1)
c+j
If j="["
b+1
ElseIf j="]"
b-1
W
W
Next
If b
B("Uneven brackets")
W
Dim k(d)
For m=1 To Len(c)
Select Asc(Mid(c,m,1))-40
V 3
k(f)+1
V 5
k(f)-1
V 6
Print(Chr(k(f)))
V 4
If l=""
l=U
W
k(f)=Asc(Left(l,1))
l=Mid(l,2)
V 22
f+1
If f>d
d+d
ReDim k(d)
W
V 20
f-1
If f<0
B("Memory pointer out of range")
W
V 51
If k(f)=0
Z()
W
V 53
If k(f)<>0
Z(-1)
W
EndSelect
Next
A()