AnimationFramea
caused error...needs to be AnimationFrame
That is really cool stuff man.

I altered your code so that the program can run full speed.
The difference is, i stored gettimer() value to time the ocean.
To use gettimer, you must have the gettimer right before showscreen,
AND sleep 1, MUST be right after showscreen.
If you dont take these steps, then the ocean will "jitter", as gettimer has some bug if you dont sleep 1 millisecond after showscreen.
I use the gettimer value inside the update function.
A second parameter to the function is added to set the milliseconds per frame.
This allows you to set the time for only the ocean, while the whole program can run max speed.
// Project: Ocean Surface
// Start: Monday, November 23, 2009
// IDE Version: 7.177
// Written by Shane Hockings
GLOBAL GridSizeX%=40
GLOBAL GridSizeZ%=40
GLOBAL SizeFactor%=3 // A lower number = higher sine wave amplitude
GLOBAL WaveFrequency%=36 // Higher number = shorter sine wave period
GLOBAL AnimationFrameMax%=20 // How many frames before we return to the start frame
GLOBAL HeightMap#[] // The array storing the heights for each square in our water surface
DIM HeightMap#[GridSizeX%][GridSizeZ%]
GLOBAL WaterTexture // Sprite for the texture
// ------------------------------------------------------------- //
// --- MAIN ---
// ------------------------------------------------------------- //
LOCAL AnimationFrame = -1 // Initialise wave animation frame counter
WaterTexture=GENSPRITE() // Reserve the sprite for the water texture
GOSUB CreateWaterTexture // Create/load the water texture
WHILE TRUE
AnimationFrame=AnimationFrame+1
IF AnimationFrame=AnimationFrameMax% THEN AnimationFrame=0 // Reset animation
X_MAKE3D 1, 600, 45 // Make 3D window
X_CAMERA 0,10,-10, 10, 0, 10 // Set up the camera
X_AMBIENT_LT 0, RGB(255,255,255)
//timer = 100 ms
UpdateGrid(AnimationFrame, 200) // Create the waves
X_SETTEXTURE WaterTexture,-1 // Give them texture
X_DRAWOBJ 1,0
//need this for right time, must be with showscreen
gTIMER=GETTIMER()
SHOWSCREEN // Display them on the screen
//i removed this: SLEEP 200
// must have sleep 1 for gettimer to work
SLEEP 1 // Pace the animation
WEND
// ------------------------------------------------------------- //
// --- UPDATEGRID ---
// ------------------------------------------------------------- //
FUNCTION UpdateGrid: AnimationFrame, Timer_ms
// These values are defined LOCAL:
// Counter%
STATIC timer
timer=timer+gTIMER
IF timer>=Timer_ms THEN timer = 0
IF timer<>0 THEN RETURN 0 //not ready to render yet=0
LOCAL X, Z
FOR Z=0 TO GridSizeZ-1 // For each grid location
FOR X=0 TO GridSizeX-1
HeightMap[X][Z]=(SIN((X+AnimationFrame)*36)-SIN((Z+AnimationFrame)*36))/SizeFactor
// Formula for saddle surface : Z = x^2 - y^2
// X and Z are points on a sine curve
NEXT
NEXT
X_OBJSTART 1 // Create 3D object number 1
FOR Z=0 TO GridSizeZ-2
X_OBJNEWGROUP // Create a new group of polygons every row
FOR X=0 TO (GridSizeX/2)-1 // As a trangle is drawn between column [X] and column [X+1] (ie. 2 columns)
// we only need to loop through half of them
X_OBJADDVERTEX X, HeightMap[X][Z+1], Z+1, 0,0, RGB(0,0,255) // Create quad
X_OBJADDVERTEX X, HeightMap[X][Z], Z, 0,1, RGB(0,0,255)
X_OBJADDVERTEX X+1, HeightMap[X+1][Z+1], Z+1, 1,0, RGB(0,0,255)
X_OBJADDVERTEX X+1, HeightMap[X+1][Z], Z, 1,1, RGB(0,0,255)
NEXT
NEXT
X_OBJEND // Finished 3D object number 1
RETURN 1 //an object was built =1
ENDFUNCTION // UPDATEGRID
// ------------------------------------------------------------- //
// --- CREATEWATERTEXTURE ---
// ------------------------------------------------------------- //
SUB CreateWaterTexture:
// Either create a texture that's a white box with blue outline
DRAWRECT 0,0,32,32,RGB(0,0,255) // Create a filled blue box
DRAWRECT 1,1,30,30,RGB(255,255,255) // Create a filled white box just inside it
GRABSPRITE WaterTexture,0,0,32,32 // Grab the boxes into sprite "WaterTexture"
// OR load a texture instead
//LOADSPRITE "Water.png", WaterTexture // Load a texture for the water
ENDSUB // CREATEWATERTEXTURE