Android Question Can You Display the Content of a Documentation Code Module on a Label

Mahares

Expert
Licensed User
Longtime User
I have the following code module called: MyComments. Can you show its content on a label or an editText from another module?
B4X:
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
End Sub

#If DOCUMENTATION
    This project is based on Peter Simpson great and simple Image Picker library he designed on 9/29/2018
    The link for his lib is:
    https://b4x.com/android/forum/threads/preview-image-picker.97710/#post-616023
    He revised it to version 1.04 on 10/1/2018
#End If
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Yes:
B4X:
Sub Process_Globals
Dim text As String = $"This project is based on Peter Simpson great and simple Image Picker library he designed on 9/29/2018
    The link for his lib is:
    https://b4x.com/android/forum/threads/preview-image-picker.97710/#post-616023
    He revised it to version 1.04 on 10/1/2018
"$
End Sub

Log(Documentation.text)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
But your code shows that I have to rewrite the entire content between #if DOCUMENTATION and #End If to the text string. That is doing double work. I want to be able to display the text that exists between the #if and #End If. Is that possible?
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
But your code shows that I have to rewrite the entire content between #if DOCUMENTATION and #End If to the text string. That is doing double work.

While I can't answer your question, I can give you a PROTIP that you can use in many different situations when using your computer. Because if you're rewriting it, you're doing it wrong.

PROTIP: You can copy text with control-c and paste it with control-v.

;-)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
PROTIP: You can copy text with control-c and paste it with control-v
I am very familiar with the cut and paste. I have been around for a while. What I meant in my post is : I do not want to display the text twice in the code module, because the code that Erel posted shows that is the way it needs to be done.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The point is that the #IF DOCUMENTATION directive will exclude the text from being compiled to the final program, so if you want to display it you need to set out your documentation module differently.

As Erel suggested you would use a variable (or multiple) to store your text. And you could be creative if you want to produce printed documentation from it.

B4X:
'Static code module
Sub Process_Globals
    Private fx As JFX

    Private mDescription As String = _
$"DESCRIPTION
    This project is based on Peter Simpson great and simple Image Picker library he designed on 9/29/2018
    The link for his lib is:
    https://b4x.com/android/forum/threads/preview-image-picker.97710/#post-616023
    He revised it to version 1.04 on 10/1/2018
"$

Private mTODO As String = _
$"TODO :

    Task1
        Do something   
    Task2
        Something else
"$
End Sub


Public Sub All As String
    Return mDescription & CRLF & mTODO
End Sub

Public Sub getDescription As String
    Return mDescription
End Sub

Public Sub ToDo As String
    Return mTODO
End Sub

Also be aware that if this is in a library, you won't be able to exclude the module from the Library if it is accessed, therefore you may need to name the module so it doesn't clash with modules in other libraries that may be included in the app.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The point is that the #IF DOCUMENTATION directive will exclude the text from being compiled to the final program
I did not know that anything between #IF DOCUMENTATION and #End If is excluded from compilation in a B4A project. Obviously, what I was after is not doable unless I assign a variable to the entire or portion of the documentation.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Mahares

Expert
Licensed User
Longtime User
It is only included if you Build the Buildconfiguration DOCUMENTATION.
Suppose I create a build config to include the DOCUMENTATION code module in the compilation. what good does it do me to compile it if I still have to assign a string variable to the text between #IF DOCUMENTATION and #End If, or is it possible to display it without having the text string shown twice in the code module.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
It will take you 2 minutes (maybe less) t
That is true. I just wanted to avoid duplicating text in the same module. In this case where one wants to display or save the documentation, there is absolutely no reason to have an #If DOCUMENTATION block. A smart string wrapper of the docs is sufficient.
 
Upvote 0
Top