Slight change to "RSet()"

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Regenduft
Enthusiast
Enthusiast
Posts: 121
Joined: Mon Mar 02, 2009 9:20 pm
Location: Germany

Slight change to "RSet()"

Post 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
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Slight change to "RSet()"

Post by Little John »

Problem is, that this "slight" change would break existing code. :)
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Re: Slight change to "RSet()"

Post by PureGuy »

Well, it would not break existing code with an optional 4 parameter. :mrgreen:
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Slight change to "RSet()"

Post by Little John »

Yep. :)
Post Reply