Posts tagged LiveCode

Follow "LiveCode" posts with Atom or RSS.

A simple publisher/subscriber library for LiveCode

This is a simple library I made to use in a game we’re making where we needed a way for objects to interact with each other without hard coded object references. This pattern is known as the publisher/subscriber pattern or the observer pattern.

In this pattern objects can register themselves as listeners for specific events. Once an object triggers an event, all objects that we’re listening for such event will receive a callback message. You can use this pattern to allow controls to react to events in your program without the need to hard code dispatch/send messages. A good example is a progress bar that listens for a message that is triggered by a download operation. The download routine would trigger this message without the knowledge of the progress bar, it is just broadcasting it like: “hey, I am downloading something” and the progress bar will listen for this broadcast and react to it. The code could be like:

on openCard put the long id of scrollbar "progress" into tTarget addEventListener "downloadProgress", "downloadProgressCallback", tTarget libURLSetStatusCallback "urlstatus" load URL myURL with message "downloadComplete" end openCard on urlstatus pURL, pStatus switch item 1 of pStatus case "loading" put 0 into tDataA["start"] put item 3 of pStatus into tDataA["end"] put item 2 of pStatus into tDataA["progress"] trigger "downloadProgress", tDataA break end switch end urlstatus on downloadComplete ## this is just cosmetic to guarantee that ## the progress bar goes to 100% once the download ## is completed. put 0 into tDataA["start"] put 100 tDataA["end"] put 100 into tDataA["progress"] trigger "downloadProgress", tDataA end downloadComplete

In the given scrollbar script:

on downloadProgressCallback pDataA set the startValue of me to pDataA["start"] set the endValue of me to pDataA["end"] set the thumbpos of me to pDataA["progress"] end downloadProgressCallback

This way we can change the UI that reacts to the download without touching the urlstatus message implementation. We could have many controls listening for the downloadProgress event. Also check out how both the urlstatus message and the downloadComplete message trigger the downloadProgress event. None of these messages have any prior knowledge of whom is receiving this event and nothing is hardcoded.

Using such patterns, you can decouple your user interface from the inner workings of your application easier than before. In our little game we have stuff such as objects broadcasting events like “exploded” and “died” so that other objects can react. Since in games you tend to create and destroy objects at runtime a lot, this library makes our life easier.

This library is released in the public domain. Use it as you see fit, can’t sue me. To download this library, use the link on the sidebar (or link below if you’re using a mobile device).

DB Lib Goes Open Source with GPL

DB Lib is a minimalistic database library for LiveCode that works on Desktop and Mobile and allows you to build database-savvy apps without writing SQL directly. For example consider the following code:

dbWhere "country", "Brazil" put dbGet("contacts") into tDataA set the dgdata of control "contacts" to tDataA

It picks all records from the contacts table that have the country field equals to Brazil and set a datagrid to it. It’s very easy to use. A more involved example:

on mouseUp -- assemble array put dbCardToArray("contacts") into tDataA -- check if we're adding a new record -- or updating an existing one. -- -- this check depends on the record id being present. if field "id" is empty then get dbInsert("contacts", tDataA) if it is not a number then answer error it else answer "New Record Saved" end if go card "contact list" else dbWhere "id", field "id" get dbUpdate("contacts", tDataA) if it is not a number then answer error it else answer "Record Updated" end if go card "contact list" end if end mouseUp

In this code first we pick the data from a card using dbCardToArray(), a function that magically picks data from fields, buttons and other controls, and assemble an array that is used to insert or update a given record depending on the presence of an id field.

This is just a quick glimpse of what you can do with DB Lib. It is basically a ORM for LiveCode.


During RunRevLive.11 I gave a talk about web stuff with LiveCode (then called Runtime Revolution, aka RunRev). I spoke about Social Network integration.

Memories from the event

For many years I’ve operated my own URL shortening website called I’ve stopped using it many years ago but for many many years it was alive and used by thousands of people. I’ve found a mail message from the day before the conference detailing the creation of the service. The service was originally created to add short urls to my slides. I’ve used it all the way into the Firefox OS and Mozilla era of my life and the original URLs for my books footnotes all used it. The service was even used as an example of good feature set to be implemented in other competing services. Proud of my little tool. Its source is available from sourcehut.


During RunRevLive.08 I gave four talks about all sorts of Web stuff:

Brace Yourself for the 7 Super Secrets of Rev CGI

Put a star right now next to this one!

We guarantee this session will change the way you think of Rev from now on. Once you see how great Rev GGI’s work on web servers, and how simple they are to create, you’ll want to start using them on all sorts of websites. And with the included world premiere latest versions of RevOnRockets and Rockets Editor, we expect you’ll begin writing your own CGI’s the very same day!

Why bother with MySQL, when all you need is a store locator database, or a website catalog? In fact, there are numerous easy to setup, high performance Rev CGI’s which enable you to quickly and easily add dynamic website capabilities without having to learn SQL or php, or configure database server technologies. While a small portion of this talk will focus on setting up Rev CGI’s on servers, most of the session focuses on how to create Rev CGI’s and will go over workflow and architecture techniques. Plenty of examples will be given out, along with the latest free release of RevOnRockets and the first-time free release of the new “Rev CGI Missing Link” workflow enhancement tool, Rockets Editor.

This was co-hosted by Chipp Walters.

Other sessions

Unfortunately the wayback machine didn’t cache the data from the other sessions but I believe the last one, Internet Kitchen, was a kind of workshop/unconference.

  • Internet Applications II: XML, SOAP, RPC
  • Exchanging Data Over the Internet
  • Internet Kitchen

RevCon West 2006

Gave a talk to present to users a set of libraries and tools to aid Revolution Developers building Web Applications. The objective is to empower the developer to create web applications from inside the comfort of Revolution IDE and using stacks. Participants will learn CGI basics, FastCGI basics and how to benefit from Model-view-controller approach. Each participant will receive a powerful suite of tools including all libraries, docs and new plugins and palettes for RunRev.