Shop OBEX P1 Docs P2 Docs Learn Events
Is there a way to split a .spin file into multiple .spin files? — Parallax Forums

Is there a way to split a .spin file into multiple .spin files?

MahonroyMahonroy Posts: 175
edited 2015-01-15 17:31 in Propeller 1
Hey guys,
So I have a rather large .spin file that contains all of my project functions. I know you can create separate object .spin files, and reference these objects within a .spin file. For some of my functionality it does not make sense to do this, so I am left with a large single file, and it makes navigating to different functions difficult. Is there a way that I can split some of this functionality up into multiple spin files, but still have the scope as if they are in a single file? Thanks and any help is greatly appreciated!

Comments

  • Heater.Heater. Posts: 21,230
    edited 2015-01-14 14:40
    What do you mean by "large"? A hundred lines of code, a thousand, ten thousand, more?

    Are your really sure that your project does not have logical "islands" of functionality that can be split off into separate independent objects?

    Generally you can split any huge mass of code into functions. And the move those functions into separate objects. Except then you may have a problem with all the global variables they are trying to use.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-14 15:00
    A trick I've used is to insert a DAT, CON or VAR block in various locations in the code.

    These blocks show up easier against the sea of "PUB" and "PRI" blocks.
    DAT ' GPS Section
    
    VAR 'Navigation Variables
    

    If you add a comment to the same line as the block's label, you can see the comments when in "Summary" view.

    While it's nice to break code into objects when possible, sometimes it's a lot easier to keep methods together in one massive object.

    The Propeller Tool also has "bookmarks" to make it easier to find sections of code. If you add a bookmark to the same line declaring the block type, the bookmark stays visible while in "Summary" view.
  • bte2bte2 Posts: 154
    edited 2015-01-14 16:04
    An inline "include" directive would be real nice, for things like pin constants and lookup tables.
  • T ChapT Chap Posts: 4,223
    edited 2015-01-14 16:09
    This is why I never use Protool or BST. You spend half your life navigating with a scroll bar with these antiquated tools.

    I have my own SPIN editor, it has 2 panes, left and right that are identical so you can do things like compare versions of code quickly to merge and update etc. I put all methods on buttons, there are 25 buttons per view, but you can click rapidly through the next 25 with up down nav. It is easy to GO TO a method by name or number. You also have color coded sections for CON, VAR, etc.
  • ElectrodudeElectrodude Posts: 1,658
    edited 2015-01-14 16:23
    T Chap wrote: »
    This is why I never use Protool or BST. You spend half your life navigating with a scroll bar with these antiquated tools.

    I have my own SPIN editor, it has 2 panes, left and right that are identical so you can do things like compare versions of code quickly to merge and update etc. I put all methods on buttons, there are 25 buttons per view, but you can click rapidly through the next 25 with up down nav. It is easy to GO TO a method by name or number. You also have color coded sections for CON, VAR, etc.

    Do you have any plans to release it?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-01-14 16:27
    This is one place where PropellerIDE really shines. If you click the "browser" button, a method index shows up in a sidebar. Click on any method name in the index, and the edit window instantly scrolls to that method. It turns navigating a really long program into the very paradigm of simplicity.

    -Phil
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-14 16:30
    This is one place where PropellerIDE really shines.

    I hate to admit it but I haven't tried PropellerIDE yet. I think it's time I give it a try.
  • MahonroyMahonroy Posts: 175
    edited 2015-01-15 14:54
    Thanks for all of the tips!

    I am using "PropellerTool", is this not what I should be writing code in? I have not heard of a "PropellerIDE"...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-01-15 15:19
  • jazzedjazzed Posts: 11,803
    edited 2015-01-15 17:31
    This is one place where PropellerIDE really shines. If you click the "browser" button, a method index shows up in a sidebar. Click on any method name in the index, and the edit window instantly scrolls to that method. It turns navigating a really long program into the very paradigm of simplicity.

    -Phil


    Glad you like it. Thanks.
Sign In or Register to comment.