Hello Ghantos,
S commands (like GCode commands) have their functionality built into the Mach3 engine. They are simply interpreted by Mach3 to produce the desired result so I think altering their functionality is out of the question. M Commands, on the other hand, have their functionality in the .m1s files located in the macros folder in your Mach3 install directory. M commands are a good way to place your own commands within the GCode file. As far as I know, the only way to achieve what you want is with MCodes and vbScripts.
If you want to be able to set a variable RPM (like when using the S command), you can first set a Mach3 variable to hold the desired RPM, then call the M Command. Inside the MCode file, you can just look at the Mach3 variable that you just set and work with it that way. The function "SetSpinSpeed()" is the same as calling an S Command.
Set this in GCode:
#2000=5000 'target RPM
#2001=200 'RPM increase per sleep
#2002=100 'Sleep time in ms
< Call M Code Here>
Mcode contents:
targetRPM = GetVar(2000)
rpmInc = GetVar(2001)
sleepMS = GetVar(2002)
currentRPM = 0
SetSpinSpeed(0)
DoSpinCW()
WHILE (currentRPM < targetRPM)
currentRPM = currentRPM + rpmInc
SetSpinSpeed(currentRPM)
Sleep(sleepMS)
WEND
Good luck.
-Marc Lim
Vital Systems Inc.