iOS Question Current declaration does not match previous one, how to figure out the cause

mcqueccu

Well-Known Member
Licensed User
Longtime User
What is the Alternative way to figure out the Declaration causing this error.
I started having this error after modifying a project. I did a lot of changes so I could not figure out where the issue is coming from. The project is big with several modules and resources so I could not upload it.

B4X:
Current declaration does not match previous one.
Previous: {Type=Int,Rank=0, RemoteObject=True}
Current: {Type=Float,Rank=0, RemoteObject=True}

Compilation Window:
B4i Version: 8.51
Parsing code.    (0.55s)
Building folders structure.    (0.03s)
Compiling code.    Error
Error compiling program.
Error description: Current declaration does not match previous one.
Previous: {Type=Int,Rank=0, RemoteObject=True}
Current: {Type=Float,Rank=0, RemoteObject=True}
Error occurred on line: 255
Dim BorderWidth As Float = NaObj.GetField("layer").GetField("borderWidth").AsNumber

From the Compilation Window above.
1. I checked all line 255 in all modules, and there is no such Declaration.
2. I did Search and Find for Dim BorderWidth As Float But there is nothing like that in the project
3. I search for Float, I only found dialog.BorderWidth = 0 which is related to B4XDialog. I removed all of them but no result

Any Help is appreciated
 
Solution
Its not Your Views...
With your Help, I was able to narrow it down to this Library AmProgressbutton.

I used the B4XLib in B4A, I forgot its untested in B4i

Looking at the Class (.bas) file. Class Globals Contains this

B4X:
Sub Class_Globals
    Public BorderWidth As Int    '<-----int 
End Sub

Whiles

B4X:
Private Sub SetCircleClip (pnl As B4XView,radius As Int)
#if B4J
    Dim jo As JavaObject = pnl
    Dim shape As JavaObject
    Dim cx As Double = pnl.Width
    Dim cy As Double = pnl.Height
    shape.InitializeNewInstance("javafx.scene.shape.Rectangle", Array(cx, cy))
    If radius > 0 Then
        Dim d As Double = radius...

Daestrum

Expert
Licensed User
Longtime User
That error sounds like you are re-dimming a variable and the new Dim .. AS doesn't match the original one
example
B4X:
Dim A As Int
....
Dim A As Long
Can throw that error.

It looks like an Int is being re-dimmed as a Long.
 
Upvote 1

AnandGupta

Expert
Licensed User
Longtime User
Search for BorderWidth in all your source in the project.
If you find two declaration then you found the error to fix.
If you do not find two declaration then one is most probably in some library.

Change BorderWidth to BorderWidth2 or any other name and then compile.
 
Last edited:
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Dim BorderWidth As Float = NaObj.GetField("layer").GetField("borderWidth").AsNumber
are you using one of these AS_Views?
1715804353361.png
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
Its not Your Views...
With your Help, I was able to narrow it down to this Library AmProgressbutton.

I used the B4XLib in B4A, I forgot its untested in B4i

Looking at the Class (.bas) file. Class Globals Contains this

B4X:
Sub Class_Globals
    Public BorderWidth As Int    '<-----int 
End Sub

Whiles

B4X:
Private Sub SetCircleClip (pnl As B4XView,radius As Int)
#if B4J
    Dim jo As JavaObject = pnl
    Dim shape As JavaObject
    Dim cx As Double = pnl.Width
    Dim cy As Double = pnl.Height
    shape.InitializeNewInstance("javafx.scene.shape.Rectangle", Array(cx, cy))
    If radius > 0 Then
        Dim d As Double = radius
        shape.RunMethod("setArcHeight", Array(d))
        shape.RunMethod("setArcWidth", Array(d))
    End If
    jo.RunMethod("setClip", Array(shape))
#else if B4A
    Dim jo As JavaObject = pnl
    jo.RunMethod("setClipToOutline", Array(True))
    pnl.SetColorAndBorder(pnl.Color,0,0,radius)
    #Else If B4I
    Dim NaObj As NativeObject = pnl
    Dim BorderWidth As Float = NaObj.GetField("layer").GetField("borderWidth").AsNumber '<------------------fLOAT'
    ' *** Get border color ***
    Dim noMe As NativeObject = Me
    Dim BorderUIColor As Int = noMe.UIColorToColor (noMe.RunMethod ("borderColor:", Array (pnl)))
    pnl.SetColorAndBorder(pnl.Color,BorderWidth,BorderUIColor,radius)
#end if
End Sub
 
Upvote 0
Solution
Top