RosettaCodeData/Task/Loops-Foreach/FreeBASIC/loops-foreach.basic

19 lines
321 B
Plaintext

' FB 1.05.0
' FreeBASIC doesn't have a foreach loop but it's easy to manufacture one using macros
#Macro ForEach(I, A)
For _i as integer = LBound(A) To UBound(A)
#Define I (A(_i))
#EndMacro
#Define In ,
Dim a(-5 To 5) As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
ForEach(i in a)
Print i; " ";
Next
Print
Sleep