Wish Generated sub names

Daestrum

Expert
Licensed User
Longtime User
When I write code I tend to write the flow logic before the actual subs to handle the logic

for example

B4X:
...
initializeBoard(w,h)
loadImages()
...

When I get to write the subs, there is no autocompletion for the names I have used.

If you write the subs first then you get autocomplete for the names. ( I don't think many people write the sub's first, as this means you jump up and down the code inserting the sub calls).

Although the names are red as in undefined, could these be added to the autocomplete list so that when you do write the sub, you can just select the name from the list.
 

LucaMs

Expert
Licensed User
Longtime User
Uhm... if you were a bad "writer" then you would have a long list of non-wanted routine names.

I'm thinking to a dialog that appear when you leave the line you are writing which should ask you if you want to create the routine (and if you choose "yes" it is automatically created) but "loadimage()" could be an array, so...!
 

Roycefer

Well-Known Member
Licensed User
Longtime User
I think a better solution would be an additional context menu item (with a keyboard shortcut) that would appear only when some text with red underlining is highlighted that would generate the sub signature. For example:
B4X:
...
Dim num As Int = loadImages(5,"5",5.55)   '<--- initially, this would be underlined with red since it hasn't been defined.
...
...
Sub loadImages(a As Int, b as String, c As Double) As Int   '<---This would be generated (arg and return types inferred from usage) when the new context menu item was selected while the above was highlighted.

End Sub

It would be even cooler if this worked across modules. And speaking of code generation wishes, the generation of getters and setters in classes and static modules would be really handy.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
the generation of getters and setters in classes and static modules would be really handy.
I don't like the generated getters and setters. Make the variables public instead. If at some point later you want to add logic then change the variable name (use F7) and add the properties.

There are cases where it makes sense to add properties without logic but these are not the default cases.
 

Daestrum

Expert
Licensed User
Longtime User
With respect to @LucaMs and @Roycefer I never asked about getters and setters, so I am still none the wiser as to if my original question is feasible.
 

LucaMs

Expert
Licensed User
Longtime User
I'm not sure how many developers write their code this way
Me (I don't know if often); but I write in a similar way also modules variables, so I write a name (routine or variable), double click, CTRL+C, go to Globals or my region "Methods", CTRL+V :).

Everything is possible. It is not a simple feature to implement
I agree. It would be (maybe) more easy to add a menu item like "Add a routine", showing a dialog to input the name of the routine (eventually also parameters) but I think I can write all in less time :)
 
Top