home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / documentation / documents / a252appg < prev    next >
Internet Message Format  |  1999-04-27  |  19KB

  1. From: jwil1@cs.aukuni.ac.nz (TMOTA)
  2. Subject: The CSA App. Writers' Guide
  3. Date: 22 Jun 92 00:41:55 GMT
  4. Organization: Computer Science Dept. University of Auckland
  5.  
  6. The comp.sys.acorn Application Writer's Guide
  7. =============================================
  8.  
  9. This guide contains a lot of small hints from some of the gurus on 
  10. comp.sys.acorn. Most of them are pet hates - things that many 
  11. applications do that really annoy us. When writing applications, 
  12. please read through this list and check that your application 
  13. conforms to as many as possible of the items...
  14.  
  15. Many of these things might seem complicated at first, but they are 
  16. all very simple when you know what you are doing. All the 
  17. information needed can be found in the Programmers Reference 
  18. Manuals, or ask someone for some help!
  19.  
  20. This guide is kept by Jason Williams (jwil1@cs.aukuni.ac.nz), so
  21. please email any new suggestions for the guide to him. Any suggestions
  22. made on comp.sys.acorn should also be caught and included...
  23.  
  24.  
  25. "Public Domain"
  26. ===============
  27.  
  28. Public Domain means that everything in the application can be 
  29. used, changed, copied, etc. exactly as the user wishes. They can 
  30. even include portions of your application in their own (commercial)
  31. programs if they so wish.
  32.  
  33. Public Domain and Copyright are MUTUALLY EXCLUSIVE!
  34.  
  35. If you wish to place distribution conditions on your software, then 
  36. call it FREEware, and clearly state your conditions. Using this term, 
  37. you can also claim copyright on your software.
  38.  
  39. Legally, if you choose to use the term 'Public Domain', then you 
  40. don't have a leg to stand on, even if you stated that the software 
  41. was copyright, etc.
  42.  
  43.  
  44. Icon sprites/Screen modes
  45. =========================
  46.  
  47. Never include additional sprites (eg your own definitions of 
  48. system sprites) in the !Sprites file of your application.
  49.  
  50. Always include small icons as well as large ones in your sprite 
  51. files.
  52. Regardless of how hard the things are to design, you can always 
  53. do a better job than the automatic scaling of the large icons.
  54.  
  55. Always include a !Sprites22 (Mode 20) and !Sprites23 (Mode 23) 
  56. file as well as !Sprites (Mode 12) - even if you can't display 
  57. multisync sprites on your monitor, you can still create & edit
  58. them provided you use at least 2x magnification.
  59.  
  60. Make sure all your sprites have a core RISC OS 2 ROM mode 
  61. number (Sprites should be defined in mode 0, 12, 20, or 23).
  62. Be very careful about this if you start using screen snapshots to 
  63. help you design sprites. Similarly make sure you remove the 
  64. sprite's palette after doing a screen shot to create an icon.
  65.  
  66. Always try your !Sprites in MODEs 8 and 0 (4 and 2 colour) to make sure
  67. they don't disappear. Careful choice of colours will ensure they don't
  68. Similarly aways try !Sprites22 in MODEs 19 and 18 as well as Mode 20. Your
  69. !Sprites23 should look similar to your !Sprites22 in MODE 18, but some
  70. difference is reasonable since you can hand stipple !Sprites23 as they are
  71. for monochrome display only.
  72.  
  73. RUN your program in ALL screen modes you can lay your hands on. Do
  74. all your icons dissapear due to colourtransing in mode 0? Do your
  75. 256-colour icons go SPLAT in mode 12?
  76.  
  77. Does your code fall over in mode 66, 78, 120? (Not checking the size
  78. of the screen is a very common fault. DO NOT assume that the 
  79. screen other people are using is identical to the one you use!
  80.  
  81. Get the size of the iconbar icon RIGHT! If in the program you declare
  82. the iconbar icon bounds as 0,0;68,68 then make the sprite you use
  83. 34x17 in mode 12/0 or 34x34 in mode 20/23!
  84. Try 'dabbing' at the edges of your icons with a window or menu 
  85. and see if you can cause bits of the icon to be 'rubbed out' and not 
  86. correctly redrawn.
  87.  
  88. Info windows like those used by BASS are pretty with all their 
  89. sprites, but how much memory does this take? Place these sprites 
  90. into a file we can edit (don't compact them in with the 
  91. !RunImage), and preferably give an option that stops unnecessary 
  92. sprites being loaded/displayed.
  93.  
  94.  
  95. !Boot & !Run files
  96. ==================
  97.  
  98. Only include a !Boot file if it is absolutely necessary. Remember 
  99. that other users may not appreciate an unnecessary !Boot file,
  100. particularly if they are Econet users.
  101.  
  102. If a !Boot file is missing, then the equivalent of
  103.   IconSprites <Obey$Dir>.!Sprites
  104. will be done automatically for you.
  105.  
  106. ALWAYS put an IconSprites <Obey$Dir>.!Sprites into your !Run file.
  107. If the application is launched with !Menon or similar, the sprites 
  108. will not have been loaded by your app. dir. being 'seen'.
  109.  
  110. Suggestion: rather than having a !Run file which goes "Obey <foo$Dir>.
  111. !Boot", include the contents of the !Boot file in line in the !Run file.
  112. This way the application starts up quicker over Econet, as the 
  113. !Boot file doesn't have to be loaded.
  114.  
  115. Never have anything (not even blank lines) after the "Run <foo$Dir>.
  116. !RunImage" in your !Run file, otherwise the !Run file stays open 
  117. while your application is running and only gets closed when it 
  118. quits.
  119.  
  120. Don't make your program auto-run in a !Boot file. If you want people
  121. to have the option of this, give them a file they can rename to 
  122. !boot...
  123.  
  124.  
  125. Help files
  126. ==========
  127.  
  128. Always include a !Help file. This should be a plain text file, and
  129. never one of these !Help applications which are springing up.
  130.  
  131. IF you MUST use a non-text !Help file, then use an Obey file that 
  132. checks if the application your Helpfile needs is loaded, and reverts 
  133. to just RUNning the text version of the help if the special 
  134. application is not found.
  135.  
  136. Always call the help file '!Help', not 'ReadMe' or other names. This
  137. allows help to be offered on the filer menu.
  138.  
  139. Always include your name in the !Help file, as well as the application.
  140. You don't have to include your address, but without a name, it can be
  141. very difficult to identify pieces of software.
  142. DON'T include your name if you are re-releasing somebody else's 
  143. work - passing off someone else's program as your own is bad, 
  144. and could get you into a lot of trouble.
  145.  
  146. Always credit other people for any help/code they supplied you 
  147. for your application.
  148.  
  149. A nice option is to check if your help file exists from within the 
  150. application, and offer a 'help' option on your main menu, which 
  151. simply RUNs the text file...
  152.  
  153. Always include an indication of the legal status of the software, 
  154. and whether or not it may be freely distributed.
  155.  
  156.  
  157. Other files/resources
  158. =====================
  159.  
  160. Don't put lots of subdirectories inside the application if it can be 
  161. helped. People with hard drives typically lose 14k for each 
  162. directory you bung in, which often wastes more space than the 
  163. total size of a small PD application... :-(
  164.  
  165. Get all your resources with <App$Dir>.Name, where Name is the filename
  166. of the resource, and App is the name of your application. Set this
  167. variable (*Set App$Dir <Obey$Dir>) in your !Run file.
  168.   DON'T use <Obey$Dir>.Name inside your main program!
  169.   DON'T use "$.!app.file" or "adfs::Mydisc.$.!app.file"
  170. -Even though this is convenient, it is bad form, and may cause 
  171. problems for anyone who adds functionality to your program 
  172. later. Do it right the first time!
  173.  
  174. Alternatively do "*Set App$Path <Obey$Dir>." (note the trailing 
  175. period character) and reference files as App:Name. This only 
  176. works for reading though.
  177. RISC OS 3 applications tend to have both a $Dir and a $Path. The 
  178. path is used for reading reasource files, so they can be in several 
  179. places (and indeed some of them are - see Alarm$Path). $Dir is 
  180. used for writing configuration files etc.
  181.  
  182. Preferably, use a SEPARATE variable for your config. files, so that 
  183. someone else can easily move your config. data to a central place 
  184. and then rename your variable to point there instead. This can 
  185. allow your program to be run from read-only filing systems (e.g. 
  186. on econet, etc)
  187.  
  188. Always use <Wimp$Scrap> and <Wimp$ScrapDir> for storing temporary files
  189. in. Never store them inside your own application's directory. In this way
  190. the user is free to put temporary files where he wants them, rather than
  191. ending up with them spread over 4 different floppy discs with attendant
  192. unecessary disc swapping. The disc with <Wimp$ScrapDir> on it is probably
  193. already in the drive.
  194. On RISC OS 2 you need to be careful about <Wimp$ScrapDir> as it 
  195. doesn't always exist. It is suggested that you supply a !Scrap 
  196. application with your software if you make use of <Wimp$ScrapDir>
  197.  
  198.  
  199. Windows
  200. =======
  201.  
  202. Even if you only have an info window, make sure you process 
  203. OPENWINDOW requests, or your windows won't be movable.
  204.  
  205. Info windows that go away when you move the pointer out of them are
  206. *incredibly* annoying! Likewise, Info windows that limit the 
  207. pointer (BASS!) are a hassle. (Especially in Protracker where the 
  208. limit is a window *behind* the one you are looking at... I *hate* 
  209. that!)
  210.  
  211. Always open windows as defined in the templates file. Reposition 
  212. them if you like, but don't change their size! Some people have 
  213. bigger screen modes than you and they like to have bigger 
  214. windows when they are first opened!
  215.  
  216. Open windows centered in the *current* screen mode, or over a 
  217. parent window. I hate windows appearing as squitty little things 
  218. in the corner of large multisync modes. I also hate windows 
  219. appearing off the top/side of mode 12...
  220.  
  221. Preferably, check the window position when things happen - if 
  222. the window is fullsized, or if the screen mode changes, check if 
  223. you need to 'bump' the window back onto the screen. At least the 
  224. titlebar should be available so it can be dragged back onto the 
  225. screen! Preferably also allow your windows to be dragged off the 
  226. screen (This means if fullsize is clicked, you must ensure that the 
  227. window doesn't get bigger than the current screen mode)
  228.  
  229.  
  230. Window Templates
  231. ================
  232.  
  233. If you get memory for templates, DON'T trim down the allocated 
  234. memory to the exact byte needed for *your* templates. Add a few 
  235. hundred bytes so we can alter/add to templates without your 
  236. program crashing. This is especially a good idea when you are 
  237. only using half of the WIMPSLOT memory anyway... (Acorn, do 
  238. you hear me? ;-)
  239. If this is a big problem and you are supplying source, give a 
  240. constant./variable that is easily found to change the allocation.
  241.  
  242. In RISC OS 3.00, there is a call to tell you how much memory is 
  243. needed for your Templates to be loaded.
  244.  
  245. 3-d 'plinthy' windows look nice. Some people don't think so, 
  246. though, and it would be very nice if you supply two sets of 
  247. templates, one for 3-d and one for 2-d icons.
  248.  
  249. Note that 'Interface' is incompatible with RISC OS 3.00's way of 
  250. redrawing 3-d icons, so your application will look really crappy in 
  251. RISC OS 3.00.
  252.  
  253.  
  254. Menus
  255. =====
  256.  
  257. Put your menu 96 OS units above the menu bar (40% of PD apps. fail
  258. this one, and it is a right pain!). The TOP menu item of your iconbar
  259. menu should be INFO, and the bottom one should be QUIT.
  260. This calculation is:
  261.   y = 96 + (number_of_items * 44) + (number_of_dotted_lines * 24)
  262.  
  263. Menu items should be 44 OS units high, and the item gap should be 0.
  264. Menu items should be left justified (DON'T center them!)
  265.  
  266. Don't put dangerous items next to innocuous one ins menus. A very bad
  267. example of brain-dead design lies over your floppy :0 drive icon -
  268. notice how dismount, format, verify, are all bunched together?
  269. How many times have *you* hit format instead of dismount?
  270.  
  271.  
  272. Fonts
  273. =====
  274.  
  275. Go to the command-line. Type *FX25 <return>. Go back to the desktop.
  276. Do all of the symbols used in your program look right still? Good.
  277. (If you have really been screwing around in the system, you may 
  278. need a *alphabet bfont as well)
  279.  
  280. If using outline fonts, AT LEAST put an easy to find option or 
  281. variable that can be set to allocate enough room for the font 
  282. menu... most people seem to make their programs to use their 5 
  283. fonts, and don't realise some people have around 300 fonts on 
  284. their hard drives! It is in fact possible to count the number of 
  285. available fonts, and allocate enough memory to read them all.
  286.  
  287. If replacing BFONT with an outline font, remember these points:
  288. * 14 point is usually about the best size - not too big to fit, roughly
  289.   the same size as BFONT, and not so small as to look 'grubby' in low
  290.   res modes (12, 15)
  291. * Use ONE font (family) consistently throughout the app.
  292. * Use ONE (or maybe 2) font size consistently throughout.
  293.   (More sizes means heavy font cache usage - thrashing off disc and
  294.    more memory needed, which are bad things)
  295. * Use Trinity, Homerton, (or Porterhouse) unless you are providing the
  296.   font with the application- these fonts are available to everyone, and
  297.   the first two are in ROM in RO3.
  298. * Give an OPTION to use BFONT.
  299. * Preferably check that there is at least 16k allocated to the font cache
  300.   and drop back to BFONT if this is not the case
  301.  
  302.  
  303. Filing systems
  304. ==============
  305.  
  306. Don't leave files open.
  307. Don't close open files with CLOSE#0 !!!
  308.  
  309. DON'T assume anything about the FS you are run from.
  310. Or the Drive number.
  311. Don't even assume that you can write to the Filing System if it can 
  312. be helped.
  313.  
  314. Don't set the CSD or library or alter any FS paths. Don't alter the 
  315. current filing system.
  316.  
  317. If doing file operations in C, try using setvbuf. I found in 
  318. CBAdecode that a 150% speed improvement resulted off floppies 
  319. (using 16k buffers in place of OS 4k buffers), and seeking was 
  320. drastically reduced on my hard drive.
  321.  
  322.  
  323. Configuration
  324. =============
  325.  
  326. If your program alters the machine in any way (eg redefines system beep,
  327. or changes mouse pointer), make sure that they are restored when it
  328. finally terminates. Be especially careful to make this work when 
  329. the program crashes! (And don't assume that it won't crash!)
  330.  
  331. Don't use *CONFIGURE commands in your applications. They are 
  332. NOT needed for anything you should be doing.
  333.  
  334. Don't *UNPLUG modules you want to kill- *RMKILL them.
  335. Never include a *RMCLEAR command in your programs.
  336.  
  337. Make sure that your program doesn't use any unusual modules or screen
  338. modes, unless they are included with the application.
  339.  
  340. If you need to RMEnsure modules from !System, try to check for the
  341. earliest possible version which will work with your software.
  342.  
  343. If your program uses a module, make sure that if the module is RMCLEARed,
  344. the application will quit cleanly, rather than going into an infinite
  345. loop.
  346.  
  347. Make sure that the memory you ask for in the WimpSlot 
  348. command in your !Run file is equal to the actual amount displayed 
  349. in the task manager window when the program starts running. 4 
  350. Megabyte machine will give you 32kB of memory even if you only 
  351. ask for 8kB, but a 1MB machine will only give you 8kB! This 
  352. causes lots of programs to fail to run on 1/2MB machines.
  353.  
  354. Bearing the above in mind, trim down the WIMPSLOT size to a 
  355. safe minimum.
  356.  
  357.  
  358. Miscellanea
  359. ===========
  360.  
  361. CTRL-Break your machine and then hold down SHIFT so it doesn't 
  362. autoboot. THis should give you a reasonably 'clean' machine, with 
  363. no strange modules, screen modes, etc. Does your program still 
  364. run fine on this 'bare' machine?
  365.  
  366. If a program will not allow users to return to the desktop, display a
  367. warning giving them the chance to return to the desktop before the
  368. program starts running.
  369.  
  370. Use % in front of any *commands you use, and specify ALL options
  371. e.g. "%wipe file ~v ~c r f"
  372. This should get around aliases that do unexpected things and odd
  373.  wipe options configurations that you didn't expect.
  374.  
  375. Get a program that protects zero page and run it. Now run your
  376. application. If you get "Abort on data transfer" errors, you are
  377. writing to places you shouldn't.
  378.  
  379. When files are saved to you from another app., you first get a 
  380. DataSave message including a suggested leafname. REMEMBER THIS LEAFNAME. When
  381. you subsequently get a <Wimp$Scrap> or similar transfer, you can then
  382. use the remembered leafname as the filename instead of <Wimp$Scrap>.
  383. I *hate* the way Edit gets this wrong.
  384.  
  385. MASK OUT NULL POLLS while you aren't using them!
  386. If you need nulls, then use Wimp_PollIdle.
  387. Clocks only need updating every second or so... If only minutes 
  388. are displayed then an update every 10 seconds is close enough. 
  389. Thus, use PollIdle to give you 1 null poll every 10 secs, and save a 
  390. lot of desktop bandwidth to make drags, etc. smoother.
  391.  
  392. When doing long operations, multitask in the background. This is 
  393. not difficult to do, and doesn't affect the speed of your program 
  394. much.
  395. (I found that with 20cs timeslices for processing, there was not
  396. a noticable (to the centisecond, at least) time difference in
  397. processing that took 90 or so seconds... 5 polls in a second just
  398. don't take a noticable time.
  399. This allows people to abort things quickly and allow them to do 
  400. low-bandwidth operations such as editing textfiles while doing 
  401. stuff in the background.
  402.  
  403. Oh, and while multitasking, don't use the hourglass!
  404.  
  405.  
  406. From: jwil1@cs.aukuni.ac.nz (TMOTA)
  407. Message-ID: <1992Jun22.050827.7797@cs.aukuni.ac.nz>
  408. Date: 22 Jun 92 05:08:27 GMT
  409.  
  410. A couple of hours after posting the application writers guide, I ran
  411. Translator 7.10, and came up with a few prime examples of super-no-no's
  412. (No criticism, John, but my f12 key don't work while you've got the caret!)
  413.  
  414. Here are the extra bits... (I didn't think a repost was in order, and
  415. anyway you might not read everything all over again just to find the
  416. 20 new lines...)
  417.  
  418. ---
  419.  
  420. Key presses
  421. ===========
  422.  
  423. ALL unused keypresses should be given back to the wimp.
  424. Important ones to let through are f12 (etc), and ctrl-keys used by Menon
  425. or similar programs, for launching other apps and doing useful things...
  426.  
  427. Up and down arrow keys and return should move the cursor to the next/prev
  428. writable icons of the innput focus window.
  429.  
  430. Try to find out what keypresses other applications use, and don't use them
  431. yourself. e.g. shift-tab seems to be getting a tad overused...
  432.  
  433.  
  434. Mouse clicks/dragging
  435. =====================
  436.  
  437. The WIMP returns different values when the mouse is clicked, dragged, and
  438. double clicked (though you must use the correct button types to get these)
  439. i.e. to start a drag, if you get a button = 1 (select click), you select
  440. the icon, and if you get a 16 (1*16 = 16, select drag), you then start the
  441. drag. This results in a short pause before the drag proper starts.
  442.  
  443. When you do file drags, CHECK SOMEWHERE that you don't drag stuff into
  444. your own windows. The worst is when you accidentally release the mouse
  445. button just as you start dragging, thus dropping the file into the save-as
  446. window... NOTHING *should* happen!
  447.  
  448. If Escape is pressed during a drag, abort the drag. (cf Draw). App.s like
  449. the template editor are very annoying because after you start a drag, you
  450. can't help but move the icon - the best you can do is try to drop it in
  451. the same place - in Draw, you bash escape, and no alteration takes place.
  452.  
  453.