Pflichtfeld Active Member Licensed User Jun 8, 2020 #1 Why do I get error in line 4 : "current delaration does not match previous one" B4X: Copy Private Sub FlipHorizontal(img As B4XView, pkt() As Mypkt ) 'Spiegelt um Senkrechte, mitte img Dim ww as double=img.Width, pp As Mypkt For Each pp In pkt pp.x=ww-pp.x Next End Sub Each element in pkt is a pp, isn't it? If I omit the declaration of pp in line 3 like: B4X: Copy Private Sub FlipHorizontal(img As B4XView, pkt() As Mypkt ) 'Spiegelt um Senkrechte, mitte img 'rückgabe in Pkt Dim ww as double=img.Width For Each pp In pkt pp.x=ww-pp.x Next End Sub I get error in line 5: unknown type: object Can anybody help me to understand?
Why do I get error in line 4 : "current delaration does not match previous one" B4X: Copy Private Sub FlipHorizontal(img As B4XView, pkt() As Mypkt ) 'Spiegelt um Senkrechte, mitte img Dim ww as double=img.Width, pp As Mypkt For Each pp In pkt pp.x=ww-pp.x Next End Sub Each element in pkt is a pp, isn't it? If I omit the declaration of pp in line 3 like: B4X: Copy Private Sub FlipHorizontal(img As B4XView, pkt() As Mypkt ) 'Spiegelt um Senkrechte, mitte img 'rückgabe in Pkt Dim ww as double=img.Width For Each pp In pkt pp.x=ww-pp.x Next End Sub I get error in line 5: unknown type: object Can anybody help me to understand?
OliverA Expert Licensed User Longtime User Jun 8, 2020 #2 Do you have a global variable named pp? Upvote 0
Pflichtfeld Active Member Licensed User Jun 8, 2020 #3 no, but I found the answer: (sorry that I did not search deep enough!) There isn't any decent way to iterate over types fields. Click to expand... Upvote 0
no, but I found the answer: (sorry that I did not search deep enough!) There isn't any decent way to iterate over types fields. Click to expand...
LucaMs Expert Licensed User Longtime User Jun 8, 2020 #4 For Each [VariableName] As [Type] In ... Upvote 0
ilan Expert Licensed User Longtime User Jun 8, 2020 #5 you need to set the type when you do a for each loop, like this: B4X: Copy Dim i(6) As Int = Array As Int(1,2,3,4,5,6) For Each nr As Int In i Log(nr) Next if you have an array with different types you can do something like this: B4X: Copy For Each obj As Object In i If obj Is Int Then Dim nr As Int = obj Log(nr) End If Next Upvote 0
you need to set the type when you do a for each loop, like this: B4X: Copy Dim i(6) As Int = Array As Int(1,2,3,4,5,6) For Each nr As Int In i Log(nr) Next if you have an array with different types you can do something like this: B4X: Copy For Each obj As Object In i If obj Is Int Then Dim nr As Int = obj Log(nr) End If Next
DonManfred Expert Licensed User Longtime User Jun 8, 2020 #6 Pflichtfeld said: Dim ww as double Click to expand... do you have another variable ww (or maybe pp) which is not declared as double resp. declared as any other Type? Last edited: Jun 8, 2020 Upvote 0
Pflichtfeld said: Dim ww as double Click to expand... do you have another variable ww (or maybe pp) which is not declared as double resp. declared as any other Type?
Pflichtfeld Active Member Licensed User Jun 8, 2020 #7 LucaMs said: For Each [VariableName] As [Type] In ... Click to expand... Uups! (not what Erel said...) Thanks! Upvote 0
LucaMs said: For Each [VariableName] As [Type] In ... Click to expand... Uups! (not what Erel said...) Thanks!