It is currently Fri Jul 19, 2019 6:54 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 11:10 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
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:
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:
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. :)


Last edited by Dude on Sat Dec 29, 2018 12:33 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 11:23 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 625
Location: France
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:


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 11:31 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2213
Location: Singapore
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?

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 11:31 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
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. ;)


Last edited by Dude on Sat Dec 29, 2018 11:39 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 11:34 am 
Offline
User
User

Joined: Sat Jul 07, 2018 6:50 pm
Posts: 11
Declare will do the same thing as your snippet, but still nice trick, thx!


Last edited by Everything on Sat Dec 29, 2018 11:37 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 11:37 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 11:41 am 
Offline
User
User

Joined: Sat Jul 07, 2018 6:50 pm
Posts: 11
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 12:01 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
Declare is ugly:

Code:
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:
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. ;)


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 12:47 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1660
Location: Uttoxeter, UK
@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

_________________
DE AA EB


Last edited by davido on Sat Dec 29, 2018 4:52 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 1:03 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 19, 2010 3:42 am
Posts: 529
https://www.purebasic.fr/english/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.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 1:41 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 625
Location: France
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:


Last edited by Marc56us on Sat Dec 29, 2018 2:48 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 1:42 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
HanPBF wrote:

I never saw that post before (2.5 years ago). Same concept, different layout. But yes, HanPBF did it first. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 1:48 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
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. ;)


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 4:27 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1063
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:
Procedure Foo()
EndProcedure

;- Var Block


Will show in the procedure browser
Code:
Foo()
> Var Block

_________________
PureBasic 5.70 LTS (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: [Tip] Procedure "index" at the top of your source
PostPosted: Sat Dec 29, 2018 4:28 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2967
Location: Boston, MA
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:

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye