Recent

Author Topic: Collapsing large blocks of code?  (Read 2814 times)

QEnnay

  • Full Member
  • ***
  • Posts: 115
Collapsing large blocks of code?
« on: August 11, 2021, 07:39:19 pm »
Hello,

Might be asking the impossible here, but I am wrestling hundreds of lines of code.

Is there a way to collapse large blocks of code in a single Unit/Form?

I have a main-form with a page control and 6-pages, each with hundreds of lines

Is there a way I can collapse all of the code for each page as I complete writing it's functionality? I do not want to use "include" files as that gets cumbersome swapping IDE-tabs.

I know I could include the sub-procedures within "procedure page_1" and collapse it, but then how do I access those internal procedures outside of the main procedure?

From this
Code: Pascal  [Select][+][-]
  1.   case pc_main.ActivePageIndex of
  2.     0 : page_1;
  3.     1 : page_2;
  4.   end;
  5.  
  6. // Page_1
  7. procedure page_1;
  8. begin
  9. end
  10.  
  11. procedure page1_stuff_a;
  12. begin
  13. end;
  14.  
  15. procedure page1_stuff_b;
  16. begin
  17. end;
  18.  
  19. procedure page1_stuff_c;
  20. begin
  21. end;
  22.  
  23. // Page_2
  24. procedure page_2;
  25. begin
  26. end
  27.  
  28. procedure page2_stuff_a;
  29. begin
  30. end;
  31.  
  32. procedure page2_stuff_b;
  33. begin
  34. end;
  35.  
  36. procedure page2_stuff_c;
  37. begin
  38. end;
  39.  
  40.  

To this
Code: Pascal  [Select][+][-]
  1.   case pc_main.ActivePageIndex of
  2.     0 : page_1;
  3.     1 : page_2;
  4.   end;
  5.  
  6. // Page 1
  7. --collapsed
  8.  
  9. // Page 2
  10. --collapsed
  11.  
  12.  
« Last Edit: August 11, 2021, 07:42:38 pm by QEnnay »
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Collapsing large blocks of code?
« Reply #1 on: August 11, 2021, 07:49:22 pm »
Are you familiar with {%region}?
If not, check this link

{%region /fold}:
Quote
if you want the fold to start out collapsed on first loading the file.
« Last Edit: August 11, 2021, 07:59:12 pm by engkin »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Collapsing large blocks of code?
« Reply #2 on: August 11, 2021, 07:55:30 pm »
Also, you might want to know about {$ModeSwitch nestedprocvars}

QEnnay

  • Full Member
  • ***
  • Posts: 115
Re: Collapsing large blocks of code?
« Reply #3 on: August 11, 2021, 09:09:22 pm »
Are you familiar with {%region}?

Nope, I was not, but thanks, that looks exactly what I am after.

I had done quite bit of searching before asking here, but did not think  of using "Fold."

ETA: Thanks that's perfect
« Last Edit: August 11, 2021, 09:19:39 pm by QEnnay »
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

QEnnay

  • Full Member
  • ***
  • Posts: 115
Re: Collapsing large blocks of code?
« Reply #4 on: August 11, 2021, 09:13:20 pm »
Also, you might want to know about {$ModeSwitch nestedprocvars}

Interesting, but as mentioned I will give the "Region" thing a try.
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

 

TinyPortal © 2005-2018