Page 1 of 2

[Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 11:10 am
by Dude
I hate pressing F2 to jump to bookmarked procedures of my sources. It's okay, but I'm often hitting F2 repeatedly until I get to the procedure that I want. Not fun.

Since I knew we can hold down Ctrl and DoubleClick a procedure name to immediately jump to it, it suddenly hit me today that why not make an "index" of procedure names at the top of my source so that I can Ctrl+DoubleClick to them quickly? I tried this with comments at first, but comments can't be clicked that way, so I did it with a section of code that isn't compiled into your exe when built. It's as simple as this:

Code: Select all

CompilerIf 0 ; This block not compiled into the exe. :)
  GlobalVars() : MainLoop() : Tweaks() : QuitApp()
  LoadSettings() : SaveSettings() : Screenshot()
CompilerEndIf
Now when my source loads, I can immediately Ctrl+DoubleClick any procedure to jump right to it. 8) Same if I'm elsewhere in the middle of my source: I just press Ctrl+Home to go to the top of my source, and Ctrl+DoubleClick a procedure name again. This has made my source navigation to my procedures so much more convenient than hitting F2 to find them.

You can even "bookmark" non-procedure parts of your source with procedure names that never get compiled:

Code: Select all

CompilerIf 0
  Procedure GlobalVars() ; Fake procedure to jump to global vars quickly. ;)
  EndProcedure
CompilerEndIf
Global who,why,what,when,where,etc...
Hope this tip helps someone else. :)

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 11:23 am
by Marc56us
Personally I use the "Procedure Browser" panel and I tell him to also put the "Issues" (ie: Todo, bugfix etc.).
A simple click on right panel automatically takes me to all the procedures and things "to do", "to fix".

IDE configuration to do this:

:arrow: Preference > ToolsPanel > add Procedure Browser

And to see in this panel "Todo, Bug, Info etc"
:arrow: Preference > Issues > ... (keyword) [X] Show in procedure browser

+ When running in project mode, all procedures and issues of the project are listed in the same panel.

:wink:

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 11:31 am
by TI-994A
Dude wrote:...we can hold down Ctrl and DoubleClick a procedure name to immediately jump to it, it suddenly hit me today that why not make an "index" of procedure names at the top of my source so that I can Ctrl+DoubleClick to them quickly?
Thanks for the tip; very resourceful.

Just curious though; why not just use the IDE's built-in Procedure Browser?

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 11:31 am
by Dude
Marc56us wrote:Personally I use the "Procedure Browser" panel
The "Procedure Browser" panel is good for short sources, but my source has over 200 procedures and so my panel is very, very long... way too long to bother scrolling through to find a single procedure name in the middle of that large haystack.

And as I pointed out, it's also good for instantly jumping to non-procedure code too, like a global var block (which wouldn't appear in the "Procedure Browser").

That's why my tip came about. ;)

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 11:34 am
by Everything
Declare will do the same thing as your snippet, but still nice trick, thx!

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 11:37 am
by Dude
Everything wrote:Declare will do the same thing as your snippet.
Nope, because then you need to declare all the procedure parameters as well, instead of just the name. ;)

And you can't use Declare for the second purpose of my tip, which is to instantly jump to non-procedure sections of code.

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 11:41 am
by Everything
Dude wrote:you need to declare all the procedure parameters as well
That's true, however if you declare procedures anyway (if you do) than you can use declare block fore same purposes.

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 12:01 pm
by Dude
Declare is ugly:

Code: Select all

Declare ResetSettings(file$,forfiles=1,forkeys=0,forimages=0) : Declare LoadSettings(file$) : Declare SaveSettings(file$)

Procedure ResetSettings(file$,forfiles=1,forkeys=0,forimages=0)
EndProcedure

Procedure LoadSettings(file$)
EndProcedure

Procedure SaveSettings(file$)
EndProcedure
Compare the above to my tip:

Code: Select all

CompilerIf 0
  ResetSettings() : LoadSettings() : SaveSettings()
CompilerEndIf

Procedure ResetSettings(file$,forfiles=1,forkeys=0,forimages=0)
EndProcedure

Procedure LoadSettings(file$)
EndProcedure

Procedure SaveSettings(file$)
EndProcedure
And trying to make it "neater" with one Declare per line means you run into the same problem as the "Procedure Browser": scrolling in your Declare block to find the procedure name. With over 200 procedures, this is no better than just using the browser.

With my tip, no scrolling is needed, and you can also instantly jump to non-procedure sections of code. ;)

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 12:47 pm
by davido
@Dude,
Took me a while to see the merit in your idea. :oops:

I always have my Declares at the top of the code and add to them as Procedures are added.
So I did not think much of the idea - until I tried it out.

So far I have tried:
1. Grouping Procedures
2. Shortening names
3. Using comments to make sense of the shortened names.

I think it can only get better as I use it.

Great Idea, in my humble opinion. :D

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 1:03 pm
by HanPBF
viewtopic.php?f=18&t=65794

Did not read the details (of both threads :?).

It's all about organizing source code and lacking features in an editor.

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 1:41 pm
by Marc56us
If you do not want Procedures Browser, uses issues (notes) as markers then show issue browser as floatting window or in panel.
Double-click go to line immediatly

PB help
Image

Personally I put markers on the important sections (Enumeration, Initialization, Main loop, Include and of course Todo and Bug to fix)

The other interest is that the markers of all open files or projects are visible in the same window

PB IDE is simple but does everything.

:wink:

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 1:42 pm
by Dude
I never saw that post before (2.5 years ago). Same concept, different layout. But yes, HanPBF did it first. :)

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 1:48 pm
by Dude
Marc56us, you're missing the point. Issues doesn't do what this tip does at all because the tip is to not have to scroll through a very long list to find what you want, and neither is the tip to mark anything like you do with the Issues tool (otherwise I'd just use F2 again to set bookmarks).

And like I said, it's quicker to just press Ctrl+Home to go to the top of my source and Ctrl+DoubleClick a procedure name, than to click the Tools menu, select "Issues Browser", then scroll through 200+ procedure "issues" to find the one you want. ;)

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 4:27 pm
by Bisonte
Dude wrote:And as I pointed out, it's also good for instantly jumping to non-procedure code too, like a global var block (which wouldn't appear in the "Procedure Browser").

That's why my tip came about. ;)
Not really true.

Code: Select all

Procedure Foo()
EndProcedure

;- Var Block
Will show in the procedure browser

Code: Select all

Foo()
> Var Block

Re: [Tip] Procedure "index" at the top of your source

Posted: Sat Dec 29, 2018 4:28 pm
by skywalk
Nice trick, but still a lot of dead typing.
Using the Procedure Browser is limited, but better than nothing.
Naming conventions help and I add a ";-!" suffix to important areas of code.
These appear at the top of the Procedure Browser and in alphabetic order if selected in preferences.

How do you get the Issue Browser as a floating window? :shock: