Code Blocks

Discussion in 'Feedback and Suggestions' started by joeyd999, Jan 2, 2015.

  1. joeyd999

    Thread Starter AAC Fanatic!

    Jun 6, 2011
    2,675
    2,723
    Am I doing something wrong? Why are tabs in code blocks now being converted to spaces? The result is no better than if I didn't use code blocks at all. For instance, code I just posted on another thread:

    Code (Text):
    1.  
    2. txdata    lfsr    0,array            ;point to array of data
    3.  
    4.     movlw    low (-bytecount)    ;load number of bytes to send
    5.     movwf    bytectr
    6.     movlw    high (-bytecount)
    7.     movwf    bytectr+1
    8.  
    9. dobyte    movlw    4        ;send 4 doublets per byte
    10.     movwf    dblctr
    11.  
    12. dublet    rlncf    indf0,f        ;simultaneously shift bytes,
    13.     rlncf    indf0,f        ;   and multiply least 2 by 4 for jump
    14.  
    15.     movf    indf0,w        ;bits 2 & 3 are important
    16.     andlw    b'1100'        ;mask them
    17.     addwf    pcl,f        ;and use as index into jump table
    18.  
    19. c00    movlw    b'00001000'    ;code for doublet '00'
    20.     bra    load
    21.  
    22. c01    movlw    b'00001111'    ;code for doublet '01'
    23.     bra    load
    24.  
    25. c10    movlw    b'11101000'    ;code for doublet '10'
    26.     bra    load
    27.  
    28. c11    movlw    b'11101111'    ;code for doublet '11'
    29.     bra    load
    30.  
    31. load    btfss    pir1,txif    ;txreg empty?
    32.     bra    load        ;  no, wait
    33.  
    34.     movwf    txreg        ;yes, send new code
    35.  
    36.     decfsz    dblctr,f    ;all doublets done?
    37.     bra    dublet        ;no, do more
    38.  
    39.     movf    postinc0,f    ;point to next byte
    40.  
    41.     incfsz    bytectr,f    ;do for all bytes
    42.     bra    dobyte
    43.     incfsz    bytectr+1,f
    44.     bra    dobyte
    45.  
    46.     return            ;done.
    47.  
    48.  
    There were tabs, now they're spaces!
     
  2. joeyd999

    Thread Starter AAC Fanatic!

    Jun 6, 2011
    2,675
    2,723
    I'm gonna try something different here:

    Code (Text):
    1.  
    2.  
    3. txdata  lfsr    0,array         ;point to array of data
    4.  
    5.     movlw   low (-bytecount)    ;load number of bytes to send
    6.     movwf   bytectr
    7.     movlw   high (-bytecount)
    8.     movwf   bytectr+1
    9.  
    10. dobyte  movlw   4       ;send 4 doublets per byte
    11.     movwf   dblctr
    12.  
    13. dublet  rlncf   indf0,f     ;simultaneously shift bytes,
    14.     rlncf   indf0,f     ;   and multiply least 2 by 4 for jump
    15.  
    16.     movf    indf0,w     ;bits 2 & 3 are important
    17.     andlw   b'1100'     ;mask them
    18.     addwf   pcl,f       ;and use as index into jump table
    19.  
    20. c00 movlw   b'00001000' ;code for doublet '00'
    21.     bra load
    22.  
    23. c01 movlw   b'00001111' ;code for doublet '01'
    24.     bra load
    25.  
    26. c10 movlw   b'11101000' ;code for doublet '10'
    27.     bra load
    28.  
    29. c11 movlw   b'11101111' ;code for doublet '11'
    30.     bra load
    31.  
    32. load    btfss   pir1,txif   ;txreg empty?
    33.     bra load        ;  no, wait
    34.  
    35.     movwf   txreg       ;yes, send new code
    36.  
    37.     decfsz  dblctr,f    ;all doublets done?
    38.     bra dublet      ;no, do more
    39.  
    40.     movf    postinc0,f  ;point to next byte
    41.  
    42.     incfsz  bytectr,f   ;do for all bytes
    43.     bra dobyte
    44.     incfsz  bytectr+1,f
    45.     bra dobyte
    46.  
    47.     return          ;done.
    48.  
    49.  
     
  3. joeyd999

    Thread Starter AAC Fanatic!

    Jun 6, 2011
    2,675
    2,723
    Aha!

    If you use the BB Code Editor, it keeps the tabs, *but* only if you don't click the More Options... button to preview your work.

    This is a major bug, I think. Please fix it.
     
  4. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,535
    Good to know. Thanks for passing it on.

    I suspect this is a fundamental bug, one the authors of the site software has to fix.
     
  5. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,677
    899
    Posting code does appear to be a little messed up. Years ago, Pommie posted a little application called CodeTidy on ETO and AAC and perhaps some other sites as well. It gives the choice of inserting spaces or tabs. I usually uses "spaces" both with CideTidy and MPLab. Anyway, it has worked for me. I tried it this morning and here is what it did in testing:
    upload_2015-1-3_6-17-5.png

    I can assure you that I double checked where my code tags were, and the close tag was after the "done", but yet those five lines of code were not included in the preview. I didn't try posting to see what would happen.

    On a second and related item, I searched for CodeTidy and variations of that by Pommie and found no posts here. Here is a link to his application on ETO: http://www.electro-tech-online.com/threads/pic-code-tidier-mkii.39820/#post-317307 My version was first downloaded/installed on 5/22/08, so it may be that MarkII version; although, "MkII" does not appear in its name.

    Maybe if Pommie sees this, he will re-post it on AAC.

    Regards, John
     
  6. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    I've also found that the editor is very poor in several regards. With the VB code I could copy something from a text file and paste it between CODE tags and the result was pretty predictable and satisfactory. Not even close here. I, too, have found that previewing something can mess things up and so I end up having to post it and then edit it and that is both inefficient and also exposes posts to being viewed by others before I am ready to have them seen.
     
Loading...