Wrapping code


Closed Thread
Results 1 to 14 of 14

Thread: Wrapping code

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425

    Default Wrapping code

    If I have a line of code that's 150 characters long, is there a way to continue that code onto the next line so all of the code can be viewed on my screen without scrolling to the right?

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    Hi there,

    yes there is...

    just use the _ to break the line.

    Check this example:

    Code:
    Lookup y, [$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$10,$08,$00,$00,$00,$00,$80,$80,$90,$00,$20,$1C,$2C,$30,_
    $18,$18,$1C,$1C,$3E,$2E,$2A,$08,$2C,$10,$18,$18,$08,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$F0,_
    $F0,$02,$02,$04,$04,$04,$04,$00,$00,$00,$00,$00,$01,$00,$00,$00,_
    $00,$00,$00,$00,$00,$80,$80,$80,$80,$40,$40,$40,$20,$20,$10,$10,_
    $10,$08,$88,$88,$4C,$44,$C4,$A4,$02,$00,$00,$00,$FC,$8C,$C4,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$20,$68,$68,$38,$00,$00,$00,$00,$00,$E0,_
    $20,$10,$B0,$68,$C8,$00,$00,$80,$30,$C8,$08,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$FE,$01,$11,$C1,$A8,$88,$88,$54,$D4,$00,$00,_
    $00,$00,$00,$00,$00,$00,$02,$14,$01,$0D,$0A,$6A,$10,$00,$00,$00,_
    $F7,$39,$18,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$4E,_
    $00,$00,$00,$03,$EE,$01,$01,$03,$01,$F3,$45,$C3,$60,$D7,$BE,$46,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$3F,$00,$14,$2C,$8A,$4A,$56,_
    $19,$06,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$02,$0C,$02,$00,_
    $00,$80,$00,$00,$02,$01,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$80,$00,_
    $80,$80,$00,$31,$00,$00,$00,$00,$FF,$00,$00,$00,$00,$DE,$39,$38,_
    $08,$6B,$FC,$32,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$02,$01,$00,$00,$00,$00,$00,$00,$80,$80,$40,$40,$40,$20,$20,_
    $20,$10,$10,$18,$08,$04,$05,$01,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$02,$05,$06,$03,$00,$00,$08,$10,$10,$20,$20,$20,$24,$56,_
    $5C,$80,$80,$81,$83,$89,$00,$00,$00,$00,$80,$C0,$50,$48,$28,$2C,_
    $12,$12,$10,$08,$08,$08,$04,$04,$02,$02,$03,$01,$01,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00] ,LcdReg
    regards
    Rui

  3. #3
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    Quote Originally Posted by ruijc View Post
    Hi there,

    yes there is...

    just use the _ to break the line.

    Check this example:

    Code:
    Lookup y, [$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$10,$08,$00,$00,$00,$00,$80,$80,$90,$00,$20,$1C,$2C,$30,_
    $18,$18,$1C,$1C,$3E,$2E,$2A,$08,$2C,$10,$18,$18,$08,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$F0,_
    $F0,$02,$02,$04,$04,$04,$04,$00,$00,$00,$00,$00,$01,$00,$00,$00,_
    $00,$00,$00,$00,$00,$80,$80,$80,$80,$40,$40,$40,$20,$20,$10,$10,_
    $10,$08,$88,$88,$4C,$44,$C4,$A4,$02,$00,$00,$00,$FC,$8C,$C4,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$20,$68,$68,$38,$00,$00,$00,$00,$00,$E0,_
    $20,$10,$B0,$68,$C8,$00,$00,$80,$30,$C8,$08,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$FE,$01,$11,$C1,$A8,$88,$88,$54,$D4,$00,$00,_
    $00,$00,$00,$00,$00,$00,$02,$14,$01,$0D,$0A,$6A,$10,$00,$00,$00,_
    $F7,$39,$18,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$4E,_
    $00,$00,$00,$03,$EE,$01,$01,$03,$01,$F3,$45,$C3,$60,$D7,$BE,$46,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$3F,$00,$14,$2C,$8A,$4A,$56,_
    $19,$06,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$02,$0C,$02,$00,_
    $00,$80,$00,$00,$02,$01,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$80,$00,_
    $80,$80,$00,$31,$00,$00,$00,$00,$FF,$00,$00,$00,$00,$DE,$39,$38,_
    $08,$6B,$FC,$32,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$02,$01,$00,$00,$00,$00,$00,$00,$80,$80,$40,$40,$40,$20,$20,_
    $20,$10,$10,$18,$08,$04,$05,$01,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$02,$05,$06,$03,$00,$00,$08,$10,$10,$20,$20,$20,$24,$56,_
    $5C,$80,$80,$81,$83,$89,$00,$00,$00,$00,$80,$C0,$50,$48,$28,$2C,_
    $12,$12,$10,$08,$08,$08,$04,$04,$02,$02,$03,$01,$01,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
    $00,$00,$00,$00,$00,$00,$00,$00] ,LcdReg
    regards
    Rui
    I'm not sure that works on anything other than the example.

    Norm

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    Quote Originally Posted by Normnet View Post
    I'm not sure that works on anything other than the example.

    Norm
    Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?
    DT

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    I thought the maximum allowed number of constants for LOOKUP was 255, it looks to be way more than that it the list - has that changed?
    Never the less, it does show the "line continuation".

    /Henrik.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    OK, I'll do my best to clarify that myself.....
    Previously the limit was 255 or 256 but in version 2.5C the limit for PIC18 parts was increased to 1024 entities. The PBP3 manual (which of course is the correct place to look when in doubt) says 1024 for PIC18 parts while the online help in MCSP 5.0.0.3 doesn't mention that, it says 256 for 18C parts though.

    /Henrik.

  7. #7
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    Quote Originally Posted by Darrel Taylor View Post
    Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?
    While the manual doesn't say a lot about how to use the line extension character, from experience you need to extend from an operator and not just anywhere in the line.
    For example:
    myvariable31 = myvariable1 + myvariable2 + myvariable3 +_
    myvariable4 + myvariable5
    should work.

    However;
    myvariable31 = myvariable1 + myvariable2 + myvar_
    iable3 + myvariable4 + myvariable5
    will not.

    It's called a line extension, but it's really statement extension to include terms and operators on the following line. You can't just jam it anywhere in the line of text and have the next line pick up exactly where the first left off.

  8. #8
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    Quote Originally Posted by Darrel Taylor View Post
    Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?
    My bad. Pleased to see it works OK.

    Norm

  9. #9
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: Wrapping code

    Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?
    I have one.

    I can't code wrap when the characters extend past column 255 even though we're given 1024.

Similar Threads

  1. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 20:44
  2. Code: Why is this code greater than 2000 words?
    By DrDreas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st June 2007, 19:51

Members who have read this thread : 1

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