Wish adding Auto-Comment the library when you declare

Theera

Expert
Licensed User
Longtime User
Is there way typing declare parameter as the library ,also adding auto-comment the used library.When someone read source code ,he will know the library i.e.
B4X:
Sub Process_Globals
   Private usbserial As felUsbSerial  'using felUsbSerial   Lib    <==Adding Auto-comment the used library
   Private manager As UsbManager  '?    <== <==Adding Auto-comment the used library
   Private bc As ByteConverter  'using ByteConverter Lib   <==Adding Auto-comment the used library
End Sub
 
Last edited:

MicroDrie

Well-Known Member
Licensed User
Longtime User
The question is how far you should comment what. It can be useful to provide a B4XPages or module with comments such as the used libraries and versions. Take the variable manager you have chosen for the UsbManager. The usual system is to start a variable with a lowercase letter, so

Self-describing variables:
Private usbManager As UsbManager
Or a shorter version

Self-describing variables:
Private usbMngr As UsbManager
With this notation you explain without explanation what a source code line does. Unless you have a very specific, non-obvious reason, you might want to provide that as an explanatory comment.
 

Theera

Expert
Licensed User
Longtime User
The question is how far you should comment what. It can be useful to provide a B4XPages or module with comments such as the used libraries and versions. Take the variable manager you have chosen for the UsbManager. The usual system is to start a variable with a lowercase letter, so

Self-describing variables:
Private usbManager As UsbManager
Or a shorter version

Self-describing variables:
Private usbMngr As UsbManager
With this notation you explain without explanation what a source code line does. Unless you have a very specific, non-obvious reason, you might want to provide that as an explanatory comment.
The source code is from Erel 's code.
Thread 'felUsbSerial - Alternative Usb Serial library' https://www.b4x.com/android/forum/threads/felusbserial-alternative-usb-serial-library.62216/
 

Theera

Expert
Licensed User
Longtime User
There are many cases where we don't know what method the expert choose from the library.
 

Sagenut

Expert
Licensed User
Longtime User
There are many cases where we don't know what method the expert choose from the library.
Do you mean that you would like to have explanation of methods in your library?
Likethis?
hint.jpg

In this case you just need to write some comment immediately before the Sub in your library code.
B4X:
'Write here what you want to explain for MyFirstMethod
Public Sub MyFirstMethod
    
End Sub

'Write here what you want to explain for MySecondMethod
Public Sub    MySecondMethod
    
End Sub
 

Theera

Expert
Licensed User
Longtime User
Do you mean that you would like to have explanation of methods in your library?
Likethis?
View attachment 161301
In this case you just need to write some comment immediately before the Sub in your library code.
B4X:
'Write here what you want to explain for MyFirstMethod
Public Sub MyFirstMethod
    
End Sub

'Write here what you want to explain for MySecondMethod
Public Sub    MySecondMethod
    
End Sub
Now, from Erel's code. I don't know where
usbmanager come from. ( What is the library name ) If it has comment, I will know to check it.
 

Sagenut

Expert
Licensed User
Longtime User
Now I understand.
Yes, sometimes can be not so clear which libraries have been used.
But usually when checking an example you should see on the Libraries Tab which ones are selected.
It can be more difficult if some Additional Libraries has been used.
 

Theera

Expert
Licensed User
Longtime User
It can be more difficult if some Additional Libraries has been used.
If you can't specify it, At least it should tell all the libies that are used, because it
indicates the scope of which one is likely to be a libary.
 

LucaMs

Expert
Licensed User
Longtime User
Rather than to comment, it would be great if pressing F7 on a class would cause the editor to show the name of the library that provides that class.

For example:
B4X:
Private B4XLoadingIndicator1 As B4XLoadingIndicator

B4XLoadingIndicator is a class from the "XUI Views" library, but there's no way to know that without looking it up on the site (or using @Vader's B4X Object Browser); if when you hover over the name of that class and press F7 a popup would show you which library contains it, that would be pretty helpful.
 
Last edited:
Top