Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news2.euro.net!dispose.news.demon.net!news.demon.co.uk!demon!aether.demon.co.uk!aether.demon.co.uk%faq
From: [email protected] (Matthew Hambley)
Newsgroups: comp.sys.acorn.programmer,comp.sys.acorn.announce,comp.answers,news.answers
Subject: comp.sys.acorn.programmer FAQ
Followup-To: comp.sys.acorn.programmer
Date: Tue, 12 Mar 2002 18:11:44 GMT
Organization: Beyond the Reality Barrier
Approved: [email protected]
Message-ID: <[email protected]>
NNTP-Posting-Host: medusa.therealm
Summary: This is the FAQ for the comp.sys.acorn.programmer news group.  It gives answers to many often asked questions and some not so often asked questions.  It should be read by anyone considering posting to this group before they do so.
X-NNTP-Posting-Host: aether.demon.co.uk:158.152.186.18
X-Trace: news.demon.co.uk 1015957396 nnrp-12:24946 NO-IDENT aether.demon.co.uk:158.152.186.18
X-Complaints-To: [email protected]
NNTP-Posting-Date: Tue, 12 Mar 2002 18:11:43 +0000 (UTC)
Archive-name: acorn/programmer
Posting-Frequency: monthly (approximately)
Last-modified: 16th September 2001
Version: 1.20
Maintainer: Matthew Hambley ([email protected])
Disclaimer: Approval for *.answers is based on form, not content.
Lines: 487
Xref: senator-bedfellow.mit.edu comp.sys.acorn.programmer:61317 comp.sys.acorn.announce:6872 comp.answers:49231 news.answers:226369

Apologies for the delay in posting.  I have been suffering unreasonably
ammounts of hassle with gateways and firewalls.  I have also come to the
conclusion that xslt is not the appropriate technology for producing the
use-net version of the FAQ.  It will do until something better is in place
though.

   The comp.sys.acorn.programmer FAQ

   1.20 - 16th September 2001


There are a number of questions which crop up time and again in the
comp.sys.acorn.programmer newsgroup.  This FAQ hopes to answer these in an
attempt to keep the signal to noise ratio on the group high.  It also
covers a number of points concerning the nature of the news group itself.

Please be aware that this FAQ does not hope to be a comprehensive resource
for programmers.  Rather it is intended to be what it claims to be, an
answer to some frequently asked questions.
  Current maintainer: Matthew Hambley <[email protected]> Web
version: <http://www.aether.demon.co.uk/faqs/programmer.html>



Revision History ----------------

1.1 (5th July 2001)
 Amended Python URL, again.
 Changed reference to Deja News to Google Groups.
 Corrected some spelling.
 Added Zhaba to the JVM question

1.0 (1st July 2001)
 The FAQ has been approved for posting to *.answers.  It is now "official"

0.9&#223; (4th June 2001)
 It was pointed out to me that HUGS is an interpreter, not a laguage

0.8&#223; (18th May 2001)
 Added Dreamscape to the libraries section and removed the reference to a
C++
   class library as I presume this is it

0.7&#223; (3rd May 2001)
 Added JFShared
 Corrected some URL's
 Added PHP to list of available languages

0.06&#223; (14th Apr 2001)
 Changed the Easy C/C++ answer in light of new information
 Added Mesa to the C libraries section
 Added a whole host of URL's to various things
 Added a bit concerning spawning processes in BASIC

0.05&#223; (8th Apr 2001)
 Move to XML based publicationn
 Spelling corrections.
 Added SharedBLib to the BASIC libraries section
 Various tweaks to library mentiones
 A few other minor changes

0.04&#223; (31st Mar 2001)
 Plumped up the Java section with some honest-to-goodness information.

0.03&#223; (3rd Mar 2001)
 Added a few more links to the introduction.
 Then removed them into a dedicated question.
 Added a nicer hierarchical question structure.
 Added the IF..THEN..ELSE..ENDIF gotcha.

0.02&#223; (25th Feb 2001)
 Added the 'getting started with WIMP programming' question.
 Added reference to Thumb code in the 32-bit section.

0.01&#223; (15th Feb 2001)
 This is the first version, thanks to Martin Penny for valuable
assistance.


Contents --------

1. Concerning the news group itself
 1.1. What is comp.sys.acorn.programmer?
 1.2. Are there any matters of netiquette of which I should be aware?
 1.3. What are the rules regarding code fragments?

2. On the matter of languages and libraries
 2.1. Which programming languages are available?
 2.2. How can I get started writing WIMP applications in BASIC?
 2.3. I want to work in C/C++, what is available?
 2.4. Where can I get an update to the Java virtual machine?
 2.5. What is available in the way of Java tools?

3. Technical issues of import
 3.1. What's all this about '32-bit' code?
 3.2. Fine, but what C/C++ stuff is 32-bit compatible?

4. Gotchas of which to be aware
 4.1. My BASIC IF...ENDIF block doesn't appear to be working   properly
 4.2. When I try to run another program from within my BASIC   application
something weird happens.



Questions and Answers ---------------------

1. Concerning the news group itself

 1.1.  What is comp.sys.acorn.programmer?

Comp.sys.acorn.programmer is a newsgroup for discussion regarding
programming RISC OS computer systems.  Its remit is wide covering
everything from novice programmers to assembly hackers.

You are encouraged to ask any programming questions but be aware that you
may find people more knowledgeable in a specific area of programming (e.g.
3D graphics) on a group dedicated to that subject.

 1.2.  Are there any matters of netiquette of which I should be aware?

First, a reminder of basic netiquette.  Before posting a question check
that it is not in this FAQ.  Then check that it has not been discussed
before. Deja News <http://groups.google.com/> may be used for this last
task.

You may also find an answer to your question in either a RISC OS specific
web site (try Acorn Search <http://www.acornsearch.com/>) or a generic
programming resource such as Wotsit
<http://www.wotsit.org>.

Finally consider whether your question is appropriate to
comp.sys.acorn.programmer. In particular bear in mind that although you are
writing your program on a RISC OS machine your question may not be RISC OS
specific. In these cases there may be a more appropriate group available.

Having said all that don't be put off posting.  As long as the denizens of
the group think you have employed due diligence in searching for an answer
they will be happy to try and help.

One last thought.  Do not end your message with 'Please reply by private
e-mail as I do not read this group.'  This is considered exceptionaly rude
and exploitative.  If you can not be bothered to participate in the group,
even for the life span of your query, then the regulars can not be bothered
to help you.

 1.3.  What are the rules regarding code fragments?

It is often a good idea to include a code fragment when asking a question
as it is often much easier to sort out the problem from the code than from
a hand-wavey discription.  The golden rule is 'Keep it short and relevant
'.

Another trick to make potential helpers' lives easier and increase the
likelyhood of you getting a useful reply is to include as much error
information as you can.  Also outline your debugging effort to date: What
you have tried and what did and didn't work.

Code fragments should be included in-line rather than being attached with
uucode or MIME.  It is also not acceptable to attach binary files to your
posts. If you feel that a binary will make matters clearer then upload it
to a web site and provide a link to it.
  2. On the matter of languages and libraries

 2.1.  Which programming languages are available?

The most obvious languages are BASIC with its built in assembler as these
are provided 'for free' with the operating system. There are a number of
C/C++ products as outlined in a following question. The Acorn C/C++ package
also comes with the ObjAsm assembly language development application.
Other languages which have received ports over the years include: Ada, AWK
<http://awk.riscos.org.uk/>, Forth, Fortran, Foger, Haskell, Icon, Java,
Lisp, Lua <http://lua.riscos.org.uk/>, Pascal, Perl, PHP
<http://www.ecs.soton.ac.uk/~ajw498/internet/php/>, Python
<http://www.schwertberger.de/>, Sather and Smalltalk
<http://sumeru.stanford.edu/tim/pooters/squeak.html> .

 2.2.  How can I get started writing WIMP applications in BASIC?

There are a number of libraries and such like which you may find useful:

 DrWimp (freeware)

   A highly regarded set of resources including not only a library
   but also a skeleton application to ease matters further.

 EasyB (Freeware) Last known version 1.01
<http://www.drawscript.fsnet.co.uk/EasyB/>
  The aim of this package is to offer a Visual BASIC style environment
whereby
  WIMP applications may be developed quickly.  It utilises the Toolbox
modules.

 JFShared

  A collection of BASIC libraries which come with a few templates to get
you
  started.  This library was written by Justin Fletcher for his own use so
your
  milage may vary.

 SharedBLib (GPL)

   In the vein of SharedCLib a set of BASIC libraries which exist only
once
   in memory.  Supports both CLI and WIMP interfaces and networking.

 WimpBASIC

   A commercial development environment from Clares.

 WimpWorks (&#163;35)

   A commercial development environment from Jaffa Software.



Other than that the various magazines have covered this topic (generally
some time ago so you will have to seek out back issues) and I can
particularly recomend some of the series run in Risc User. The book Wimp
Programming for All is based on these articles and is available on the
'RISC User in a Nutshell' CD-ROM.

 2.3.  I want to work in C/C++, what is available?


Compilers
 Acorn C/C++ (&#163;125)

   Includes the toolbox bits and a pile of other utilities.
   The C compiler (often refered to as Norcroft) is very capable however
   the C++ compiler is based on CFront and as such is showing its age.

 Easy C/C++ (&#163;30)

   Originally produced by Beebug, now sold by ProAction/APDL.  It aims to
   be a good basic C and C++ compiler.  It is a little dated now and some
doubt
   has been case as to its reliability on newer machines. However it is
cheap
   and therefore ideal for people who are just learning or who are
dabbling
   and don't want to muck about with command lines as in GCC.
   Comes with a mottly selection of libraries: RISCOS_Lib (with added
bugs),
   DeskLib (dubious version) and Vista (C++ library with memory leaks).

 GCC (free) Last known version 2.95 pre3 <http://hard-mofo.dsvr.net/gcc/>
   The Gnu Compiler Collection ported to RISC OS. Comes with C, C++ and
   Fortran77/Fortran90 compilers. Requires a shed load of memory to run so
   not really suitable for people with 4MB machines. Includes a linker.
Still
   undergoing development: There is a pre3 version but there are some
fairly
   serious problems with it.

   A competent compiler with good optimisation capabilities.

 GCC (free) Last known version 2.7.2

   An earlier port of the Gnu Compiler Collection.

 LCC (free)

   Although there were two ports of this library made. It is suggested
   that only the AOF based one is worth considering. The author, Reuben
   Thomas, is looking for someone to take over the maintenance of this
   compiler.



There was also a C interpreter, is that still available? I think it was
written by Hugo Fiennes and came on a magazine cover disc.  We have a vote
for Acorn User, February 1994.


Tools
 CMunge <http://www.movspclr.co.uk/cmunge/>
   Generates a code skeleton to allow the programming of relocatible
   modules in C. Similar to CMHG which comes with the Acorn C/C++
environment
   but, according to advocates, better.




Libraries
 conio.h

   Port of 'the most abhorent M$ lib/header file'.

 Curses

   Port of the Unix command line cursor control system.

 DeskLib

   Quite nice and rumoured to be have been upgraded by Pace to support
32-bit
   addressing.

 Desk

   Upgrade to the above, the 32-bit addressing support is apparently under
   test.

 Dreamscape
<http://members.nbci.com/mseaborn/comp/risc-os/dscape/index.html>
   This C++ class library was last updated in June 1998.  It wraps up the
various toolbox
   modules in an object oriented fashion.

 Dynamite <http://www.excessus.demon.co.uk/acorn/software.html>
   A shifting heap manager.

 FlexLib

   Memory manager

 JSLib

   Mozilla JavaScript library.  Allows applications to support JS
   scripting.

 Mesa <http://www.david.boddie.net/Mesa/>
   A port of this OpenGL based 3D graphics library.  David is keen that
   others get involved with using and developing this library.

 NetLib

   Goodness knows

 OSLib

   Well thought of and nigh on comprehensive set of libraries.

 RISCOS_Lib

   Depreciated and possibly bugged although it is claimed that the new
32-bit
   addressing version (under test) is much improved.  Improved use with
Easy C
   is also promised.

 Shared C Library

   A version of the standard C libraries built into the operating system.
   Requires programs to be linked against an object file called "stubs".
This
   comes as part of Acorn C/C++ but is also available as a
   freeware version <http://hard-mofo.dsvr.net/clib/index.html>
   .

 Sockets

   Comes with Acorn C and is designed to allow the use of the TCP/IP
stack.
   Also available seperately for download.

 TBoxLib

   Part of Acorn C, supports the toolbox modules.

 UnixLib <http://hard-mofo.dsvr.net/unixlib/>
   Provides all the functions required for GCC but can also be used with
   Acorn C.  Very useful for porting Unix applications.

 X11

   Offers XLib support.  If you don't know what that is you probably don't
   need it.

 ylib

   For machines with floating point hardware.  Provides faster versions of
   the maths functions.



 2.4.  Where can I get an update to the Java virtual machine?

   If you have version 0.76 then you can't, that's the most recent there
   is.

 2.5.  What is available in the way of Java tools?

There is a web site at which  further information
<http://www.chocky.org/java/> may be found.


Virtual Machines


There is currently one complete Java Virtual Machine (JVM) available for
RISC OS machines. Called RiscCafe it was written by Acorn and is therefore
not currently supported. It supports applets written to the 1.0.2 standard.
If you want a copy keep your eyes on the charity stalls at shows or the
small ads in magazines.

A coding group called eQ R&D gas recently released an alpha test version of
their JVM, Zhaba <http://www.eqrd.net/english/riscos/index.html>

A third JVM, called Chockcino, is currently under development. As yet no
release date is known.


Compilers


Two Java compilers exist for RISC OS. The first, guavac, compiles to the
1.1 version of the Java run-time environment. It can be used in conjuction
with the libraries supplied with RiscCafe or version 1.1 libraries are
available for it. Guavac support has been dropped in favour of Jikes.

The second compiler is a port of Jikes from IBM. It's newer, faster, leaner
and smells of pepermint.
  3. Technical issues of import

 3.1.  What's all this about '32-bit' code?

It relates to the underlying ARM hardware; the simplest explanation is that
the earliest ARM CPUs used a combined program counter/processor status
register. This limited the effective address range to 64MB ("26-bit" code).
Later ARM CPUs provide 26-bit compatibility along with extra modes that
have separated program counter and status registers ("32-bit" code). Some
ARM CPUs - not in use on current RISC OS computers - lack the 26-bit
compatibility modes. For one thing 26-bit mode is incompatible with the
'Thumb' instruction set provided by some ARM processors.

This, not surprisingly, has an affect on the low-level code in
applications; some 26-bit code will not work correctly in 32-bit modes.
This is not a problem. Yet.  However the processors which support 26-bit
mode will not be around for much longer. RISCOS Ltd has stated that it will
not perform the work to move the OS to 32-bit addressing until such time as
a machine which requires it is built.  This causes a bit of a 'Chicken or
the Egg' problem.

 3.2.  Fine, but what C/C++ stuff is 32-bit compatible?

There is already a Beta test release of a new Shared C Library and other
Acorn C/C++ based libraries available from RISCOS Ltd
<http://www.riscos.com/download/>.
  4. Gotchas of which to be aware

 4.1.  My BASIC IF...ENDIF block doesn't appear to be working   properly

Chances are you have a space after the THEN. In these cases BASIC will
assume that it is dealing with a single line IF. Thus it will execute the
rest of the block regardless of the state of the condition.

There are a number of ways of avoiding this problem in the future. Both Zap
and StrongEd provide a means whereby trailing spaces may be automatically
stripped on file save. Alternatively you can use the BASIC command CRUNCH
to perform a number of size reducing operations including the removal of
trailing spaces.

 4.2.  When I try to run another program from within my BASIC
application something weird happens.

Performing this task is a little trickier than you might at first think. It
is not simply a matter of *RUNing the new program as doing this will
replace the currently executing code with the new stuff.  Hence when the
new program finishes executing it will exit but the original program is no
longer in existence to return to.

There are a number of ways to achieve the desired goal.  The hardest, most
prone to errors and least recommended method is to fiddle around, a lot, to
set up a new environment in which the new program may run.

If you are looking for an easier and less nasty way there are several.
There is *WimpTask which will work inside and outside the WIMP.  Be warned
though that you have to be careful keeping track of which task is swapped
in at any given time.  If you try to include arguments to the new program
by placing them in memory which is then swapped out you can suffer crashes.

There is also the BASICShell module which is part of the SharedBLib
library.  This module may have trouble if another has claimed certain
vectors.

Finally you can try hacking the code which provides this function out of
the SlideShow application.

--
                         (\/)atthew )-(ambley
    Maintainer of the comp.sys.acorn.games and programmer FAQ lists
E-mail : [email protected]                    Public key ID : C487AC52
                  http://www.aether.demon.co.uk/faqs/