mrcoollion wrote: Sat Apr 30, 2022 1:09 pm
Does anybodu use the Atom IDE with the LiveCode plugin. How does this work? Can i step through the code just like with the LC IDE?
Regards,
Paul
Sadly no, you cannot debug your script in an external editor - I presume this is what you mean by wanting to step through your code. But then again I find the built in debugger quite sufficient.
The linters available for both Atom and VSCode (the latter is definitely my preference even on Mac) will however format your code, do syntax colouring (much better than the built in IDE), autocomplete and will highlight syntax errors as you type.
How you work with this is also different, as the IDE does not provide integration with 3rd party editors (in my mind they really should as these are the best tools for the job).
Your options are either to take the “low tech” approach and just copy/paste larger scripts back and forth from the editor to the IDE.
Or do what I’m now doing - abstracting code to script only stacks (SOS).
What I’ve done is separated SOS in to 3 groups:
- card behaviours which are assigned to each card at startup
- libraries which are loaded at start with “start using”
- backscripts Which are loaded at startup and which includes a stack with functions to return the location of SOS files depending on whether in IDE or standalone (obviously this loads first)
Unfortunately there is no automatic refresh of code when you edit externally (the above mentioned lack of integration :-/ ) and I therefore also have a handler that will close all SOS and remove them from memory and then just run the startup script to load them all up again.
Above and beyond the benefits of working with professional code editors the benefits of this approach include:
- excellent integration with Git or other version control
- I can group all SOS ina project folder so they’re all in one place in the code editor
- it’s much easier break up scripts into logical units. Being a bit old fashioned I like an MVC approach which is now more straightforward. For example if I have a card that deals with staff data stored in a database:
- model.staff.livecodescript loads as a library to manage db transactions
- view.staff.livecodescript is assigned as the card behaviour at start up
- controller.staff.livecodescript loads as a library to manage any logic required
And any utilities required by other libs are loaded into the backscripts.
This may seem complex but it is really quite fast and means I can break down massive scripts into more manageable chunks.
Of course you don’t really need SOS to do this - the card and stack scripts can be good places for these but I find very easily get too long to be practical.
That’s my approach anyway. Needs a bit of work to set up the load and reload handlers but the. Works very nicely indeed…
Having said that there is no way to fully avoid the IDE as you can’t debug in an external editor in LiveCode
Anyway, that’s just my (current) approach, and it’s only really something I would do for larger projects where scripts can be thousands of lines long. For smaller projects I’d just use the built in stuff tbh. Maybe it’s useful to you, maybe not…
Stam