String() command in addition to Space() command

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

String() command in addition to Space() command

Post by oldefoxx »

Space(n) allows you to create a string of n spaces. How about a String(n,x) command to create as string of whatever X is, which would usually be a character code, but might also be a character constant, or it might be a string of one or more characters to be returned n times.
has-been wanna-be (You may not agree with what I say, but it will make you think).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: String() command in addition to Space() command

Post by PB »

I'd like this too -- I needed it just the other day, actually. :)
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Try: LSet("",10,'*')

Btw: Other language can do this
a$="hallo"*2
debug a$ ; you get "hallohallo"

GPI
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

Cleaver Feature

Post by oldefoxx »

That is cute. Just use a$=LSet("".100."*") and you get a line of 100 astericks. Note your example was not quite complete, and the use of
single quotes to surround the "*" character was invalid. I am sure you
know better, but it might mislead someone else. It also works with RSet() as well. I will have to remember that. Still, as String() command would be more obvious, consistent with soem other BASICs, and have more flexability.

I personally would not care to see the abitlity to perform a$*2 as a wqy to couble a string, since a might have been defined as a.s, and a*2 would not be obvious as a string doubling function, but rather look like a math operation.
has-been wanna-be (You may not agree with what I say, but it will make you think).
Post Reply