Page 1 of 1

Slight change to "RSet()"

Posted: Tue Jan 06, 2015 11:15 am
by Regenduft
Hi there,

I think a slight change to the behavior of RSet() would make it a bit more intuitive and reduce redundant code.

Code: Select all

Debug RSet("1", 3, "0")
Debug RSet("12" ,3, "0")
Debug RSet("123", 3, "0")
Debug RSet("1234", 3, "0")
Debug RSet("12345", 3, "0")
Debug RSet("123456", 3, "0")

; real debug output:
; 001
; 012
; 123
; 123
; 123
; 123

; debug output I would expect:
; 001
; 012
; 123
; 234
; 345
; 456
Currently I'm using this work around in my default include, which costs some time when dealing with huge amounts of different strings.
If I know you right, then a native implementation would be fast as hell! :wink:

Code: Select all

Procedure.s _RSet(String$, Length, Character$)
  ProcedureReturn RSet(Right(String$, Length), 3, Character$)
EndProcedure

Macro RSet(String, Length, Character)
  _RSet(String, Length, Character)
EndMacro

Debug RSet("1", 3, "0")
Debug RSet("12", 3, "0")
Debug RSet("123", 3, "0")
Debug RSet("1234", 3, "0")
Debug RSet("12345", 3, "0")
Debug RSet("123456", 3, "0")

; debug output:
; 001
; 012
; 123
; 234
; 345
; 456

Re: Slight change to "RSet()"

Posted: Tue Jan 06, 2015 9:04 pm
by Little John
Problem is, that this "slight" change would break existing code. :)

Re: Slight change to "RSet()"

Posted: Tue Jan 06, 2015 9:13 pm
by PureGuy
Well, it would not break existing code with an optional 4 parameter. :mrgreen:

Re: Slight change to "RSet()"

Posted: Tue Jan 06, 2015 9:22 pm
by Little John
Yep. :)