home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
326-350
/
apd341
/
programming
/
tips.seq
< prev
Wrap
Text File
|
1991-07-19
|
7KB
|
225 lines
222
eca00007cf00fe008033300f70f
^4********************************************************************
^3T. I. P. S.
^2[3(Tiny Informative Pieces Spot.)[0
[5^6By Len Tucker.[0
^4*******************************************************************
^5 Here are just a few things that I have discovered along the way and
^5which I have found very useful.
^5 More than likely, the majority of programmers will know most, if
^5not all, of these little tips, but just in case any learners
^5(like me) are reading this, you will find these useful to know.
^4--------------------------------------------------------------------
[3^2NUMBER 1:[0
^1 Instead of using `Dec' to reduce a variable E.G.
^7B=6
^7Dec B
^7Dec B
^7Print B
^24
^1or
^7B=50
^7For Z=1 to 10
^7Dec B
^7Next Z
^1or
^7B=50
^7B=B-10
^1Try using the add command like so:-
^7Add B,-2
^7or Add B,-10
^1Both of which do the same thing, but in less lines! (It also saves
^1wear and tear on the fingers!)
^2 The saving is obvious with the `For Next Loop' version but not so
^2obvious with the B=B-10 version. It seems that the add command is
^2much faster so use it as often as you can.
^4------------------------------------------------------------------
[3^2NUMBER 2:[0
^6 When you want to change a numeric variable (A,SCORE,LIVES,Etc)
^6to a string variable, for printing with the `Text' command
^6there is a space inserted at the begining of the string, this is
^6because when a computer sees a numeric variable, it could be one of
^6two things, either a positive or a negative, so it precedes every
^6number with a space in case it becomes a negative "-".
^6E.G.
^7SCORE=4532
^7SCORE$=Str$(SCORE)
^7Print SCORE$
^2 4532
^6 The leading space can cause you display troubles so it is better to
^6get rid of it.
^6 The way I used to do it was:-
^7SCORE=4532
^7T$=str$(SCORE)
^7SCORE$=Mid$(t$,2,Len(t$))
^7Print SCORE$
^24532
^6 Now I use a command I spotted in the compiler manual `-' it seems
^6this was in all versions of AMOS but not mentioned!
^6 Using this new(?) command the above routine would look like:-
^7SCORE=4532
^7SCORE$=Str$(SCORE)-" "
^7Print SCORE$
^24532
^6 This little command does not stop there! It will strip ALL
^6occurances of the character inside the inverts from the target
^6string!!
^6 E.G.
^7A$="The cat sat on the mat"
^7B$=A$-" "
^7Print B$
^2Thecatsatonthemat
^7A$="The cat sat on the mat"
^7B$=A$-"at"
^7Print B$
^2The c s on the m
^6 This could be very useful if handled properly.
^4------------------------------------------------------------------
[3^2NUMBER 3:[0
^5 Sometimes in a game you need to dump certain Bobs or Sprites from
^5the Sprite bank. An easy way to do this is use the undoccumented
^5command (yet another!) called Del Bob. Let's say that you have 30
^5Bobs in your Bank and for some reason you want to dump the Bobs
^5numbered from 15 to 25 in order to bring back some memory. Perhaps
^5these bobs have already performed their function and are now
^5obsolete, so are a waste of memory, it is very easy to get rid of
^5them with:-
^7Del Bob 15 To 25
^2Now Bob 26 becomes 15 and so on.
^4------------------------------------------------------------------
[3^2NUMBER 4:[0
^1 Supplied by[3 ROD PASCOE[0 some of you will find the Dos numbers very
^1useful.^2 Thanks Rod!
^4 This tip is for the more advanced programmer, as it can cause the
^4machine to Guru if not used with discretion. I have tried it on
^4several programs, and it seems to work O.K.
^1 The following routine allows you to call and execute a non Amos
^1program from inside Amos e.g. PPmore, Diskmaster etc.
^1 Its limits are amount of available memory and the support files
^1needed to run the program.
^2 Let's use PPmore as an example. PPmore needs the PowerPacker ARP
^2library in the libs dir to work.
^7 Amos To Back
^7 COM$="PPmore"
^7 Dreg(0)=Varptr(COM$)
^7 Dreg(1)=0
^7 Dreg(2)=0
^7 A=Doscall(-222)
^7 Amos To Front
^2 This will execute and run PPmore, once you kill PPmore, you're taken
^2back to AMOS.
^1 Use LEFT AMIGA-A keys to toggle between the two.
^4 This is very handy if you have a large `help' file to display as it
^4saves writing a routine to display it, BUT beware of copyright
^4problems, any program which calls a copyright program will not be
^4eligable for licenseware!!!!!
^4---------------------------------------------------------------------
^2[3NUMBER 5:[0
^1 If you've been having Compiler problems, like I have, then this tip
^1will solve one of them.
^6 Sometimes after a program has been compiled, you'll find that the
^6mouse will only move across 2/3rds of the screen, which is no good if
^6you need to click on buttons on the other 1/3rd of the screen.
^6 An easy way around this is to put in Limit Mouse. For NTSC screens
^6this is from 128,50 to 438,249 and for PAL screens 128,43 to
^6438,294. This completely cures the problem.
^4---------------------------------------------------------------------
^2[3NUMBER 6:[0
^1 This is the answer to another compiler bug. If you remember, one of
^1the older versions of RAMOS had to have a default screen opened. The
^1Compiler has the same problem, so either get the Compiler to open a
^1default screen for you, or do it in your program.
^4---------------------------------------------------------------------
^2[3NUMBER 7:[0
^2 A simple way of centring text.
^6 If you want to centre a piece of text on the screen using the Text
^6command, try this.
^7 A$="This is centred." ^1- put your text in the " "
^7 L=len(A$)*8 ^1- the 8 assumes you are using the Amos
^1default font.
^7 Text160-(L/2),10,A$ ^1- Assumes you have a normal 320 wide
^1screen. If not, replace the 160 with
^1your screen width divided by 2.
^2This easily centres text and will give you neater displays.
^4---------------------------------------------------------------------
^1 That's it for this issue, I hope that you find the above tips useful.
^1Do not forget, if you have any tips or hints that could help the
^1learners among us PLEASE send them in, they might be of use to
^1someone, so don`t be mean with your knowledge spread it about a bit!
^1You will feel better for it!!
^4********************************************************************
\