Amos Professional Manual  Contents  Index

Machine Code

The fill pattern is a standard four-byte integer, but if you need to fill the area with multiple copies of a single byte, this value can be calculated as follows, where V will contain the required value of your fill command:

E> BYTE=255 : Rem This can be any number from 0 to 255
   Poke Varptr(V),BYTE : Poke Varptr(V)+1,BYTE
   Poke Varptr(V)+2,BYTE : Poke Varptr(V)+3,BYTE
   Print V
function: find a string of characters in memory
first=Hunt(start To finish,s$)

HUNT is really a low level version of the familiar INSTR$ command. It searches the memory area defined by the given start and finish addresses, looking for the first occurrence of the characters held in your specified string.

If the search is successful, the position of the first character in memory is returned, otherwise a value of zero will be given. When using this function, take great care in selecting the start and finish points for the search.

Direct access to variables

function: read the address of a variable

This useful function returns the location of any AMOS Professional variable in the Amiga's memory. Programmers familiar with C should find it very similar to the & (ampersand) operator in that language.

VARPTR provides back-door access to your variables, and with careful use you are able to get to them directly, without having to rely on standard routines. This is especially valuable with procedures, because if procedures are loaded with the address of a variable instead of its actual value, that variable can be changed from inside the procedure. For example:

   Rem Correct use of square brackets
   ANSWER[Varptr(Test)] : Rem Load ADDRESS of variable into AD parameter
   Print TEST
   Procedure ANSWER[AD]
    Loke AD,42 : Rem Copy new value into variable, by back door!
   End Proc

There should be few problems encountered when reading the variables, but changing them is a very hazardous process!

Back    Next