Well, there is an error I can't fix.
I have changed your code into:
mode=0 ;(0 == waiting To display, 1 == displaying)
endtime = MilliSecs()+20000 ;(this is 20 seconds After now)
Repeat
If MilliSecs() > endtime Then
If mode=0 Then
display_random_picture()
endtime=MilliSecs()+4000 ;(this is 4 seconds After now)
mode=1
Else If mode = 1 Then
turn_off_picture()
endtime=MilliSecs()+20000
mode=0
End If MilliSecs
End If
Until KeyDown
End
If Function display_random_picture()
x=Rand(0,640)
y=Rand(0,480)
DrawImage image,x,y
End Function
Also, the error that comes up is: "Expecting expression".