Task

Take a combined set of elements and apply a function to each element.




 
'Task
'Take a combined set of elements and apply a function to each element.
'UDT
Type Friend
    Names As String * 8
    Surnames As String * 8
    Age As Integer
End Type
 
Dim Friends(1 To 6) As Friend
Restore
FillArray
SearchForAdult Friends(), LBound(friends), UBound(friends)
 
End
 
Data "John","Beoz",13,"Will","Strange",22
Data "Arthur","Boile",16,"Peter","Smith",21
Data "Tom","Parker",14,"Tim","Wesson",24
 
Sub FillArray
    Shared Friends() As Friend
    Dim indeX As Integer
    For indeX = LBound(friends) To UBound(friends) Step 1
        Read Friends(indeX).Names, Friends(indeX).Surnames, Friends(indeX).Age
    Next
End Sub
 
Sub SearchForAdult (F() As Friend, Min As Integer, Max As Integer)
    Dim Index As Integer
    Print "Friends with more than 18 years old"
    For Index = Min To Max Step 1
        If F(Index).Age > 18 Then Print F(Index).Names; " "; F(Index).Surnames; " "; F(Index).Age
    Next Index
End Sub
 
 