home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / 326-350 / apd341 / programming / tips.seq < prev   
Text File  |  1991-07-19  |  7KB  |  225 lines

  1.  222
  2. eca00007cf00fe008033300f70f
  3. ^4********************************************************************
  4.  
  5.                                ^3T. I. P. S.
  6.  
  7.                      ^2[3(Tiny Informative Pieces Spot.)[0
  8.                        
  9.                               [5^6By Len Tucker.[0
  10.  
  11. ^4*******************************************************************
  12.  
  13. ^5 Here are just a few things that I have discovered along the way and
  14. ^5which I have found very useful.
  15. ^5 More than likely, the majority of programmers will know most, if
  16. ^5not all, of these little tips, but just in case any learners 
  17. ^5(like me) are reading this, you will find these useful to know.
  18.  
  19. ^4--------------------------------------------------------------------
  20.  
  21. [3^2NUMBER 1:[0
  22.  
  23. ^1  Instead of using `Dec' to reduce a variable  E.G.
  24.  
  25. ^7B=6
  26. ^7Dec B
  27. ^7Dec B
  28. ^7Print B
  29.  
  30. ^24
  31.  
  32. ^1or
  33.  
  34. ^7B=50
  35. ^7For Z=1 to 10
  36. ^7Dec B
  37. ^7Next Z
  38.  
  39. ^1or
  40.  
  41. ^7B=50
  42. ^7B=B-10
  43.  
  44. ^1Try using the add command like so:-
  45.  
  46. ^7Add B,-2
  47.  
  48. ^7or Add B,-10
  49.  
  50. ^1Both of which do the same thing, but in less lines! (It also saves
  51. ^1wear and tear on the fingers!) 
  52.  
  53. ^2 The saving is obvious with the `For Next Loop' version but not so
  54. ^2obvious with the B=B-10 version. It seems that the add command is
  55. ^2much faster so use it as often as you can.
  56.  
  57. ^4------------------------------------------------------------------
  58.  
  59. [3^2NUMBER 2:[0
  60.  
  61. ^6  When you want to change a numeric variable (A,SCORE,LIVES,Etc)
  62. ^6to a string variable, for printing with the `Text' command
  63. ^6there is a space inserted at the begining of the string, this is
  64. ^6because when a computer sees a numeric variable, it could be one of
  65. ^6two things, either a positive or a negative, so it precedes every
  66. ^6number with a space in case it becomes a negative "-".
  67.  
  68. ^6E.G.
  69.  
  70. ^7SCORE=4532
  71. ^7SCORE$=Str$(SCORE)
  72. ^7Print SCORE$
  73.  
  74. ^2 4532
  75.  
  76. ^6 The leading space can cause you display troubles so it is better to
  77. ^6get rid of it.
  78.  
  79. ^6 The way I used to do it was:-
  80.  
  81. ^7SCORE=4532
  82. ^7T$=str$(SCORE)
  83. ^7SCORE$=Mid$(t$,2,Len(t$))
  84. ^7Print SCORE$
  85.  
  86. ^24532
  87.  
  88. ^6 Now I use a command I spotted in the compiler manual `-' it seems
  89. ^6this was in all versions of AMOS but not mentioned!
  90.  
  91. ^6 Using this new(?) command the above routine would look like:-
  92.  
  93. ^7SCORE=4532
  94. ^7SCORE$=Str$(SCORE)-" "
  95. ^7Print SCORE$
  96.  
  97. ^24532
  98.  
  99. ^6 This little command does not stop there! It will strip ALL
  100. ^6occurances of the character inside the inverts from the target
  101. ^6string!!
  102.  
  103. ^6 E.G.
  104.  
  105. ^7A$="The cat sat on the mat"
  106. ^7B$=A$-" "
  107. ^7Print B$
  108.  
  109. ^2Thecatsatonthemat
  110.  
  111. ^7A$="The cat sat on the mat"
  112. ^7B$=A$-"at"
  113. ^7Print B$
  114.  
  115. ^2The c s on the m
  116.  
  117. ^6 This could be very useful if handled properly.
  118.  
  119. ^4------------------------------------------------------------------
  120.  
  121. [3^2NUMBER 3:[0
  122.  
  123. ^5  Sometimes in a game you need to dump certain Bobs or Sprites from
  124. ^5the Sprite bank. An easy way to do this is use the undoccumented
  125. ^5command (yet another!) called Del Bob. Let's say that you have 30
  126. ^5Bobs in your Bank and for some reason you want to dump the Bobs
  127. ^5numbered from 15 to 25 in order to bring back some memory. Perhaps
  128. ^5these bobs have already performed their function and are now
  129. ^5obsolete, so are a waste of memory, it is very easy to get rid of
  130. ^5them with:-
  131.  
  132. ^7Del Bob 15 To 25
  133.  
  134. ^2Now Bob 26 becomes 15 and so on.
  135.  
  136. ^4------------------------------------------------------------------
  137.  
  138. [3^2NUMBER 4:[0
  139.  
  140. ^1 Supplied by[3 ROD PASCOE[0 some of you will find the Dos numbers very
  141. ^1useful.^2 Thanks Rod!
  142.  
  143. ^4 This tip is for the more advanced programmer, as it can cause the
  144. ^4machine to Guru if not used with discretion. I have tried it on
  145. ^4several programs, and it seems to work O.K.
  146.  
  147. ^1 The following routine allows you to call and execute a non Amos
  148. ^1program from inside Amos e.g. PPmore, Diskmaster etc.
  149. ^1 Its limits are amount of available memory and the support files
  150. ^1needed to run the program.
  151.  
  152. ^2 Let's use PPmore as an example. PPmore needs the PowerPacker ARP
  153. ^2library in the libs dir to work.
  154.  
  155. ^7 Amos To Back
  156. ^7 COM$="PPmore"
  157. ^7 Dreg(0)=Varptr(COM$)
  158. ^7 Dreg(1)=0
  159. ^7 Dreg(2)=0
  160. ^7 A=Doscall(-222)
  161. ^7 Amos To Front
  162.  
  163. ^2 This will execute and run PPmore, once you kill PPmore, you're taken
  164. ^2back to AMOS.
  165.  
  166. ^1 Use LEFT AMIGA-A keys to toggle between the two.
  167.  
  168. ^4 This is very handy if you have a large `help' file to display as it
  169. ^4saves writing a routine to display it, BUT beware of copyright
  170. ^4problems, any program which calls a copyright program will not be
  171. ^4eligable for licenseware!!!!!
  172.  
  173. ^4---------------------------------------------------------------------
  174.   
  175. ^2[3NUMBER 5:[0
  176.  
  177. ^1 If you've been having Compiler problems, like I have, then this tip
  178. ^1will solve one of them.
  179.  
  180. ^6 Sometimes after a program has been compiled, you'll find that the
  181. ^6mouse will only move across 2/3rds of the screen, which is no good if
  182. ^6you need to click on buttons on the other 1/3rd of the screen.
  183.  
  184. ^6 An easy way around this is to put in  Limit Mouse. For NTSC screens
  185. ^6this is from 128,50 to 438,249  and for PAL screens 128,43 to
  186. ^6438,294. This completely cures the problem.
  187.  
  188. ^4---------------------------------------------------------------------
  189.  
  190. ^2[3NUMBER 6:[0
  191.  
  192. ^1 This is the answer to another compiler bug. If you remember, one of
  193. ^1the older versions of RAMOS had to have a default screen opened. The
  194. ^1Compiler has the same problem, so either get the Compiler to open a
  195. ^1default screen for you, or do it in your program.
  196.  
  197. ^4---------------------------------------------------------------------
  198.  
  199. ^2[3NUMBER 7:[0
  200.  
  201. ^2 A simple way of centring text.
  202.  
  203. ^6 If you want to centre a piece of text on the screen using the Text
  204. ^6command, try this.
  205.  
  206. ^7 A$="This is centred."        ^1- put your text in the " "
  207. ^7 L=len(A$)*8                  ^1- the 8 assumes you are using the Amos
  208.                                 ^1default font.
  209. ^7 Text160-(L/2),10,A$          ^1- Assumes you have a normal 320 wide
  210.                                 ^1screen. If not, replace the 160 with
  211.                                 ^1your screen width divided by 2.
  212.  
  213.  ^2This easily centres text and will give you neater displays.
  214.  
  215. ^4---------------------------------------------------------------------
  216.  
  217. ^1 That's it for this issue, I hope that you find the above tips useful.
  218. ^1Do not forget, if you have any tips or hints that could help the
  219. ^1learners among us PLEASE send them in, they might be of use to
  220. ^1someone, so don`t be mean with your knowledge spread it about a bit!
  221. ^1You will feel better for it!!
  222.  
  223. ^4********************************************************************
  224. \
  225.