Method Comment Code Assistant

Here’s a script I use to comment on my methods.

function Name() as String
    	Return "Heading Comment"
End Function

Function CanEdit(selection As String) As Boolean
  	Return True
End Function

Function Edit(selection As String) As String
  Dim Lines() As String
  Lines.Add("//************************************************************************************************************\\")
  Lines.Add("// Author      : W Golding                                                                                    \\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("// Date        :                                                                                              \\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("// Description :                                                                                              \\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("//************************************************************************************************************\\")
  Lines.Add("// Modification History                                                                                       \\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("//************************************************************************************************************\\")
  Lines.Add("")
  Lines.Add("")
  Var Result As String = String.FromArray(Lines, EndOfLine)
  Return Result
End Function

You’d obviously change the Author name before use :slight_smile: This results in a comment like

//************************************************************************************************************\\
// Author      : W Golding                                                                                    \\
//                                                                                                            \\
// Date        : 8/4/22                                                                                       \\
//                                                                                                            \\
// Description : This method translates Database Column Types to JSON Safe Xojo Types in a Dictonary          \\
//               based on http://docs.xojo.com/Database.TableColumns from DatabaseRow                         \\
//               DateTime columns are converted to SQLDateTime Strings                                        \\
//               Currency columns are converted to doubles                                                    \\
//                                                                                                            \\
//************************************************************************************************************\\
// Modification History                                                                                       \\
//                                                                                                            \\
//************************************************************************************************************\\

After it’s been updated.

4 Likes

And here’s one to add modification comments.

function Name() as String
    	Return "Modification Comment"
End Function

Function CanEdit(selection As String) As Boolean
  	Return True
End Function

Function Edit(selection As String) As String
  Dim Lines() As String
  Lines.Add("//------------------------------------------------------------------------------------------------------------\\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("// Author  : W Golding                                                                                        \\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("// Date    :                                                                                                   \\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("// Details :                                                                                                  \\")
  Lines.Add("//                                                                                                            \\")
  Lines.Add("")
  Var Result As String = String.FromArray(Lines, EndOfLine)
  Return Result
End Function

Where again you’d change the Author :slight_smile:

5 Likes

Hi Wayne,

I already used (something like) that years ago.

Care to explain what is new ?

PS: the script was storedin my Xojo folder (Applications), and called from a Menu → MenuItem (Scripts, probably).

Hi Emile,

In 22R1 code assistant scripts were introduced which is what these are. You can now contextual click in the code editor and select a script from the menu.

1 Like

For more information have a look at this Blog.

1 Like