B4J Question Method not appearing in IDE code completion

Squiffy

Active Member
Licensed User
Longtime User
Using 4.70
I have a normal class with the following method :

B4X:
public Sub setHTMLFile(fn As String)
    ...
End Sub

That method does not show in the code completion drop down for the instantiated class, but it does work OK if I call it anyway. That said it doesn't recognise it as a setter any more, I have to call it like this :

B4X:
x.setHTMLFile("hi")

What's the criteria for Subs appearing in the completion drop down? I've seen this before but I can't remember the circumstances surrounding the others. If I set the Sub name to almost anything else it code completes as expected and I can use it as a setter (ie x.HTMLFileName="hi")
 

Squiffy

Active Member
Licensed User
Longtime User
Ahhhh, ok. I have a variable set up in the Class Globals of that name.

So just to be sure - that isn't necessary (or in fact desirable) if I want to use getters & setters.

So is that automatic property class global?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
With this code in the class:
Public Sub setHTMLFile(fn As String)

HTMLFile is condidered as a property, so you call it like this:
x.HTMLFile = "hi"

It appers as HTMLFile in the code completion:
upload_2016-11-17_11-17-24.png



With this code in the class:
Public Sub SetHTMLFile1(fn As String)

SetHTMLFile is condidered as a method, so you call it like this:
x.SetHTMLFile1("hi")
 
Upvote 0

Squiffy

Active Member
Licensed User
Longtime User
Sorry, still slightly confused ...

1. If that's a property, how do I then reference it inside the class itself if it's not declared as a class global? Or do I still have to set a different property with the new value?

2. Klaus - what is the difference in your declarations that makes one a property setter and one a method definition?

EDIT -
If I create a new property called for example pHtmlFile and set or return that in the getter/setter that works.
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Sorry, still slightly confused ...

1. If that's a property, how do I then reference it inside the class itself if it's not declared as a class global? Or do I still have to set a different property with the new value?

2. Klaus - what is the difference in your declarations that makes one a property setter and one a method definition?
2 - the difference is the caps "S" vs "s"...
Lowercase set and get prefixes will be treated as properties, while any other prefix or name will be treated as method
 
Upvote 0
Top