Code blocks (snippets)

Little Cthulhu

Code blocks (snippets)

Hi everybody. 

I'd like to make a request for a forum feature called "code blocks" (or "code snippets"). It is widely used throughout the internet, mostly on programming related sites such as StackOverflow or CodeProject. I'm pretty sure that most users are familiar with this feature, but still give a brief explanation of how it works.

How does it work?

Basically, code snippets allow user to create a block of text with numbered lines (optional) and text appearance formatted according to selected programming language.

For instance, placing a following VB code:

Dim isGoingToVisitCOE2013 As Boolean

isGoingToVisitCOE2013 = true

If (isGoingToVisitCOE2013) Then

    MsgBox "Waiting for you!"

End If

into a code block will turn into the following block when posted: 

1| Dim isGoingToVisitCOE2013 As Boolean
2| isGoingToVisitCOE2013 = true
3| If (isGoingToVisitCOE2013) Then
4|     MsgBox "Waiting for you!"
5| End If

 

Why do we need it?

The problem that we have now is inreadability of code posted as normal text. As for me (and I believe that for almost everyone) the very basics of code formatting are key words tab spacing. It allow to easily distinct user code from standard operators and evaluate overall code structure.

Current formatting features (styles for example) doesn't allow us to quickly format code blocks. As for now reading any reasonable amount of code (more than 10 lines and 2 levels "deep" in fact) is a real challenge. Sure, a code can be copy-pasted to a favourite IDE that will line and highlight everything up, but this is definitely now how you want to read a forum. 

 

To sum up, I am sure that code blocks will make sharing code easier, thus giving us (all users interested in automation and KW-engineering) a boost to share ideas in a more effective way.

 

Thank you for your attention,

LC.

Dave Frank

RE: Code blocks (snippets)
(in response to Little Cthulhu)
Attention COE HQ!
This is the best change for the COE forum ever suggested, IMHO.
Especially if you take into account the traffic on the develop and deploy forum.
Thanks Little for posting.
I'll bet you were in a debugger when you got this idea, from necessity.
I am going to add one additional suggestion, that functions in my postprocessor debugger
Please add +/- functionality to minimize IF--ENDOF/IF couplets. Also CASE, and WHILE, and DO
BEFORE


1| Dim isGoingToVisitCOE2013 As Boolean

2| isGoingToVisitCOE2013 = true

3| If (isGoingToVisitCOE2013) Then

4|     MsgBox "Waiting for you!"

6| ' 

7| ' Some additional comments... to show the effect of minimizing

8| '

9| End If


AFTER



1| Dim isGoingToVisitCOE2013 As Boolean

2| isGoingToVisitCOE2013 = true

3|+If (isGoingToVisitCOE2013) Then  '< Begin with IF

9| End If                           '< END with end if....... see 4-8 are hidden under the +

Best Regards
Dave
Edited By:
Dave Frank[Forrest Machining] @ Nov 22, 2012 - 09:23 AM (America/Pacific)
Dave Frank[Forrest Machining] @ Nov 22, 2012 - 09:27 AM (America/Pacific)

Little Cthulhu

RE: Code blocks (snippets)
(in response to Little Cthulhu)
Great addition, Dave.
Expand-Collapse feature will make code blocks look almost identical to how advanced text/code editors look like. Major improvement without a doubt.

Little Cthulhu

RE: Code blocks (snippets)
(in response to Little Cthulhu)
Any feedback from COE site maintance crew?

Dave Frank

RE: Code blocks (snippets)
(in response to Little Cthulhu)

I spoke with Brian Prasad, the COE learership, and he will support this change.  Lets hope the folks doing the fourm software upgrade can accomidate us.

Dave

Little Cthulhu

RE: Code blocks (snippets)
(in response to Dave Frank)

Bumping this thread as posting code on the forum is a pain. And when I say that I mean "PAIN THAT MAKES YOU WANT TO CLOSE THAT DAMMIT... OH NO DON'T YOU EVER MOVE THAT LINE AGAIN YOU HEAR ME?!"

Come on, folks, it's 2014! Or am I doing something terribly wrong here and just not aware about amazing code formatting features that forum editor provides?