A few things worth mentioning.
1. x# and z# need to be global (or in an array) in order for their values to be used in a function like that.
2. You never see the saving / loading messages as creating an object will turn the backdrop on.
3. Why not write float values to the file instead of a long?
Edited code:
sync on : sync rate 0
global x# as float : global z# as float
make matrix 1,2000,2000,25,25
make object sphere 1,20
position camera 1000,2000,1000
point camera 1000,0,1000
do
position object 1,x#,10,z#
if upkey()=1 then z#=z#+1
if downkey()=1 then z#=z#-1
if leftkey()=1 then x#=x#-1
if rightkey()=1 then x#=x#+1
if lower$(inkey$())="s" then savegame()
if lower$(inkey$())="l" then loadgame()
sync
LOOP
function savegame()
If file exist("savegame.dat")=1 then delete file "savegame.dat"
open to write 1,"savegame.dat"
write float 1,x#
write float 1,z#
close file 1
NoKeys()
if file exist("savegame.dat")=1
ink rgb(0,225,0),0
repeat
center text 320,160, "Save succesfull! press any key to continue"
sync
until scancode() > 0
else
ink rgb(225,0,0),0
repeat
center text 320,160, "Save Un-Succesfull. press any key to continue"
sync
until scancode() > 0
endif
ENDFUNCTION
function loadgame()
if file exist("savegame.dat")=1
open to read 1,"savegame.dat"
read float 1,x#
read float 1,z#
position object 1,x#,10,z#
close file 1
NoKeys()
ink rgb(0,225,0),0
repeat
center text 320,160, "Load succesfull! press any key to continue"
sync
until scancode() > 0
else
ink rgb(225,0,0),0
repeat
center text 320,160,"File does not exist. Press any key to continue"
sync
until scancode() > 0
ENDIF
ENDFUNCTION
function NoKeys()
repeat
until scancode() = 0
endfunction
Hope this helps.
So many games to code.......so little time.