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
OpenConsole()
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()
839
- alles was ich hier im Forum sage/schreibe ist lediglich meine Meinung und keine Tatsachenbehauptung
- unkommentierter Quellcode = unqualifizierter Müll
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 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
Procedure B(n$,o=1)
If o
PrintN(n$)
W
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
EndProcedure
OpenConsole()
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
B("",0)
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 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
Procedure B(n$,o=1)
If o
PrintN(n$)
W
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
EndProcedure
OpenConsole()
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
Dim 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
B("",0)
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.
STARGÅTE hat geschrieben:
Macros können nicht verschachtelt werden! Der aufruf von Macro ... Macro ist also nicht erlaubt, auch wenn er "verkleidet wird"
EnableExplicit
Global d=9,f,b,m,n
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
n=Asc(Mid(c,m,1))
b+(n/90)*(92-n)
Until b=0
EndMacro
Procedure B(n$,o=1)
If o
PrintN(n$)
W
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
EndProcedure
OpenConsole()
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
B("",0)
EnableExplicit
Global d=9,f,b,m,n
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro Z(a=1)
b=a
Repeat
m+a
n=Asc(Mid(c,m,1))
b+(n/90)*(92-n)
Until b=0
EndMacro
Procedure B(n$,o=1)
If o
PrintN(n$)
W
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
EndProcedure
OpenConsole()
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
n=Asc(j)
b+(n/90)*(92-n)
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
B("",0)
EnableExplicit
Global d=9,f,b,m,n
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro Z(a)
b=a
Repeat
m+a
n=Asc(Mid(c,m,1))
b+(n/90)*(92-n)
Until b=0
EndMacro
Procedure B(n$,o=1)
If o
PrintN(n$)
W
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
EndProcedure
OpenConsole()
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
n=Asc(j)
b+(n/90)*(92-n)
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(1)
W
V 53
If k(f)<>0
Z(-1)
W
EndSelect
Next
B("",0)
Macro verhalten sich wirklich komplett anders als Prozeduren (auch wenn deren Definition ähnlich ist).
Der Compiler liest immer nur die erste Zeile "Macro Test" und übergeht solange den nachfolgenden Code bis ein "EndMacro" kommt, es findert keinerlei Syntaxkontrolle statt.
Erst wenn im Code dann diese Macro verwendet wird also: "Test", dann wird der Inhalt zwischen Macro und EndMacro Zeichen für Zeichen übernommen und erst dann auf Syntax kontrolliert.
EnableExplicit
Global d=9,f,b,m,n
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro Z(a)
b=a
Repeat
m+a
n=Asc(Mid(c,m,1))
b+(n/90)*(92-n)
Until b=0
EndMacro
Procedure B(n$,o=1)
If o
PrintN(n$)
W
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
EndProcedure
OpenConsole()
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
n=Asc(j)
b+(n/90)*(92-n)
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(1)
W
V 53
If k(f)
Z(-1)
W
EndSelect
Next
B("",0)
EnableExplicit
Global d=9,f,b,m,n
Global.s c,e="+-<>.,[]",g,h,i,j,l
Macro U
Input()
EndMacro
Macro V
Case
EndMacro
Macro W
EndIf
EndMacro
Macro Z(a)
b=a
Repeat
m+a
n=PeekA(@c+m-1)
b+(n/90)*(92-n)
Until b=0
EndMacro
Macro B(z,o=1)
If o
PrintN(z)
W
Print(#LF$+#LF$+"Press ENTER to exit")
U
End
EndMacro
OpenConsole()
Print("Filename (blank to use std in)...?")
g=U
If g
OpenFile(1,g)
Repeat
i+ReadString(1)
Until Eof(1)
CloseFile(1)
Else
h=U
While h
i+h
h=U
Wend
W
b=0
For m=1 To Len(i)
j=Mid(i,m,1)
If FindString(e,j)
c+j
n=Asc(j)
b+(n/90)*(92-n)
W
Next
If b
B("Uneven brackets")
W
Dim k(d)
For m=1 To Len(c)
Select PeekA(@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)=PeekA(@l)
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(1)
W
V 53
If k(f)
Z(-1)
W
EndSelect
Next
B("",0)
"Menschenskinder, das Niveau dieses Forums singt schon wieder!" — GronkhLP ||| "ich hogffe ihr könnt den fehle endecken" — Marvin133 ||| "Ideoten gibts ..." — computerfreak ||| "Jup, danke. Gruss" — funkheld