Consider the following code:

     Function SQLFormat String sText ;
        String s1 String s2 String s3 String s4 String s5 String s6 String s7 String s8 String s9 ;
        Returns String
        String sParam
        Integer iArg
        If (num_arguments>10) Error DFERR_WRONG_NUMBER_OF_ARGUMENTS // only allow max of 9 params
        Move (Replaces("%%",sText,"$%$")) to sText // %% is used when you want a single % followed by a 1-9. e.g. "%%1"=%1
        For iArg from 2 to Num_Arguments
CompilerWarnings Suspend
            MoveStr iArg& to sParam
CompilerWarnings Restart 
            Move (Replaces("'",sParam,"''")) to sParam
            Move (Replaces("%"+String(iArg-1),sText,sParam)) to sText
        Move (Replaces("$%$",sText,"%")) to sText
        Function_Return sText
Somehow MoveStr converts iArg& into the iArgth passed in parameter.

How on earth is it actually doing this?

Changing Movestr to Move breaks it entirely.