Jump to content

_ArrayToString()


Recommended Posts

Hi,

is there a reason why _ArrayToString() returns "" and sets an error if there's only one element in the array? I think it should return the element (without any separator) instead. Does anyone else support this RFC?

Link to comment
Share on other sites

Hi,

is there a reason why _ArrayToString() returns "" and sets an error if there's only one element in the array? I think it should return the element (without any separator) instead. Does anyone else support this RFC?

Hmm... :)

;Test _ArrayToString()
#include <array.au3>
Global $MyString, $MyArray[1] = ["Chunky"]
_TestIt()

_ArrayAdd($MyArray, "Funky")
_ArrayAdd($MyArray, "Monkey")
_TestIt()

$MyArray = StringSplit($MyString, ";")
_ArrayDisplay($MyArray, "_StringSplit()")

_TestIt()

Func _TestIt()
    $MyString = _ArrayToString($MyArray, ";")
    $SaveError = @error
    MsgBox(64, "Test _ArrayToString()", "Returned string = " & $MyString & @CRLF & _
            "@Error = " & $SaveError)
EndFunc   ;==>_TestIt

The helpfile make a point out it being the recipricol of StringSplit(), but for that you have to be sure to add start index = 1 (which is 0 by default). Then _StringSplit($MyString, ";") = _ArrayToString($MyArray, ";", 1). But your change won't hurt any already-written scripts, since it just eliminates an error condition, so it seems reasonable to me.

I like the idea... :(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi,

is there a reason why _ArrayToString() returns "" and sets an error if there's only one element in the array? I think it should return the element (without any separator) instead. Does anyone else support this RFC?

P.S. This probably belongs in the v3 Idea Lab forum... perhaps some nice moderator would move the thread?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Developers

Well, if this RFC seams not be that interesting for the rest of you, I will do a quick hack for my own. :D

Thank you PsaltyDS for your support :D

what about you take the current Function and you write a proposal for changes in a way that no current implementations will brake ?

:P

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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