home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / prog_bar.lha / prog_bar / Docs / readme.txt < prev   
Encoding:
Text File  |  1997-01-12  |  14.4 KB  |  409 lines

  1.  
  2.                                 Prog_Bar.Lib
  3.                                 ============
  4.  
  5.              A progress bar link library for Amiga Programmers
  6.              =================================================
  7.  
  8.                        Written by Allan Savage © 1996
  9.                        ==============================
  10.  
  11.  
  12. Introduction
  13. ============
  14.  
  15. Prog_Bar.lib  is  a  progress  bar  link library designed to make it easy to
  16. create,  manage  and delete progress bars within most programming languages.
  17. It  has  been  tested  using  Dice  C,  Devpac  3  Assember, SAS/C and Turbo
  18. Modula-2.
  19.  
  20. The  library  is  easy to use and provides a large range of options for your
  21. progress  bars.   It  has  been  designed to operate in a similar way to the
  22. GadTools functions for managing gadgets, so the ideas involved should not be
  23. new to anyone who might be using them (except possibly assembly programmers.
  24. See "Usage" for more details).
  25.  
  26. The  library  is  capable of producing many different types of progress bars
  27. using  a simple set of parameters.  These allow the programmer to completely
  28. customise  a  progress  bar by changing its border, colours, size, location,
  29. dimensions, direction and text.
  30.  
  31. To  give you an idea of what is possible using this system I have included a
  32. few  demonstration  programs complete with source code so that you can learn
  33. from the techniques used to control a progress bar.
  34.  
  35.  
  36.  
  37. Installation
  38. ============
  39.  
  40. How  to  install and use the library really depends on which environment you
  41. want  to  use it in.  I will provide a general outline of the various stages
  42. and  a more detailed description of how I installed it with each system.  In
  43. each case you may be using a different system, but if you follow the general
  44. guidelines you should not have much difficulty.
  45.  
  46. I  will  also show the commands I used to compile and link the demo programs
  47. for each system.
  48.  
  49. The  documentation includes an Amigaguide file called prog_bar.guide .  This
  50. contains  a  detailed description of each function and can be copied to your
  51. compiler's   document   directory,  or  can  be  linked  into  the  Autodocs
  52. documentation  if  you have it installed.  A plain text version of this file
  53. is also supplied.  It is called "prog_bar.doc".
  54.  
  55.  
  56. C Installation
  57. --------------
  58.  
  59. The C system is comprised of two files, "prog_bar.h" and "prog_bar.lib".
  60.  
  61. "prog_bar.h"  should  be  copied to anywhere on your compiler's include file
  62. search path.  Just make sure you know where you put it because you will need
  63. to #include it any time you want to use prog_bar.
  64.  
  65. For  Dice  I  created a directory called "DINCLUDE:library" and copied it to
  66. there.
  67.  
  68. "prog_bar.lib"  should  be  copied  to  anywhere  on your compiler's library
  69. search  path.   Alternatively you could put it anywhere and then specify its
  70. full pathname when linking.
  71.  
  72. In Dice I copied it to "DCC:dlib/"
  73.  
  74.  
  75. Assembler Installation
  76. ----------------------
  77.  
  78. The   Assembler   system   is  comprised  of  two  files,  "prog_bar.i"  and
  79. "prog_bar.lib".
  80.  
  81. "prog_bar.i"  should  be copied to anywhere on your assembler's include file
  82. search path.  Just make sure you know where you put it because you will need
  83. to include it any time you want to use prog_bar.
  84.  
  85. For Devpac I copied it to the "Devpac/include/libraries" directory.
  86.  
  87. "prog_bar.lib"  should  be  copied  to  anywhere on your assembler's library
  88. search  path.   Alternatively you could put it anywhere and then specify its
  89. full pathname when linking.
  90.  
  91. In Devpac I copied it to "Devpac/lib/"
  92.  
  93.  
  94. Modula-2 Installation
  95. ---------------------
  96.  
  97. The   Modula-2   system   is   comprised  of  three  files,  "prog_bar.def",
  98. "prog_bar.sym" and "prog_bar.lib".
  99.  
  100. "prog_bar.def"  should be copied to anywhere on your compiler's include file
  101. search path.  Just make sure you know where you put it because you will need
  102. to import it any time you want to use prog_bar.
  103.  
  104. For Turbo Modula-2 I copied it into the "Modula_2/amiga/" directory.
  105.  
  106. "prog_bar.sym"  should  be  copied to your compiler's symbol file directory.
  107. If  the  "prog_bar.sym"  file is not of the correct format for your compiler
  108. you will need to recreate it.  This is done by compiling "prog_bar.def".
  109.  
  110. For Turbo Modula-2 I copied it into the "Modula_2/sym/" directory.
  111.  
  112. "prog_bar.lib"  should  be  copied  to  anywhere  on your compiler's library
  113. search  path.   Alternatively you could put it anywhere and then specify its
  114. full pathname when linking.
  115.  
  116. For Turbo Modula-2 I copied it into the "Modula_2/lib/" directory.
  117.  
  118.  
  119. N.B.   I  have  my  copy  of  Turbo  Modula-2  installed  in  the "Modula_2"
  120. directory.
  121.  
  122.  
  123.  
  124. Usage
  125. =====
  126.  
  127. General Description
  128. -------------------
  129.  
  130. Using  the  system  should  now  be  (almost)  as simple as using any of the
  131. operating system libraries.  When you write a program which needs a progress
  132. bar  just include the relevant definition file at the top of your source and
  133. remember to link your object file to prog_bar.lib.
  134.  
  135. To  actually  create  and handle a progress bar within your program you will
  136. need  to  follow  the  rough guide given below.  However, every situation is
  137. different  so  you  might  need  to  vary  your approach.  All the available
  138. functions are documented in the function list.
  139.  
  140. N.B.   Because all of the necessary functions will be linked into your final
  141. executable it is completely unnecessary to open the library at runtime.
  142.  
  143.  
  144. Step 1.
  145.  
  146. Work  out  what  size  your  bar has to be.  Note that the size is the value
  147. represented  by  the  full  bar.   It  is  not  related  to the bar's actual
  148. dimensions.
  149.  
  150. How you do this will depend on what you are using the bar for.  For example,
  151. if  you want to represent a percentage the size would be 100.  If you wanted
  152. to  use  a progress bar while printing the size might be the number of lines
  153. to be printed.
  154.  
  155.  
  156. Step 2.
  157.  
  158. Create a suitable progress bar using CreateProgBarA() or CreateProgBar() .
  159.  
  160.  
  161. Step 3.
  162.  
  163. Every  time  your  program  completes  one unit of whatever it is doing, you
  164. should  use  UpdateProgBar()  to display the new position.  For the examples
  165. above  this would mean updating the bar after one percent, or after printing
  166. each line.
  167.  
  168. If  the  value  of  the  bar  is  decreasing  and you have the text function
  169. activated,  it  will  probably  be necessary to call ClearText() immediately
  170. before  updating  the  bar.   This  is  not necessary if the text is centred
  171. within the bar, or if the length of the text never decreases.
  172.  
  173.  
  174. Step 4.
  175.  
  176. When  you  have  finished you should delete the progress bar and release the
  177. memory used by calling FreeProgBar() .
  178.  
  179.  
  180. Step 5.
  181.  
  182. When your window needs refreshed you should call RefreshProgBar() .
  183.  
  184.  
  185. Using Prog_Bar in C
  186. -------------------
  187.  
  188. When  writing  your  source  you  will need to include the file "prog_bar.h"
  189. before  you  use  any of the functions, otherwise the compiler will complain
  190. about undefined structures, etc.
  191.  
  192. In Dice I use the line "#include <library/prog_bar.h>".
  193.  
  194. When  compiling  you will then need to tell the compiler to include the code
  195. for  the  prog_bar  functions.   This  is  done  by  linking  your  code  to
  196. "prog_bar.lib".   In some compilers, or with large multi-module programs, it
  197. will  be  necessary to compile your source to *.o files, and then link these
  198. and  prog_bar.lib  together to produce the executable.  If your program is a
  199. single  source  file  then  you  might  be  able  to  compile it and link to
  200. prog_bar.lib  in  one instruction.  Your compiler documentation will contain
  201. more detailed information about this.
  202.  
  203. To  compile  the demo with Dice I was able to compile the source and perform
  204. the  link  in  one operation.  The command line to do this was "dcc -2.0 -//
  205. -Tt:  -o Demo Demo.c prog_bar.lib".
  206.  
  207.  
  208. Calling the prog_bar functions uses exactly the same notation as any other C
  209. function, e.g.  "ClearProgBar(PBar);".
  210.  
  211.  
  212. Using Prog_Bar in Assembler
  213. ---------------------------
  214.  
  215. When  writing  your  source  you  will need to include the file "prog_bar.i"
  216. before  you  use any of the functions, otherwise the assembler will complain
  217. about undefined symbols, etc.
  218.  
  219. In Devpac I use the line "include libraries/prog_bar.i".
  220.  
  221. To  produce your final executable you will need to assemble your source as a
  222. linkable  file.   The  resulting  *.o  file will then need to be linked with
  223. Prog_Bar.
  224.  
  225. To  create  the  demo program with Devpac I created my source in a directory
  226. called  "Devpac/Progs".   From  here  the command to link the executable was
  227. "BLINK demo.o TO demo LIB /lib/prog_bar.lib".
  228.  
  229. Your  assembler  documentation  will contain more detailed information about
  230. assembling and linking programs.
  231.  
  232.  
  233. Calling  the  prog_bar  functions is different from all the operating system
  234. functions.   The  reason  is because the library has been written to be used
  235. from  C  with  the  minimum  of  fuss, and as such each function expects its
  236. parameters to be placed on the stack, NOT in the registers.
  237.  
  238. Before  calling  a  prog_bar  function  you must place its parameters on the
  239. stack  in  the  reverse order, i.e.  right to left.  Each value you place on
  240. the  stack MUST be a longword value, even if the parameter type is a word or
  241. byte value.
  242.  
  243. To actually call the function you just use a JSR instruction.  The target of
  244. the  jump will be the function name preceded by an underscore, e.g.  to call
  245. CreateProgBar() you use the instruction "JSR _CreateProgBar".
  246.  
  247. When  the  function  returns you are responsible for removing its parameters
  248. from the stack.  Any return values will be in the register D0.
  249.  
  250.  
  251. An  example  from  the  demo program is this small piece of code which calls
  252. CreateProgBarA() and stores the result in PBar_ptr.
  253.  
  254.  
  255.    bar = CreateProgBarA ( Wnd, Left, Top, Width, Height, Size, taglist )
  256.  
  257.  
  258.          *  create the progress bar
  259.             pea.l    pbar_tags         ;  taglist
  260.             move.l   max_size,-(sp)    ;  Size
  261.             move.l   #30,-(sp)         ;  Height
  262.             move.l   #300,-(sp)        ;  Width
  263.             move.l   #65,-(sp)         ;  Top
  264.             move.l   #100,-(sp)        ;  Left
  265.             move.l   windowptr,-(sp)   ;  Wnd
  266.             jsr      _CreateProgBarA   ;  Call CreateProgBarA()
  267.             move.l   d0,PBar_ptr       ;  bar
  268.             lea      28(sp),sp         ;  remove parameters from stack
  269.                                        ;  7 parameters * 4 bytes each = 28
  270.  
  271.          pbar_tags
  272.             dc.l     PB_BorderType,PBBT_RIDGE
  273.             dc.l     PB_TextMode,PBTM_PERCENT
  274.             dc.l     PB_TextPosition,PBTP_CENTRE
  275.             dc.l     TAG_DONE
  276.  
  277.          windowptr   dc.l     0
  278.          max_size    dc.l     200
  279.          PBar_ptr    dc.l     0
  280.  
  281.  
  282. Using Prog_Bar in Modula-2
  283. --------------------------
  284.  
  285. When  writing  your  source  you will need to import the file "prog_bar.def"
  286. before  you  use  any of the functions, otherwise the compiler will complain
  287. about undefined structures, etc.
  288.  
  289. In Turbo Modula-2 I use the line "IMPORT P := prog_bar".
  290.  
  291. When  compiling  you will then need to tell the compiler to include the code
  292. for  the  prog_bar  functions.   This  is  done  by  linking  your  code  to
  293. "prog_bar.lib".   Your  compiler  documentation  will  contain more detailed
  294. information about this.
  295.  
  296. To  compile  the demo with Turbo Modula-2 I just added "prog_bar.lib" to the
  297. end  of  my compile command.  The resulting command line to achieve this was
  298. "m2b Demo prog_bar.lib".
  299.  
  300.  
  301. Calling  the  prog_bar functions uses exactly the same notation as any other
  302. Modula-2 function, e.g.  "P.ClearProgBar(PBar);".
  303.  
  304.  
  305.  
  306. Demonstration Programs
  307. ======================
  308.  
  309. The Library can currently be used from Modula-2, C and Assembly Language.  I
  310. have  included  small example programs in each language so that you can test
  311. the library with your compiler before writing anything of your own.
  312.  
  313.  
  314. All Programmers
  315. ---------------
  316.  
  317. The demo program written in C is by far the largest of the demo programs.  C
  318. is  my preferred language so I used this program as a complete demonstration
  319. of  everything  the library can do.  As such it is probably worth looking at
  320. even if you do not normally program in C.
  321.  
  322.  
  323. Assembly Programmers
  324. --------------------
  325.  
  326. This  is  a small program which creates a progress bar and then slowly fills
  327. it.  When full, the bar is reset and the process repeats.  Just click on the
  328. Window's Close gadget to end the program.
  329.  
  330.  
  331. Modula-2 Programmers
  332. --------------------
  333.  
  334. This  is  also a small program.  It fills a progress bar in steps of 1, then
  335. changes  the  direction,  border and text mode of the bar, and then fills it
  336. again in steps of 5.  You just have to wait until it has finished.
  337.  
  338.  
  339.  
  340. Distribution
  341. ============
  342.  
  343. Prog_Bar is Copyright © Allan Savage 1996.  All Rights Reserved.
  344.  
  345. Prog_Bar  is freely distributable, providing that no commercial gain is made
  346. from its distribution, and no modification is made to the original archive.
  347.  
  348. Anyone  wishing to include Prog_Bar on a magazine coverdisk or other similar
  349. collection,  or  use it in any application, commercial or otherwise, have my
  350. full permission.  All I ask in return is to be acknowledged somewhere in the
  351. documentation and to be told about it (preferably by e-mail).
  352.  
  353.  
  354.  
  355. Disclaimer
  356. ==========
  357.  
  358. This  software  is  provided  "AS  IS"  without warranty of any kind, either
  359. expressed  or implied, including, but not limited to, the implied warranties
  360. of  merchantability  and  fitness for a particular purpose.  The author does
  361. not guarantee the use of, or the results of the use of, this software in any
  362. way.   In  no  way  will  the  author  be  held liable for direct, indirect,
  363. incidental, or consequential damages to data or equipment resulting from the
  364. use of this software.
  365.  
  366.  
  367.  
  368. Acknowledgements
  369. ================
  370.  
  371. The  Demonstration  program  was also compiled using DICE v2.07.56 R and its
  372. interface  was designed using GadToolsBox v37.300.  Thanks to Matthew Dillon
  373. and Jan van den Baard for these excellant programs.
  374.  
  375. Many  thanks also to Roberto Bizzarri for his assistance in testing Prog_Bar
  376. v1.1 with SAS/C.
  377.  
  378.  
  379.  
  380. How to contact me
  381. =================
  382.  
  383. If  you  have  any  suggestions  for  improving  Prog_Bar, bugs to report or
  384. queries  about  the  program, please send them to me at one of the addresses
  385. below.
  386.  
  387.         E-Mail :  asavage@bitsmart.com         (preferred option)
  388.                   asavage@enterprise.net
  389.  
  390.         Post   :  Mr. Allan Savage
  391.                   2 Navar Drive
  392.                   Gransha Road
  393.                   Bangor
  394.                   N. Ireland
  395.                   BT19 7SW
  396.  
  397.  
  398.  
  399. Program History
  400. ===============
  401.  
  402. V1.0   13/12/96   - Initial Release.  (Only worked with Dice)
  403.  
  404. V1.1   11/01/96   - Rewritten  in  Assembly  language.   Now  works with all
  405.                     compilers (hopefully).
  406.                   - Added definiton files for Assembler and Modula-2.
  407.                   - Added Demo programs for Assembler and Modula-2.
  408.  
  409.