The main problem is the 'repeat - until' loop. This part of the code is repeating a certain number of times, perhaps indefinitely, every single loop. Let the 'do' loop do the business of repeating the code, once every loop, and add an 'if - then' condition to prevent that part of the code executing when certain limits have been met.
This now executes properly, just by having taken out the repeat - until commands:
REM Project: gemstone
REM Created: 10/13/2004 2:42:56 PM
REM
REM ***** Main Source File *****
REM
rem Best display
if check display mode(1024,768,32)=1
set display mode 1024,768,32
endif
`setup main int.
make matrix 1,300,200,20,20
make object cube 2,5
make object cube 1,5
hide object 1
position object 1,0,0,0
position mouse 400,400
global ca#=0
global ch#
global x1#
global y1#
global z1#
rem Init app
sync on
sync rate 60
show mouse
`start the game
do
`int. players positions
x1#=object position x(2)
y1#=object position y(2)
z1#=object position z(2)
x2#=object position x(1)
y2#=object position y(1)
z2#=object position z(1)
`position mouse object
rem Here we position the mouse object at the cursor's position (code by WhizzRich)
`repeat
if object screen x(1) < mousex()-3
position object 1,object position x(1)+1,object position y(1),object position z(1)
endif
if object screen x(1) > mousex()+3
position object 1,object position x(1)-1,object position y(1),object position z(1)
endif
if object screen y(1) < mousey()-3
move object 1,-3
endif
if object screen y(1) > mousey()+3
move object 1,3
endif
`until object screen x(1) =< mousex()+7 and object screen x(1) => mousex()-7 and object screen y(1) =< mousey()+7 and object screen y(1) => mousey()-7
rem -----------------------------------------------------------------------------------
`control character
if mouseclick()=1
point object 2,object position x(1),object position y(1),object position z(1)
move object 2,0.5
endif
controlcam(5)
text 0,0,str$(screen fps())
sync
loop
`Functions
function controlcam(camspeed#)
if leftkey()=1 then ca#=wrapvalue(ca#+camspeed#)
if rightkey()=1 then ca#=ca#-camspeed#
if upkey()=1 and ch# < 201 then ch#=ch#+camspeed#
if downkey()=1 and ch# > -1 then ch#=ch#-camspeed#
`follow the player
set camera to follow x1#,y1#,z1#,ca#,100,ch#,20,1
`always taget the player
point camera x1#,y1#,z1#
endfunction
althoug without knowing what you are really trying to do, I'm not sure if it actually works how you intended.