Shop OBEX P1 Docs P2 Docs Learn Events
Any way to break up long lines in SPIN2 & Fastspin? — Parallax Forums

Any way to break up long lines in SPIN2 & Fastspin?

In a few places I have some longer source code lines in my driver I'd like to break up.

In C you can make use of a backslash for doing this, is there any way to spread code over multiple lines in Spin2/Fastspin?

Comments

  • RaymanRayman Posts: 14,646
    Maybe you can end top line with "/*" and start next one with "*/" ?
    I think that works for things in CON section anyway...

    There was another trick too, but don't remember...
  • roglohrogloh Posts: 5,787
    edited 2020-07-09 00:50
    Yeah I vaguely thought there was a way too but maybe I'm wrong.

    Just tried but the "/*" thing doesn't work in the PUB section. However I tried line wrapping with { ending one line and starting with } on the next line and that did work in Fastspin. It's a slightly weird way to do it, but I guess it might help if it is compatible with official SPIN2 as well.
        if (r := writeReg(addr, $555, $AA)) OR (r := writeReg(addr, $2AA, $55)) OR {
    }      (r := writeReg(addr, $555, $80)) OR (r := writeReg(addr, $555, $AA)) OR {
    }      (r := writeReg(addr, $2AA, $55)) OR (r := writeReg(addr, sa, cmd))
            return r
    
  • RaymanRayman Posts: 14,646
    Right! I was thinking C++ for some reason... Sometimes I get the two mixed up :(
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-07-09 02:23
    I don't know if it works in FastSpin, but you can use curly braces to break lines in Spin and Spin2. I have used this when I have a lot of locals.
    pub some_method(param1, param2, param3) : result | {
    }     local1, local2, local3
    
  • Thanks JonnyMac. I have just tried this myself too several minutes ago and it does work in PNut's SPIN2 as well as Fastspin so I will certainly start to use it in my drivers where needed. I am trying to make the same code work across both tools and it looks like I am getting there now.
Sign In or Register to comment.