Nice neat code posts


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    1,046


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    HTML posting is NOT allowed on the PICBASIC Community Forum, not only because of security issues, but also because we cannot prevent people using MS word to create a document and then posting the garbage Word HTML in the forum...which causes a number of issues that may prevent the post or the forum area from displaying correctly.

    Thus if you wish to post formatted text, you may use the editor and some BB code. All of the articles in the WIKI are produced that way and they are not unreadable.

    Using the built in editor and some BB Code does NOT prevent the creation of clean and readable posts.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Well, if you say so Lester but that's the first time I've heard it's not allowed. There's even been guides on how to do it, here's a thread where one of the moderators explains how to do it (though I don't think Dave was a moderator at the time) and also the code that at the time looked perfect but not any more. And I belive this is the orignal thread.

    I'm not saying it's not possible to create good looking readable code but simply copy and paste from MCSP to within code tags usually doesn't work that well.

    /Henrik.

  3. #3
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    1,046


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    OK, a few posts went through with HTML in them. BUT as the Moderators are aware and a few forum users are aware. there were one or two posts that had really badly bloated and badly formatted HTML in them, that caused the forum pages NOT to load or Crash when viewing those threads.

    HTML will not solve your problem, but WILL definitely allow users to crash certain pages and damage the smooth running of the forum.

    Sorry, but at present i don't have time to produce a tutorial on how to post code examples, formatted with colour. But if you google it you'll see that its quite faesable, if you really have to.

    For sure, I will not enable HTML posting for users, I don't have the time to sort out the issues that will arise !

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Hi Lester,
    No, I'm not particularly interested in the colours and I'm not asking you to enable/allow .html if that's a problem. My point was that many of the posts were they have already been used are no longer readable, like the ones in the thread I linked to. But if they wasn't supposed to be there in the first place then you've made your point.

    Again, I know how to format the code using BB-code but that's just it - simply cut'n'paste well formated code from an editor/IDE to a post usually needs quite a bit of touch-up afterwards. Again, disregard the colours, I'm talking about tabs, blank lines etc. Just what Charles mentioned in his original post. I'm not saying it's yours or the forums fault. I'm, like Charles, asking what's needed to preserve the formatting when copying code into a post.

    /Henrik.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Below is an unedited cut-and-paste from MCS. Even when I go back and try to clean it up, the final results look terrible. I'd post more code if it didn't look so bad.



    Code:
    GetNum:
            Result = 
    0
            MaxNum = 
    5     ; set for max number of digits you will 
    accept
            YY = 
    1
     
    POSN=0
            IsNeg = 
    0
            TimedOut = 
    0
            ArrayWrite InputString,[Rep 
    $FF\8]  ; Fill with 
    $FF
     
    GetMoreN:              
     
            HSERIN 
    9000,InputTimeout,[Keyin]
     
    IF Keyin = ESC THEN 
    ZeroNum
                If 
    Keyin = CR THEN 
    DunInputn
     
    If allowNeg 
    then
                IF 
    Keyin = "-" and Posn = 0 THEN 
     
     
    IsNeg = 
    1
     
    Hserout 
    ["-"]
     
    goto 
    GetMoreN
     
    ENDIF 
     
    endif   
     
                IF Keyin 
    = BS 
    THEN
     
    HSEROUT 
    [BS,SP,BS]
     
    IF POSN > 0 
    THEN
     
    POSN = POSN - 
    1
     
    InputString [POSN] = 
    $FF
     
    GOTO 
    GetMoreN
     
    ENDIF   
     
     
    ENDIF
            IF Keyin < "0" or Keyin 
    > "9" THEN GetMoreN 
            HSEROUT 
    [Keyin]
            InputString [POSN] = Keyin 
    - "0"
            IF POSN >= (MaxNum -1) 
    THEN DunInputN
            POSN = POSN 
    +1
            GOTO 
    GetMoreN
    DunInputN:
            For xN = 7 
    to 0 STEP - 1 
     
    IF InputString[XN]= 255 THEN 
    NoMoreNum
     
    Result = Result + 
    (InputString[xN]*YY)
     
    YY = YY 
    *10
    NoMoreNum:            
     
            Next 
    XN
     
     
            If Isneg 
    then
              If result < 
    32768 
    then
     
    Result = 0 - Result
     
    else
    Charles Linquist

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Charles,

    Attach your code (BAS/PBP) so I can try it if you do not mind.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    I have to agree with others here ...not only posting code snippets can be plain ugly....also reading others' old snippets with with the wrong (now incompatible) formatting renders them virtually unreadable.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts