Function blocks in Editor

Previous topic - Next topic

AndyH

Just a small niggle rather than an issue -

If you declare a FUNCTION that does not start on a line, the Green Bar in the margin of the source code editor that will normally mark the start and end of the function will not register.  Instead, the green bar extends upwards to either the next FUNCTION declaration that is at the start of the line, or the top of the code if there isn't one.  Also the Jumps panel in the editor changes from an F(x) icon to a bullet point.

Similarly, if an ENDFUNCTION is not at the beginning of a line the green bar in the editor margin will ignore it and will extend downwards to the next ENDFUNCTION that starts at the beginning of a line.

EG:

Code (glbasic) Select
FUNCTION foo:
  // this is OK!
ENDFUNCTION


  FUNCTION bar:
  // this FUNCTION is not recognised in the margin of the editor
ENDFUNCTON

FUNCTION doh:
  // this functions ENDFUNCTION is not recognised in the margin of the editor
  ENDFUNCTION

  FUNCTION dohdoh:
    // eek! the solution is to put the FUNCTION and ENDFUNCTION in column 0, the start of every line, no spaces or tabs before
  ENDFUNCTION
The spaces or tabs in front of FUNCTION / ENDFUNCTION's makes the editor not recognise them in the margin color coding.

Moru

Why would you want spaces or tabs before the functions? This is just how I expect the editor to work. If I type a space in front by accident I want to know about it :-)

AndyH

Space is not an invalid character AFAIK.  No big deal, but what if you want to indent your code to help readability?  Eg:  I want to re-use as much code as possible between projects so I use additional source files.  In these files I might make a load of functions I want to re-use.  To keep code as simple as possible, and without overloading a function's contents with 100's of lines of code I make more functions, but many of these I don't want to use or worry about in my main game, they are just there to for that source file.  As GLB does not have any private or protected blocks, and is not OOP, I keep to a naming convention for these private functions.  For readability I can indent them from the left margin so it is clear what they are.

Kitty Hello

Fixed in next update.

bigsofty

Bah, missed my classic Microsoft Quote chance... "Its not a bug, its a feature!" :D
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Schranz0r

;)

like a bluescreen :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard