Log in

View Full Version : Programming the Pocket PC – entirely PPC (not desktop)-based solutions


Menneisyys
07-26-2005, 05:12 PM
In my latest, second article (http://www.firstloox.org//forums/showthread.php?p=34860) on CabInstl, Mad Programmer's File Dialog Changer and the HKEY_LOCAL_MACHINE\SOFTWARE\Apps\Microsoft Application Installer\fAskDest registry key, I’ve already spoken a bit about the two free scripting applications, nscript (http://www.geocities.com/s_k_s_k_s_kru/util.html#nscript) and MortRunner (http://www.sto-helit.de/freeware/pocketpc/mortrunner-en.pl) for the Pocket PC.

Because nscript has excellent support for the Windows Mobile operating system, I’ve decided to compare it to the other solutions of directly compiling code on the Pocket PC: Java (http://www.pocketpcthoughts.com/forums/viewtopic.php?p=349780) (my tutorials there have even made to the Pocket PC Thoughts frontpage! :) ) and PocketC (http://www.orbworks.com/wince/).

Why did I choose just Java and PocketC, you may ask. The answer is simple. To my knowledge, these are the only two environments/languages that can also be edited and, most importantly, compiled on the Pocket PC (not taking into account almost useless, non-native solutions like running Borland C++ under PocketDOS). I wish I could be able to edit and compile native WindowsCE C/C++ applications, or managed code (Compact Framework; preferably accessed from C#) on the Pocket PC, but, as far as I know, it’s not possible. So, for people that have to write an app that does something serious while they don’t have access to a desktop PC (or, the language/class librtary they use just don’t support the thing they want to do – see or example the WinCE database access, which I’ll speak more in the next paragraph), only PocketC and Java are the viable solutions.

PocketC was a big surprise for me. Despite the lack of any kind of TCP/IP and multithreading support, it’s an astonishingly well written, compact language and function library. My initial fears (what if it’s so different from C that I end up learning another language/even I/O/string handler library?) disappeared very fast when I learnt more and more about it. I especially liked the almost full access to the WindowsCE system databases it offers – not even the Compact Framework 2.0 is able to do this (it only allows for accessing PIM databases), let alone older, now still current versions! It also has a great set of drawing, file I/O functions etc.

Some remarks on PocketC: please note that its character size must be modified in a rather unusual place: Help/Preference. Without it, it has way too big characters in QVGA/SE VGA. On VGA devices, size of 6 is the way to go IMHO, especially in Landscape mode. It also puts a 357,041-byte-long help file, pchelp.htp, in \Windows; you may want to relocate/delete it after installation.

Java is also compiling/working great on Pocket PC’s, especially with the CrEme JVM. Please read the above-linked thread on Java compilation for more information. Also, on MortRunner and nscript, read my second big post in the above thread.

When to use which language/environment?

First, you need to make a distinction based on whether you “only” want to have a “light” scripting language (only slightly better, in this respect, than the control/conditional structures of MS-DOS) that is mostly meant for process control (MortRunner), a strong(er) language with decent C-like syntax and tolerably good system access capabilities (nscript) or a language that is, except for the TCP/IP and multithreading fiasco, is able to do almost anything on your PDA (PocketC). The latter, PocketC, is even able to access all the “problematic” parts of the device that can’t be accessed by a generic, multiplatform language like Java.

This means you shouldn’t (and, actually, can’t really) use PocketC or Java for process control (say, starting external programs, sending mouse clicks to it just like the stylus tap emulation in the Button Mapper app of VITO SystemTools (http://vitotechnology.com/en/products/manual.php?id=372) etc), while, on the other hand, you won’t be able to write an app that processes (reads, extracts some info etc) files in MortRunner. The former is meant for scripting apps, the latter for real programming languages.

There is indeed some kind of overlap between the two categories. While, for example, nscript is more of a scripting app, it even offers file I/O like a “real” programming language and even regex support and socket I/O (the latter two isn’t supported by PocketC). This is why I’ve decided to include both scripting apps together with “real” programming languages in my roundup.

Enough of talk: let the table speak instead of me (http://winmobiletech.com/sekalaiset/PPCScripterCompilerRoundup.html). :)


This table contains all the major areas: I/O, networking, string manipulation, system access, native graphics, process control, multithreading, system events, WinCE databases, WinCE registry etc. I’ve even collected and formatted the function names (with Java, mostly the package names) for the different application areas so you’ll know at once what to use.

(Note that, the table being a big HTML table, I couldn’t copy its contents in here. This is why I needed to link it.)

Bottom line: all the three apps/environments have strengths and weaknesses. nscript and MortRunner are both free; the latter is actively worked on, the latest version, 2.60, released some days ago. I wish it had a C-like syntax though. For simple(r) scripting/programming, they, especially nscript, may be perfectly OK.

PocketC has delivered much more than I expected. This app is really great, except for the lack of multithreading and network support. For multithreading, you may want to stick to Java; for network support, nscript can also be a good choice.

With Java, as I’ve already pointed out in the Java compilation thread above, you have access to almost anything. All this editable, compilable and usable right on your PDA, without the need for any desktop computer. Its only downside is the unability to access the registry / the system databases. In the latter, PocketC really excels, and is much easier to use than the standard Win32 library. (Which, again, can only be written programs to on a desktop PC.)

Please let me know if you have any questions about any of the three above applications or how Java should be compiled/run on the PPC. I will also keep posting scripts/programs using these apps in my later posts.

Menneisyys
07-27-2005, 06:22 AM
Over at AximSite, http://www.aximsite.com/boards/showthread.php?p=773029 , JonMisurda has posted a great list on other languages/tools. It seems I need a lot to test / add to my article. Stay tuned! :)

gwinter
07-27-2005, 04:21 PM
It is already possible to develop managed app using C#. There is a GNU C# compiler ported over to the Windows CE platform. Take a look here (http://www.pocketpcfreewares.com/en/index.php?soft=1174).

sto-helit.de
08-24-2005, 01:21 PM
Just a little update note on MortRunner...
The current beta can be downloaded in the download section on www.sto-helit.de (currently still in redesign work due to some server problems with the old technics...).

Typing: None (there are variables now, type casts are done dynamically)
GUI: The "Choice" command also shows a selection, and there's "Message"
Controlling other windows of other processes: Added "If procExists ..." and "Kill ..."
Time: Added GetTime function (unix timestamp, formatted, or into single variables)
String: Only concatenation
Math: Only basics (*, /, +, -, MOD, brackets)
Registry: read? + RegWrite[String /Dword] [root],[path], [key],[variable]

But still it's just a batch language, nothing to write proper applications.

burtcom
08-24-2005, 04:47 PM
It is already possible to develop managed app using C#. There is a GNU C# compiler ported over to the Windows CE platform. Take a look here (http://www.pocketpcfreewares.com/en/index.php?soft=1174).

I've been using Pocket C#, and it's great! Although the programmer who first compiled it has gone missing, we have a small community of users at

http://groups.yahoo.com/group/pcsharp/

You'll also find the program, source code and other goodies here too,