Ever wanted to write a script once and then run it using the Clojure REPL for Android? I was recently asked about this via e-mail, and I thought it would be good to make a note of it here.
First, you will need to write your script and get it onto your phone in a
world-readable location. Usually, the SD card should work out well enoughi,
which is generally mounted at
/sdcard. Therefore, if you transfer your
coolscript.clj to the SD card, it should show up at
Now, all you need is the
load-file command. To run the script
above, you would just enter:
Note there is one important limitation to this approach. It does not change the path for which scripts are looked up. If your script requires searching for other files that define namespaces, it generally will not work. Adding directories to the search path is proposed feature that would be nice to add.
Behind the scenes
I have not abandoned the REPL. Since the Conj, I have been working on the REPL to help get some more feedback to the Clojure/dev team to improve Clojure on Android. At the Conj, I announced Neko, the Clojure/Android Toolkit. I have since updated it to be compatible with the latest versions of both Clojure and the Android SDK. I also now have a version of Clojure for Android that is compatible with the latest 1.4 developments.
Please stay tuned for more Clojure/Android news and a Clojure/conj wrap-up.
No trackbacks, yet.
Trackbacks are closed for this story.
On Thursday, 12 Jul 2012 11:27, Steve wrote the following:
I just downloaded your Clojure Repl to my Kindle Fire and I am interested in finding one based on 1.4 . Do you have an .apk that I can install of such?
On Thursday, 12 Jul 2012 15:46, Daniel Solano Gómez wrote the following:
You'll be happy to know that I just submitted a new version to the Play Store that includes Clojure 1.4.0.
On Saturday, 14 Jul 2012 17:56, Vish wrote the following:
Thanks much for a fine REPL app. My daughter is using it (the 1.4.0 one) on her tablet to learn Clojure. One issue we ran into is that the read-line function doesn't work at the app's REPL. I guess that is because the *in* VAR is pointing to the LineNumberingPushbackReader in com.sattvik,coljure_repl.repl_runner.
Is there some other way to write and execute interactive functions (that read input interactively at your REPL)?
On Sunday, 15 Jul 2012 09:48, Daniel Solano Gómez wrote the following:
Unfortunately, I don't think that's possible at the moment. I hadn't really considered that when I created the app, and I am not sure it can be easily added. Whenever I get around to rewriting the REPL, that's something I can keep in mind.
On Monday, 16 Jul 2012 15:36, Rokand wrote the following:
Hi! Is it possible to spit and slurp files from the sd-card? I didnt see the External storage-propery in the rights section.
On Monday, 16 Jul 2012 15:45, Daniel Solano Gómez wrote the following:
It should be possible to read files from the SD card. For now, it appears Android allows that by default.
However, without the WRITE_EXTERNAL_STORAGE permission, you shouldn't be able to write anything. I suppose this is something I can think about including as a feature if people are interested.
Comments are closed for this story.