Fence Painting or Coding Challenges?

by Steven Crighton on April 8, 2020 12 comments

It’s true for many of us that we have extra time on our hands at the moment. That extra time presents the opportunity to start or finish those tasks you’ve always been meaning to do. For me that could have been finally getting round to painting the garden fence five years after it was put up (unpainted), clearing out the garage, or sorting out my junk room – I mean spare room! I can confirm that after what has been about a month of me being at home I have not started any of those jobs. I have however tried to build a mini-golf course in my back garden and, which you may be more interested in hearing about, got stuck into some coding challenges.

I am not a developer, not even close, but I have always enjoyed trying to make things in LiveCode. I’ve prototyped a couple of UI’s in LiveCode and built a few really simple apps to help with daily tasks at work. This time instead of building something using LiveCode I wanted to challenge myself to add something to LiveCode.

My Coding Challenge

I may be the only person who has ever been annoyed by this, but from creating UI prototypes in Adobe XD or Moqups I am used to ordering the layers of the objects by right-clicking on the object and sending it back 1 or bringing it the front etc. That functionality already exists in LiveCode I hear you cry. Yes, it does, but not where I wanted it, on that right-click menu, which is where it makes the most sense to me.

With no IDE editing experience, I jumped in, found the correct file and started breaking things.

The one neat thing I found is you can edit the IDE files locally inside LiveCode and even if you make a horrible job and break everything, when you restart LiveCode it reverts to how things were previously.

Before I talk any more about what I did I must disclose what help I got from The LiveCode Team. Back in November I spoke to Ali about this. I told him I wanted to make some menu changes to LiveCode and he told me which file I need to be looking at and how to open that file in the IDE.

He told me that to add the menu item I need to be looking here – https://github.com/livecode/livecode-ide/blob/develop/Toolset/palettes/menubar/revmenubar.livecodescript#L2133

And to add the switch I need to be looking here – https://github.com/livecode/livecode-ide/blob/develop/Toolset/palettes/menubar/revmenubar.livecodescript#L2551

I had no idea what the switch was at this time but that was enough to get me started – I opened up the message box and entered

edit the script of stack "revMenuBar"

I won’t talk you through step by step exactly what I did but I can, however, say that I did manage to get this working successfully – You can see the pull request here if you are interested – https://github.com/livecode/livecode-ide/pull/2126

What I learned from doing this is a similar lesson I have learned when doing other things in LiveCode. You don’t need to go into anything knowing exactly how to do it, or even knowing roughly how to do it. I went into this knowing nothing and if I am being honest I am probably going out of it not knowing that much more. However, it’s incredible what you can do in LiveCode simply by looking at other examples, tweaking them a little bit and seeing if it works. I was able to read through the code in the revmenubar file, understand roughly what it was doing and match that to what I was trying to do. I broke it several times. I went through what seems to be a pretty normal developer cycle of getting one part working, getting the other part working and then realizing the initial part no longer works. I went through this cycle for several evenings sitting with the laptop on my lap and The Tiger King on the TV with no real idea of what was happening, both with the code and with the craziness on the TV.

Eventually, I had a breakthrough – it all started working and the feeling of achieving that was great. I suspect it was a much better feeling than that of starting and finishing painting my fence. I rushed onto Slack to tell Ali and others that I got it working, I was super happy. Ali was quick to point out that he expects there might be a few comments on the PR which I took as a hint that I didn’t quite do things perfectly. I have since discovered for example that my arrange menu item still appears even if no objects are selected, I suspect I need to put some kind of checking in the code to ensure an object is indeed selected. That sounds like a job to tackle during the next episode of The Tiger King. I look forward to it!

Your Coding Challenge

I wrote this blog post not just to show off how bad I am at home chores or how good I am at IDE editing, but instead to talk about the opportunity for you to jump headfirst into your own coding challenges. What is that one project you always planned to do if you ever found a way to create more time in a day? Now could be the time to get that coding challenge started and finished. Maybe it’s a small individual project, maybe you always wanted to start a group project with others in the LiveCode community? Maybe it’s a new app, a widget you always wished existed or maybe you have your own IDE pet peeves. Now could be the time to resolve them. I wanted to end this post with some clever message about being brave enough to walk into the tiger’s cages like Joe Exotic (The Tiger King) and relate that back to jumping in headfirst with your coding challenge but I really can’t think of any good examples to take from that show that would be relatable or appropriate here. Nope. None. Crazy.

I challenge you to start your own coding challenge during this lockdown. I hope you accept. You won’t regret it! If you are struggling to come up with a challenge here are some things that you could get stuck into…

  1. Build a comprehensive interactive charts widget for LiveCode (Everyone would love this)
  2. Add guides to the IDE so that you can easily see when things are lined up and spaced evenly and objects just snap into place. Similar to those found in Mockup prototyping tools or even in keynote when you are editing (This is one Kevin would LOVE to see)
  3. Make a treadmill elevation calculator where the calculation is in a single line of code – (Suggested by our ultra-marathon runner and coder Sophie)
  4. Dip your toes into GitHub and contributing to LiveCode – check out the latest post of This Week in LiveCode for some tips on how to do that. (Suggested by Panos)
  5. Learn how to code for the first time or help someone else learn to code. See our Covid-19 page for more information on getting started with LiveCode.

Tell us in the comments section what you have always wanted to do in LiveCode but never had the time? Maybe you have already started your own coding challenge, let us know below. Maybe you have some cool challenges for other people to try out, share them below.

Keep safe everyone – let’s get through this!

Steven CrightonFence Painting or Coding Challenges?

12 comments

Join the conversation
  • Matthew Turney - April 8, 2020 reply

    Thanks for your blog on coding! My own challenge is to conquer the Data Grid! I was able to build a Data Grid in the Form format. I scripted the Form to place the Data (which was text) into the grid as well as changing labels on buttons in the grid using (set the label of button “x” of me to pDataArray[“xName”]). How fun was that?! Having difficulty changing the checkbox with sending a true or false statement to the scripting, but for some reason, this sometimes crashes the system. It may be because I placed the information in the script of the Data Grid in the wrong location (FillInData pDataArray) within the script. I also wrote a card button to refresh the data grid, because I’m having a problem with the DataGrid refreshing itself when a change is made. I tried using the (dispatch “RefreshList” to group “DataGrid”) to no avail! Overall, I’m bound and determined to conquer the Data grid!

    Steven Crighton - April 8, 2020 reply

    Hi Matthew – Conquering the Data Grid sounds like a great challenge. I’m sure you will get a breakthrough on your current DataGrid issue soon. Hopefully, someone might see your comment and be able to point you in the right direction! Happy Coding 🙂

  • Phil - April 8, 2020 reply

    Thank you. Speaking of challenges I am struggling with printing in iOS apps. This is much more difficult than say Mac apps. I have tried pdf printing but it still fails. I need something basic and clear regarding iOS printing. So, anyone with programming examples would be appreciated. Can LiveCode or others include a simple fix? Hope all are well!

    Elanor Buchanan - April 9, 2020 reply

    Hi Phil, printing to PDF should work on iOS. Here is a quick example that creates a PDF of the current card in the app’s documents folder.

    on mouseUp
    open printing to pdf (specialFolderPath(“documents”) & “/mypdf.pdf”)
    print this card
    close printing
    end mouseUp

    After the PDF was created I checked it using a browser widget.

    set the url of widget “browser” to (“file://” & specialFolderPath(“documents”) & “/mypdf.pdf”)

    I hope that helps.

    Kind regards

    Elanor

  • Bernd Niggemann - April 8, 2020 reply

    @suggestion 2
    do you mean guides like this?
    http://livecodeshare.runrev.com/stack/918/BnGuides

    Steven Crighton - April 9, 2020 reply

    Yes, that is extremely close to what was being put forward in suggestion 2. I have just installed it, it’s very good! It would be great to have something like this available in the IDE as standard I think. Really nice work.

  • Paul Foraker - April 9, 2020 reply

    How about, for the Mac, CMD-click the stack title to reveal the enclosing (and selectable) folder(s)?

  • José Donizeti Borges - April 14, 2020 reply

    Nice Job, really useful feature, the LC team must think about to include in future versions.

    Another big feature that LC users want to have is an ADs Widget

  • Massimiliano Vessi - April 16, 2020 reply

    I love Livevode and I propose this Challenges to Livecode team with my best feelings:
    1) Write a real guide on Livecode widgets, all topics are too fragmented and confusing. It would be a book people would buy
    2) Improving homepage, writing somewhere something like “write once run everywhere”; because now homepage seems the IDE of a Javascript webpage generator. (I see APP word, I see a server, I see HTML5)
    3) choose a person who writes a blog article EVERY WEEK, because a blog post a year seems a funeral announcement
    4) Read and correct all the dictionary, it’s a bit outdated and also the formatting is no more correct and bad displayed in the current IDE.

    Sandro - April 16, 2020 reply

    I agree with your comments, Max.

    Steven Crighton - April 16, 2020 reply

    Thanks for the comments – some valid ones in there. For number 4, that would be a good LiveCode community challenge. It’s quite a large project for one person to take on. The dictionary is not a single, static, document. It’s updated live all the time, as terms are added or edited. Trying to read and edit it all as one project would be like painting the Forth Bridge – it takes all year, and once you finish, you have to start again. This makes it ideal as a target for community editing and fixing. Every time you see an error, jump in and offer a fix via github. Its one of the easiest areas to offer community edits in.

    Jose Donizeti - April 24, 2020 reply

    100% with you, your words are mine words .

Join the conversation

*