Jump to content

StringTrimLeft and StringRight


Recommended Posts

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?

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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.

Link to comment
Share on other sites

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.
Link to comment
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.
Link to comment
Share on other sites

  • Developers

I am lost on this discussion ...

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

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Developers

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 ......

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...