It is currently Fri Feb 26, 2021 7:11 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: LSet() and RSet() are reversed?
PostPosted: Sat Jan 30, 2021 1:49 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1301
Does it bother anyone else that LSet() and RSet() are reversed? For example, I always expect LSet() to pad to the left (like its name) instead of to the right. It's more intuitive and makes more sense that way. The manual says LSet() "pads a string to the left" which is obviously not true at all; it actually adds the padded characters to the right of the given string.

I note that Microsoft agrees with me for .NET coding, that PadLeft puts the spaces to the left:

https://docs.microsoft.com/en-us/dotnet/standard/base-types/padding wrote:
The following code example uses the PadLeft method to create a new string that is twenty characters long. The example displays "--------Hello World!" to the console.


Top
 Profile  
Reply with quote  
 Post subject: Re: LSet() and RSet() are reversed?
PostPosted: Sat Jan 30, 2021 3:46 am 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3409
Location: Boston, MA
LSET is relative to typewriter days.
PADLEFT is not.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: LSet() and RSet() are reversed?
PostPosted: Sat Jan 30, 2021 7:15 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2432
Location: Singapore
BarryG wrote:
...I always expect LSet() to pad to the left (like its name) instead of to the right...

The LSET and RSET functions have existed since the early days of GW-Basic, and their core functionality has not changed.

As their names imply, the functions essentially align or SET a string to the LEFT or RIGHT, by padding it with the given character, to result in a string with the given length.

This is quite different from Microsoft's newer PADLEFT and PADRIGHT functions, that add or PAD the given character to the LEFT or RIGHT of a string, to result in a string with the given length.

The descriptions of these functions in the PureBasic manual should perhaps read:
PureBasic Manual wrote:
Description
SETS a string to the left/right by adding extra characters to fit the specified length.

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: LSet() and RSet() are reversed?
PostPosted: Sat Jan 30, 2021 7:21 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1301
Now that makes more sense! It's the manual's use of the word "pad" which is wrong, because "pad" means to insert spaces (or characters), just like Microsoft's .NET example for "PadLeft".

Can a mod move this to the "Bugs - Documentation" section and implement TI-994A's wording change please? Thanks.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye