Jump to content


Photo

code without the text box?


  • Please log in to reply
5 replies to this topic

#1 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 29 July 2006 - 03:39 AM

I've seen a few folks post code without the dreaded text box -- like the old forum would let you do. I really hate having to scroll in that little box -- especially left and right. How is this posting method done?

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 29 July 2006 - 12:59 PM

You just post your code starting with "<?php" if it's php like this:

<?php
    session_start();
    $just = 'showing an example';
    $of = 'posting without a code box';
    $but = 'there is a problem<br>when trying to post<br>tags';
?>

My own preference is to see all posts in a [code][/code] box. It make long lines and long posts much easier to read (IMHO).

Same post in the [code]
<?php
    session_start();
    $just = 'showing an example';
    $of = 'posting without a code box';
    $but = 'there is a problem<br>when trying to post<br>tags';
?>


Ken

#3 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 29 July 2006 - 04:40 PM

You mean like this?
<?php
function count_to_one_hundred() {
    for($i=1; $i<=100; $i++) echo "$i<br/>";
}
count_to_one_hundred();
?>

You just enclose your code in [php][/php] tags. Although, I too would prefer to see code within the [code] tags, mainly because I prefer to read code with fixed width characters. It looks neater that way.

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 29 July 2006 - 08:32 PM

if only the code tags would wrap the text. Having to scroll right is very annoying.

Thanks for the info though.

#5 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 30 July 2006 - 07:37 PM

i imagine there's a good reason it doesn't scroll the text, and that's because if it did so it would be a pain in the *insert body part of choice here* for us to count the lines (god forbid someone actually tell us what line x is).

#6 Oldiesmann

Oldiesmann
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationCincinnati, Ohio

Posted 04 August 2006 - 02:02 PM

There's an easy way to post code without using the code box - just use [pre][/pre]. This will preserve spacing/formatting and also display things in an easy-to-read fixed-width font. If you do this though, you should also make sure to select the "Don't use smileys." option under "Additional options..." on the main post screen so that your code won't end up having smileys scattered throughout it.

The horizontal scrolling is done to prevent extra-wide code from stretching out the rest of the page, which is really annoying, especially for those using the dreaded 800x600 resolution...

As akitchin stated, word-wrapping within the code box would make things extremely difficult to read and would make it hard to find specific lines without copying the code and pasting it into notepad or another text editor.
The Oldiesmann
SMF Project Manager
SMF+Gallery2 - Beta3.1 now available




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users