Sign in to follow this  
Followers 0
jvanegmond

StringTrimLeft and StringRight

10 posts in this topic

StringTrimLeft and StringRight do exactly the same. Don't you think we could lose either of the two functions? The same counts for StringTrimRight and StringLeft, and I am sure more of these functions can be found in AutoIt.

I believe that removing unnecessary functions, the file size of AutoIt could be reduced. We may be talking bytes here, but in the end it may also count up to a few kilobytes.

Is there anyone that may want to shed light on this subject?

Share this post


Link to post
Share on other sites



StringTrimLeft and StringRight do exactly the same. Don't you think we could lose either of the two functions? The same counts for StringTrimRight and StringLeft, and I am sure more of these functions can be found in AutoIt.

I believe that removing unnecessary functions, the file size of AutoIt could be reduced. We may be talking bytes here, but in the end it may also count up to a few kilobytes.

Is there anyone that may want to shed light on this subject?

What happens when you know exactly how many chars to the left or right you want to go, but not the opposite? Then you have to get into StringLen() - or + X blah blah....

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

As far as this is concerned, using solely StringMid and StringLen, I could replace all 4 with UDFs:

Func _StringLeft($sString, $iNum)
    If $iNum <= 0 Or Not IsInt($iNum) Then Return SetError(1, 0, 0)
    If Not IsString($sString) Then Return SetError(2, 0, 0)
    Return StringMid($sString, 1, $iNum)
EndFunc

Func _StringRight($sString, $iNum)
    If $iNum <= 0 Or Not IsInt($iNum) Then Return SetError(1, 0, 0)
    If Not IsString($sString) Then Return SetError(2, 0, 0)
    Return StringMid($sString, StringLen($sString) - $iNum + 1, StringLen($sString) - $iNum)
EndFunc

Func _StringTrimLeft($sString, $iNum)
    If $iNum <= 0 Or Not IsInt($iNum) Then Return SetError(1, 0, 0)
    If Not IsString($sString) Then Return SetError(2, 0, 0)
    Return StringMid($sString, $iNum + 1, StringLen($sString) - $iNum)
EndFunc

Func _StringTrimRight($sString, $iNum)
    If $iNum <= 0 Or Not IsInt($iNum) Then Return SetError(1, 0, 0)
    If Not IsString($sString) Then Return SetError(2, 0, 0)
    Return StringMid($sString, 1, StringLen($sString) - $iNum)
EndFunc

Same can be done with the new binary type and their appropriate functions. Only thing with removing these functions, it'd break so many scripts, it might not be worth it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I think StringTrim* functions should be replaced with UDF's.

Func _StringTrimLeft($sStr, $iCount)
    Return StringRight($sStr, StringLen($sStr)-$iCount)
EndFunc
Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

I suppose it's one of the should have been made earlier (if developers agreed) choices.


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I am lost on this discussion ...

They are there and serve a purpose ... full stop .

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

StringTrimLeft and StringRight do exactly the same.

You are absolutely incorrect!

Debate over. :rolleyes:

Share this post


Link to post
Share on other sites

You remove them, you will break scripts so might as well leave em be.

Share this post


Link to post
Share on other sites

You remove them, you will break scripts so might as well leave em be.

Think the discussion was closed and conclusion drawn that they are not one and the same ......

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0