Jump to content

add to the value of an array


Recommended Posts

I can't seem to get it. I want to add the values I get so that when it give the value on the for loop it will add to that the next time around.

$String = a,b,c,d,e,f

$iString = StringSplit($String, ",")

For $i = 1 To $iString[0]

Guictrlsetdata($TestField, $iString[$i])

Next

Problem is I want it to add to the value each time. So that it will set a new string of a\b\c\d\e\f

Can't seem to figure out how to add to the value on each loop.

??

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

I can't seem to get it. I want to add the values I get so that when it give the value on the for loop it will add to that the next time around.

$String = a,b,c,d,e,f

$iString = StringSplit($String, ",")

For $i = 1 To $iString[0]

Guictrlsetdata($TestField, $iString[$i])

Next

Problem is I want it to add to the value each time. So that it will set a new string of a\b\c\d\e\f

Can't seem to figure out how to add to the value on each loop.

??

What do you mean by "add to the value"? If the array element has "a" then does it mean that you want it to become "b", or do you mean you want to add extra elements?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

What do you mean by "add to the value"? If the array element has "a" then does it mean that you want it to become "b", or do you mean you want to add extra elements?

I want a to become a\b

and everytime it goes through the loop it adds the next value to the end of the last value with what it finds in the arrar,

a becomes, a\b, a\b becomes a\b\c etc?

I've been looking at _arraytostring but haven't yet made that work either.

Thanks

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

I want a to become a\b

and everytime it goes through the loop it adds the next value to the end of the last value with what it finds in the arrar,

a becomes, a\b, a\b becomes a\b\c etc?

I've been looking at _arraytostring but haven't yet made that work either.

Thanks

I think I get it, but to be sure

you start with a string "a,b,c,d,e,f"

You make an array $array[0] = 6, [1] = "a", [2] = "b" etc

then you want to make a string from this array which will be "a/b/c/d/e/f"

Is that what you want?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I think I get it, but to be sure

you start with a string "a,b,c,d,e,f"

You make an array $array[0] = 6, [1] = "a", [2] = "b" etc

then you want to make a string from this array which will be "a/b/c/d/e/f"

Is that what you want?

Yes but I don't alway know the size of the array because I will be using StringSplit with different strings. But want to add them back together with another delimited. So yes.
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

$String = "a,b,c,d,e,f"
$aStrings = SplitString($String, ",")
For $i = 1 To $iString[0]
    GuiCtrlSetData($TestField, GuiCtrlRead($TestField) & "/" & $aStrings[$i])
NextoÝ÷ ØƲmà%µêçjدz²¢ç(ºWZq˦ºV­zØ^½©nz)í¡©è¶«²Úâ§våÊÇ­¶¯j[¢wjëh×6$String = "a,b,c,d,e,f"
$aStrings = SplitString($String, ",")
$sValue = ""
For $i = 1 To $iString[0]
    If $i > 1 Then $sValue &= "/"
    $sValue &= $aStrings[$i]
Next
GuiCtrlSetData($TestField, $sValue)

HTH

Edited by WideBoyDixon
Link to comment
Share on other sites

I believe, you are looking for _ArrayAdd, but that will only add the data so if you are using [0] to store the number of elements, then you would probably want to Ubound it, or just add as you go which ever you find easier.

But also what WideBoyDixon said would also be wise about using another array.

"Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend.

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