REQUEST: FUNCTION header and trailer

Make a request or discuss new features.
Post Reply
User avatar
yereverluvinuncleber
Posts: 247
Joined: 20 Apr 2018 09:49

REQUEST: FUNCTION header and trailer

Post by yereverluvinuncleber » 10 Jun 2019 21:41

This may already be in the product already but I haven't seen it.

A useful addition would be the automatic addition of custom header and trailers to functions/ subroutines.

I might add my own custom header code:

Code: Select all

'---------------------------------------------------------------------------------------
' Procedure : functionName
' Author    : 
' Date      : 30/05/2019
' Purpose   : 
'---------------------------------------------------------------------------------------
'Private Sub functionName()
   On Error GoTo functionName_Error
This would be inserted above the current function being edited and the actual function name would be automatically inserted wherever functionName is encountered.

Same with a custom trailer:

Code: Select all

   On Error GoTo 0
   Exit Sub

btnRefresh_Click_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure functionName"
I would assume the date would be filled in automatically too.

So, a typical function might end up looking like this:

Code: Select all

'---------------------------------------------------------------------------------------
' Procedure : btnRefresh_Click
' Author    : beededea
' Date      : 30/05/2019
' Purpose   : refresh the file or thumbnail display
'---------------------------------------------------------------------------------------
'
Private Sub btnRefresh_Click()
   On Error GoTo btnRefresh_Click_Error

        filesIconList.Refresh
        
        If picFrameThumbs.Visible = True Then
            populateThumbnails (thumbImageSize)
            picFrameThumbs.SetFocus
        Else
            filesIconList.SetFocus
        End If

   On Error GoTo 0
   Exit Sub

btnRefresh_Click_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnRefresh_Click "
End Sub
This would be a useful addition to allow easy commenting and information for each function. I have this on other IDEs already and miss it when editing using RjTextEd. If it is already present do let me know.
Noli pati a scelestis opprimi...

You can find me on Deviantart https://www.deviantart.com/yereverluvinuncleber/gallery/

User avatar
Rickard Johansson
Site Admin
Posts: 5807
Joined: 19 Jul 2006 14:29

Re: REQUEST: FUNCTION header and trailer

Post by Rickard Johansson » 11 Jun 2019 10:26

You could use abbreviations. E.g. take a lock at the PHP func abbreviation in the text clips panel. You would have to create your own, of course.

1. Select the "Abbreviation" tree item.
2. Click on "New folder" and select highlighter.
3. Add your own abbreviations. Lock at some existing to see how to do it.

You may also want to allow TAB as a trigger in "Format->Abbreviations->Allow trigger keys".

So, if you name your abbreviation to "proc", type "proc" and hit TAB - the full code you entered should expand with tab point you've set.

User avatar
yereverluvinuncleber
Posts: 247
Joined: 20 Apr 2018 09:49

Re: REQUEST: FUNCTION header and trailer

Post by yereverluvinuncleber » 11 Jun 2019 11:52

I will try that. Thankyou.

I still think a purposely-designed function wrapper for header and trailer for comments, author and date would be a 'nice to have' as a function in itself.

I will look at your suggestion and see if I can make it work the way I want it to and give feedback later.
Noli pati a scelestis opprimi...

You can find me on Deviantart https://www.deviantart.com/yereverluvinuncleber/gallery/

Post Reply