It's quite straightforward.
You should use floating point variables to store sonic's position and speeds, it keeps things nice and smooth:
Global PLX#
Global PLY#
Global PLXS#
Global PLYS#
So every loop your affecting the PLXS# variable, the players horizontal speed, and this is added to the PLX# variable.
So a loop like this would have a sonic sprite moving smoothly:
Do
movex=0
if leftkey()=1 then movex=-1
if rightkey()=1 then movex=1
`Adjust X speed
if movex=-1 the dec PLXS#,0.1
if movex=1 the inc PLXS#,0.1
`Or dampen it
If movex=0
if PLXS#>0 then dec PLXS#,0.05 : if PLXS#<0 then PLXS#=0
if PLXS#<0 then inc PLXS#,0.05 : if PLXS#>0 then PLXS#=0
endif
`Limit the X speed
If PLXS#<-1 then PLXS#=-1
If PLXS#>1 then PLXS#=1
`Add the X speed to the position
Inc PLX#,PLXS#
Sprite 1,PLX#,PLY#,sonicimagenumber
Sync
Loop

''Stick that in your text and scroll it!.''