Blackstar Posted July 13, 2006 Share Posted July 13, 2006 Im trying to update the element[0] count to 18 when there is one new element added to the array...how do I do that? Check the pics below: Link to comment Share on other sites More sharing options...
herewasplato Posted July 13, 2006 Share Posted July 13, 2006 redim [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
FuryCell Posted July 13, 2006 Share Posted July 13, 2006 (edited) It would be easier for people to help you if you showed some code but here is what I can say without code. Just set its value like you would any array element, Dim $Array[5] $Array[0] = 4 MsgBox(0, "", $Array[0])oÝ÷ Úî±å¢éݶ®¶¶'%ÊÇzW¦z{t¶azè¥êì7ºÚ"µÍ[H ÌÍÐ^VÍWBÌÍÐ^VÌHHPÝ[ ÌÍÐ^JHHBÙÐÞ ][ÝÉ][ÝË ÌÍÐ^VÌJ Edited July 13, 2006 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Blackstar Posted July 13, 2006 Author Share Posted July 13, 2006 (edited) Heres the code if it helps. #include <Array.au3> #include <File.au3> Dim $s_Path, $names $s_Path = @ScriptDir & "\names.txt" If Not FileExists($s_Path) Then MsgBox(4096, "Error!", "names.txt does not exist.") Exit EndIf _FileReadToArray($s_Path, $names) _ArrayDisplay($names, "Names ") _ArrayAdd($names, "Troy Phillips") _ArrayDisplay($names, "New addition") $namestring = "Troy Phillips" if _CheckNames($namestring, $names) then MsgBox(4096, "Found!", "This name " & $namestring & " has been found in array.") Else MsgBox(4096, "Not Found!", "This name " & $namestring & " has NOT been found in array.") EndIf Func _CheckNames($s_string, $namesarray) For $j = 1 To $namesarray[0] $search = $namesarray[$j] If Not @error Then $result = StringInStr($s_string, $search) If $result Then Return True EndIf Next EndFunc Edited July 13, 2006 by Blackstar Link to comment Share on other sites More sharing options...
evilertoaster Posted July 13, 2006 Share Posted July 13, 2006 (edited) and where in this code do you need to resize your array? Edit: o wait maybe you mean- #include <Array.au3> #include <File.au3> Dim $s_Path, $names $s_Path = @ScriptDir & "\names.txt" If Not FileExists($s_Path) Then MsgBox(4096, "Error!", "names.txt does not exist.") Exit EndIf _FileReadToArray($s_Path, $names) _ArrayDisplay($names, "Names ") _ArrayAdd($names, "Troy Phillips") $names[0]=ubound($names)-1 _ArrayDisplay($names, "New addition") $namestring = "Troy Phillips" if _CheckNames($namestring, $names) then MsgBox(4096, "Found!", "This name " & $namestring & " has been found in array.") Else MsgBox(4096, "Not Found!", "This name " & $namestring & " has NOT been found in array.") EndIf Func _CheckNames($s_string, $namesarray) For $j = 1 To $namesarray[0] $search = $namesarray[$j] If Not @error Then $result = StringInStr($s_string, $search) If $result Then Return True EndIf Next EndFunc Edited July 13, 2006 by evilertoaster Link to comment Share on other sites More sharing options...
Blackstar Posted July 13, 2006 Author Share Posted July 13, 2006 before this line: if _CheckNames($namestring, $names) then Link to comment Share on other sites More sharing options...
evilertoaster Posted July 13, 2006 Share Posted July 13, 2006 ahh sory you posted while i edited^^ Link to comment Share on other sites More sharing options...
Blackstar Posted July 13, 2006 Author Share Posted July 13, 2006 ahh sory you posted while i edited^^Thats fine, as long its before that line I tried your suggestion and it works. thanks! Link to comment Share on other sites More sharing options...
herewasplato Posted July 13, 2006 Share Posted July 13, 2006 evilertoaster, Give away the whole answer, why don't ya? :-) At least I was close since _ArrayAdd uses ReDim. Blackstar, Sorry for the short post above - it was all I had time for. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Blackstar Posted July 13, 2006 Author Share Posted July 13, 2006 Redim....ok how do I put that in proper coding format in the autoit code I posted in above, herewasplato? Thanks. Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 13, 2006 Share Posted July 13, 2006 Hi, why ReDim? #include <Array.au3> #include <File.au3> Dim $s_Path, $names $s_Path = @ScriptDir & "\names.txt" If Not FileExists($s_Path) Then MsgBox(4096, "Error!", "names.txt does not exist.") Exit EndIf _FileReadToArray($s_Path, $names) _ArrayDisplay($names, "Names ") _ArrayAdd($names, "Troy Phillips") $names[0] = UBound($names) - 1 _ArrayDisplay($names, "New addition") $namestring = "Troy Phillips" if _CheckNames($namestring, $names) then MsgBox(4096, "Found!", "This name " & $namestring & " has been found in array.") Else MsgBox(4096, "Not Found!", "This name " & $namestring & " has NOT been found in array.") EndIf Func _CheckNames($s_string, $namesarray) For $j = 1 To UBound($namesarray)-1 $search = $namesarray[$j] If Not @error Then $result = StringInStr($s_string, $search) If $result Then Return True EndIf Next EndFunc So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Blackstar Posted July 13, 2006 Author Share Posted July 13, 2006 Redim....ok how do I put that in proper coding format in the autoit code I posted in above, herewasplato? Thanks. Link to comment Share on other sites More sharing options...
herewasplato Posted July 14, 2006 Share Posted July 14, 2006 There is little reason to "build your own" UDF when _AddArray is already built/tested/proven. It has all of the error checking you'll need. The OP asked how to add to an array and that is what ReDim does. "Resize an existing array" I saw the OP, I posted the AutoIt function. Just use the _ArrayAdd UDF like evilertoaster suggested. The heart of the _ArrayAdd UDF is:ReDim $avArray[UBound($avArray) + 1] I did not mean to imply that you needed to change anything - I was just attempting to acknowledge that evilertoaster gave you a better answer than I did. ...sorry for any confusion... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now