Using Code posted in these forums

  • I see that there is a forum etiquete article that gives some great examples of how to post code.

    However, my question is in the opposite direction. It would seem that once I copy and paste code from the forum into an editor such as QA or Slick Edit or notepad etc... all the formatting including CR/LF pairs is removed.

    I assume that it is I who is doing something wrong what's the trick?

  • I think the developers are working on that. It has been that way since the last upgrade. If you paste them into ms word and then into QA they seem to keep most of the formatting.


  • Until they fix it, there's a work around...

    1. Put your cursor one line above the code box.

    2. Click and drag to one line below the code box.

    3. Copy

    4. Open MS Word

    5. Paste

    6. Do a Search'n'Replace... replace ^l (Circumflex followed by lower case "L") with ^p (Circumflex followed by lower case "P).

    7. Select all and copy.

    8. Paste into Query Analyzer. All formatting is preserved.

    And thanks for the compliment on the article.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks! That seems to work. What are these RTF codes for hard and soft return?

  • Hard returns are CHAR(13)... Soft returns are actually vertical tabs (CHAR(11))... if that's what you meant...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • That's what I mean, however, that is not what we are looking at are we? I guess ms word and the rich text edit control or whatever control being used is not ascii.

    ^i = ascii(9) - tab

    ^j = ascii(10) - linefeed

    ^k = ascii(11) -vert tab

    ^l = ascii(12) -form feed (new page) ???soft return

    ^m = ascii(13)-carriage return

    ^p = ascii(16) -data link escape ???hard return

    None of this really matters, as long as it works! 🙂

    Just observations.

  • Heh... no, not what we're looking at in Word... Yes, I understand the control character notation for things like ^m (ASCII 13 or Hex OD)... Word seems to have it's own bit of notation... the "L" in ^l is supposed to be for soft Line and the "P" in ^p is supposed to be for Paragraph... supposed memory aids for the ASCII uninitiated.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • How many M$ employees does it take to change a lightbulb....

    None, they just declare darkness to be the standard.

    🙂

    Silly me, assuming again...

  • Microsoft still uses lightbulbs? 😛 I heard they couldn't find anyone who still knew how, so they've shifted to HI-LEDs that never need changing.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (12/27/2007)


    Until they fix it, there's a work around...

    1. Put your cursor one line above the code box.

    2. Click and drag to one line below the code box.

    3. Copy

    4. Open MS Word

    5. Paste

    6. Do a Search'n'Replace... replace ^l (Circumflex followed by lower case "L") with ^p (Circumflex followed by lower case "P).

    7. Select all and copy.

    8. Paste into Query Analyzer. All formatting is preserved.

    And thanks for the compliment on the article.

    And if the code is posted in a forum, click reply with quote ;copy the code and paste it in QA


    Madhivanan

    Failing to plan is Planning to fail

  • Jeff Moden (12/27/2007)


    Microsoft still uses lightbulbs? 😛 I heard they couldn't find anyone who still knew how, so they've shifted to HI-LEDs that never need changing.

    I heard that they are all so bright there that they don't need external light sources. :w00t: (Boo! Hiss! Yeah, I know.)

  • Heh... yeah... so they would say! After seeing the cruddy stored procedures they wrote (like sp_SpacedUsed, for example), it must be a "black light" 😛

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply