home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / totallyamos / issue3 / programming / 1.seq next >
Text File  |  1992-02-28  |  10KB  |  255 lines

  1.  252
  2. fff0004aff23fe04a6555b0586a
  3. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  4.  
  5.                        ^2{7H I N T S   A N D   T I P S .{
  6.  
  7. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  8.  
  9. ^7 We have gathered hints and tips from several readers for this Issue.
  10.  
  11. ^7Read on for tips from Steve Bennett, Jeff Tullin, Ronnie Simpson and
  12. ^7Aaron Fothergill. 
  13.  
  14. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  15.  
  16. ^5 From Steve Bennett, West Midlands.
  17.  
  18. ^2 Here  is  a  list of commands that are missing from the Amos Manual,
  19. ^2Some you may have heard of, some may be new.
  20.  
  21. ^1 MOUSE SCREEN :  ^2This gives the screen number that the mouse is in.
  22.  
  23. ^1 REQUEST  ON  /  OFF :  ^2This command will turn off the System Request
  24. ^2box  that  pops  up  from  time to time to tell you that your disk is
  25. ^2write  protected  etc.   You will probably have found out by now that
  26. ^2you cannot always get backto to your program after one of these boxes
  27. ^2has appeared.  Request On turns the box on again.
  28.  
  29. ^1 DEL SPRITE N :  ^2Deletes sprite Image number N from the bank.
  30.  
  31. ^1 DEL  SPRITE START TO FINISH :  ^2Deletes sprite image numbers start to
  32. ^2finish.  Do not delete the last image in the bank using Del Sprite as
  33. ^2it crashes the computer - use Erase 1 instead.
  34.  
  35. ^1 INS SPRITE N :  ^2Inserts a sprite into the bank at number N.
  36.  
  37. ^1 DEL ICON N :
  38.  
  39. ^1 DEL ICON START TO FINISH :
  40.  
  41. ^1 INS ICON N :
  42.  
  43. ^1 STOP :  ^2Stops the program.
  44.  
  45. ^1 CHANMA()  :   ^2I  assume  this tests for an AMAL channel that is just
  46. ^2running an animation.  I have not tested it yet
  47.  
  48. ^1 AMOS HERE :
  49.  
  50. ^1 AMOS LOCK :  ^2Amos Lock disables the <LEFT AMIGA + A> from being used
  51. ^2together  to  toggle  between  different programs in memory.  This in
  52. ^2effect stops the Amiga multi-tasking on more than one program.
  53.  
  54.   ^1AMOS UNLOCK : enables these keys.
  55.  
  56.                                                      ^7Steve Bennett.
  57.  
  58. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  59.  
  60. ^4 The  next  tip  was  picked  up from Aaron Fothergill, who being the
  61. ^4generous person that he is with his coding tips, has said that we can
  62. ^4use it!
  63.  
  64. ^5 This  tip  will be of interest to programers who frequently use data
  65. ^5banks to store ascii text etc.
  66.  
  67. ^4 To  explain  this  tip, we will have to give an example application,
  68. ^4giving a listing would probably confuse matters.
  69.  
  70. ^6 The  thing  I  used  it  for required me to look inside a bank for a
  71. ^6sentence,  then  pull out the sentence and store it as a string.  The
  72. ^6usual method for doing this would be as folows.
  73.  
  74. ^61.  Find the start position in memory of the sentence in question.
  75.  
  76. ^62.  Find the end location in memory of the sentence.
  77.  
  78. ^7 Now you'd use a For Next Loop to peek out each character in turn and
  79. ^7store  as  a  string.  This is fine for a single sentence, but if you
  80. ^7are  talking of pulling out multiple sentences, it can turn out to be
  81. ^7a very lengthy process.
  82.  
  83. ^6 To save an enormous amount of time, use the following method.
  84.  
  85. ^7 Initially  you do the same as before, follow 1 & 2 above.  This time
  86. ^7however, you find out how many characters there are between the start
  87. ^7and finish of the sentence..  Now you must check to see if the number
  88. ^7of  characters  is  even.   If  it  is  odd, add one to the amount of
  89. ^7characters  and one to the end position in memory.  Now set a flag to
  90. ^7true  to  let you know that you originally had an odd number.  That's
  91. ^7the hard bit over with, the rest is easy!
  92.  
  93. ^6 Let  us  assume  that the length is 50 characters, in the old method
  94. ^6we'd  use a For Next Lop to read the characters, but now all you have
  95. ^6to do is this,
  96.  
  97. ^2 Sentence$=Space$(number of characters)
  98.  ^2Copy start position, end position, to Varptr(Sentence$)
  99.  
  100.  ^7This  does  it  all in one transaction rather than the fifty used by
  101. ^7the previous method.  The difference in speed is amazing!
  102.  
  103.  ^6The  main  thing  to  watch  out  for is the fact that the number of
  104. ^6characters  MUST  be an EVEN number.  Using the copy command with odd
  105. ^6numbers  will only give you a randomly locking machine or a big, red,
  106. ^6flashing box!
  107.  
  108.  ^7This idea is well worth mastering as it wil make your programs a lot
  109. ^7faster and therefore more acceptable to your users.
  110.  
  111.                                                         ^2Thanks Aaron!
  112.  
  113.  
  114. ^7In case you do not know how to check for odd numbers, try this.
  115.  
  116.  ^2P=noofcharacters Mod 2
  117.  ^2If P=1
  118.  ^2noofcharacters = noofcharacters + (noofcharacters Mod 2)
  119. ^7(above line sets the odd numbers) 
  120.  ^2End If
  121.  
  122.  ^6Checking  on the odd numbers after the copy will tell you to cut off
  123. ^6the  last  character  and  the Mod line will add one to the number of
  124. ^6characters if odd.
  125.                                                                  ^7Len.
  126.  
  127. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  128.  
  129.  ^1Jeff Tullin has given us permission to use some tips he has found.
  130.  
  131. ^11. There is another problem with Workbench 2 and AMOS, this time
  132. ^1concerning fonts.It occurs if you have created a program an a version
  133. ^1of Workbench other than V2, ie 1.2 or 1.3.  
  134.  
  135.  ^1When you run it on a machine using WB2, you may find that your text
  136. ^1has `grown' and your display is out. Jeff has come up with a solution
  137. ^1for you, we cann't test it for ourselves, but according to Jeff, this
  138. ^1is what you do:-
  139.  
  140.  ^1Open a small work screen. Here we will say it is Screen X.
  141.  
  142.  ^1Screen Open (X) ,320,10,(no of colours),lowres
  143.  
  144.  ^1When  you  want  to  output  to  your  display screen, you jump to a
  145. ^1procedure called JEFFTEXT(square bracket)a,b,T$(sq.brk)
  146.  
  147.  ^2Procedure JEFFTEXT(sq.brk)a,b,T$(sq.brk)
  148.  
  149.  ^2Screen (X) 
  150.  
  151.  ^2Get Palette (Display screen)
  152.  
  153.  ^2Cls 0
  154.  
  155.  ^2Locate 0,0
  156.  
  157.  ^2Print T$; ^1(the ; is essential or it will carriage return and
  158.            ^1disappear off the top of the screen) 
  159.  
  160.  ^2Screen Copy(X),0,0, Len(T$)*8,8 to Screen(display screen),a,b-6
  161.  
  162.  ^2Screen(display screen)
  163.  
  164.  ^2End Proc
  165.  
  166.  ^1We hope this will solve the problem.
  167.  
  168.  ^7Jeff's  next  tip concerns the creation of animated buttons.  If you
  169. ^7have  TA1 and/or TA2, you will have seen the indenting buttons on the
  170. ^7alert  box routine and in the alternative file requester.  These were
  171. ^7created  by  drawing  lines  with selected colours to get the desired
  172. ^7effect.
  173.  
  174.  ^7Jeff's  method is even simpler.  All you need to do is draw a bar (a
  175. ^7solid  rectangle)  in  any colour OVER the button you want to indent,
  176. ^7but first you must put in the command
  177.  
  178.  ^2Grwriting 3
  179.  
  180.  ^6This  indents  the  button.  To get it back to normal, put Grwriting
  181. ^6back  to  normal  and just draw your bar again.  (wish I'd thought of
  182. ^6that!  Len)
  183.  
  184.  ^310/10 for this tip!
  185.  
  186.  ^7Jeff  has  also  found  a  way of changing the colours of the system
  187. ^7request box.
  188.  
  189.  ^6First make a backup of your AMOS disk, or at least a copy of the
  190. ^6Request.lib file incase you do not like the colours you have created!
  191.  
  192.  ^7Key in the following as set out below
  193.  
  194.  ^2Reserve as work 10,1440
  195. ^2Bload "amos_system/request.lib",Start(10)
  196. ^2A=Start(10)+$494
  197. ^2Doke A,$0
  198. ^2Doke A+2,$444
  199. ^2Doke A+4,$888
  200. ^2Doke A+6,$FFF
  201. ^2Bsave "Amos_system/request.lib,Start (10) To Start(10)+Length(10)
  202.  
  203. ^7Run, then reboot to see the differences!
  204.  
  205. ^7You  can  alter the RGB colour values to suit yourself, but try these
  206. ^7colours.
  207.  
  208. ^4Thank  you  Jeff for providing so many tips for this issue, it's nice
  209. ^4to see new names in the magazine.
  210.  
  211. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  212.  
  213. ^4 Ronnie  Simpson  sent  in  a  tip  for dot matrix printer users, our
  214. ^4printer doesn't use ribbons, so we haven't tested this one!
  215.  
  216. ^7 "A  little  tip that I picked up recently may be of interest to some
  217. ^7of  your  readers  who  own  printers.....Imagine  that  you  have an
  218. ^7important letter or listing that you must get printed and your ribbon
  219. ^7is  worn and producing only the lightest shade of grey, the shops are
  220. ^7closed and you have no spare ribbon.  What do you do?
  221.  
  222. ^5 Answer....Grab  a can of WD40 (damp start for cars) or similar, give
  223. ^5the ribbon a quick spray, and Bob's your uncle - nice black sparkling
  224. ^5print."
  225.                                                       ^2Ronnie Simpson.
  226.  
  227. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  228.  
  229. ^5 If  you  are  the protective type and want to hide your data for one
  230. ^5reason or another, this is a fairly efficient way of doing so.
  231.  
  232.  ^5You  do this by reading each character in a string, converting it to
  233. ^5an  ascii number, rolling it, then storing it back in a string.  This
  234. ^5will make the data unreadable, and easy to decode.
  235.  
  236.  ^5To  code  the data, lets assume that you want to code the letter `A'
  237. ^5by this method.
  238.  
  239.  ^2To do this you use the command Rol.b 1,A
  240.  
  241.  ^51  is the amount rolled to the left, and A is the ascii value of the
  242. ^5letter to be rolled.  To decode, all you have to do is Ror.b 1,A
  243.  
  244.  ^5The  niffty bit in this idea is the number, here it is 1, you decide
  245. ^5the number for the roll, so that you can make it harder to decode for
  246. ^5anyone else.
  247.  
  248.  ^5This  method is by no means perfect, but if you wish to protect your
  249. ^5data,  it  will  give  anyone  trying  to  unscramble  it  a bit of a
  250. ^5headache,  as  you are the one who knows the key number.  It will end
  251. ^5in failure for someone who isn't really sure of what they are doing!
  252.  
  253. ^6|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|
  254. \
  255.