Jump to content

Archived

This topic is now archived and is closed to further replies.

michaellunsford

code without the text box?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 [nobbc][code][/code][/nobbc] box. It make long lines and long posts much easier to read (IMHO).

Same post in the [nobbc][code][/nobbc]
[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';
?>[/code]


Ken

Share this post


Link to post
Share on other sites
You mean like this?
[code=php:0]<?php
function count_to_one_hundred() {
    for($i=1; $i<=100; $i++) echo "$i<br/>";
}
count_to_one_hundred();
?>[/code]

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

Share this post


Link to post
Share on other sites
if only the code tags would wrap the text. Having to scroll right is very annoying.

Thanks for the info though.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
There's an easy way to post code without using the code box - just use [nobbc][pre][/pre][/nobbc]. 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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.