Page 1 of 1

"Block" and "EndBlock" keywords to fold "blocks" of code

Posted: Sun Feb 03, 2019 3:56 am
by Charlie
UPDATE: I've got a workaround that seems A-1 (just not sure about impact on compiled code ...); see later in this thread.

Hello,

If SpiderBasic already has a feature that does this kind of thing, please let me know !

I love (LOVE!) folding/collapsible source code.

Would it be possible to add "Block" and "EndBlock" keywords (or something similar) to allow folding of a block of code ?

I'm thinking the compiler could simply ignore these keywords (i.e. the sole purpose of the keywords: visually folding/unfolding blocks of code).

For example: image

Cheers and best regards !

Re: "Block" and "EndBlock" keywords to fold "blocks" of code

Posted: Sun Feb 03, 2019 4:49 am
by poshu
Here I am, traveling through time to add this feature back in SB 1.00!

Code: Select all

;{ FOOOOOOLDING!

;}
And if it's not enough, you can customize folding with keywords in Preferences > Folding

Re: "Block" and "EndBlock" keywords to fold "blocks" of code

Posted: Sun Feb 03, 2019 5:05 am
by Charlie
I was playing around with preferences, happily adding If / EndIf keywords, which is really awesome.

I just went back in and added ";Block" and ";EndBlock", and that works A-1. Thanks !
  • Yup, I had not clued in that we could have "commented text" as keywords
  • The ";)" and ";)" would have been great hints if I had not been overthinking things (I.e. I was thinking they were some kind of special compiler things; face-palm moment)
Aside: Adding more reserved keywords ("Block" and "EndBlock", or anything else) would be bad for anybody who may be using those words in their code for variables, procedures, or anything else. So, let's ignore my initial request.

My workaround

Posted: Sun Feb 03, 2019 6:05 am
by Charlie
Just because I find it easier for these old eyeballs to distinguish blocks of folded code from comments: image
  • Block.i and EndBlock.i : the start and end wrappers for a block of code, setup as variables so they don't cause compilation errors
  • Block and EndBlock: setup as custom keywords and added as folding start/end keywords
Does the trick. (Well, remains to be seen what kind of mess I'm creating in the resulting javascript etc. ...)