Dieuz Posted December 16, 2009 Posted December 16, 2009 (edited) Can anyone help me with this syntaxt error? How can I mix string & variables? $pr1list_array = StringSplit($pr1list, @LF, 2) $pr2list_array = StringSplit($pr2list, @LF, 2) $pr3list_array = StringSplit($pr3list, @LF, 2) $fpr1 = 0 $fpr2 = 0 $fpr3 = 0 For $x = 1 To 3 For $w = 0 To UBound($urllist_array) - 1 If _ArraySearch("$pr" & $x & "list_array", $urllist_array[$w]) > -1 Then ; Syntax error in Array to search "$fpr" & $x += 1 ; Syntax Error EndIf Next Next Edited December 16, 2009 by Dieuz
Developers Jos Posted December 16, 2009 Developers Posted December 16, 2009 What is that line supposed to do? 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.
BennyBB Posted December 16, 2009 Posted December 16, 2009 (edited) #include <Array.au3> $pr1list_array = StringSplit($pr1list, @LF, 2) $pr2list_array = StringSplit($pr2list, @LF, 2) $pr3list_array = StringSplit($pr3list, @LF, 2) Dim $prlist_array[3] = [StringSplit($pr1list, @LF, 2),StringSplit($pr2list, @LF, 2),StringSplit($pr3list, @LF, 2)] $fpr1 = 0 $fpr2 = 0 $fpr3 = 0 Dim $fpr[3] = [0,0,0] For $x = 1 To 3 For $w = 0 To UBound($urllist_array) - 1 If _ArraySearch($prlist_array[$x-1], $urllist_array[$w]) > -1 Then ; Syntax error in Array to search ;"$fpr" & $x += 1 ; Syntax Error $fpr[$x-1] += 1 EndIf Next Next as far as I know, it is not possible to sum up variable names so it would be better to put it in an array Hope this was, what you were looking for EDIT: now he just shows the error that some variables havn't been declarde, because you just gave us a piece of code Edited December 16, 2009 by BennyBB
Skruge Posted December 16, 2009 Posted December 16, 2009 as far as I know, it is not possible to sum up variable names so it would be better to put it in an arrayAssign() lets you do this, but an array is much better. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]
Dieuz Posted December 16, 2009 Author Posted December 16, 2009 (edited) Dim $prlist_array[3] = [StringSplit($pr1list, @LF, 2),StringSplit($pr2list, @LF, 2),StringSplit($pr3list, @LF, 2)] _ArrayDisplay($prlist_array) ; Gives me a BLANK array Thanks for your help but this doesnt seem to work.. StringSplit already create an array. It's like an array IN another array. Also, in _ArraySearch, you need to specify an Array to search in, not an array element... Edited December 16, 2009 by Dieuz
JohnOne Posted December 16, 2009 Posted December 16, 2009 Without testing, heres my offering $pr1list_array = StringSplit($pr1list, @LF, 2) $pr2list_array = StringSplit($pr2list, @LF, 2) $pr3list_array = StringSplit($pr3list, @LF, 2) $fpr1 = 0 $fpr2 = 0 $fpr3 = 0 $sString1 = "$fpr" $sString2 = "list_array" For $x = 1 To 3 For $w = 0 To UBound($urllist_array) - 1 If _ArraySearch($sString & $x & $sString2, $urllist_array[$w]) > -1 Then $x += 1 EndIf Next Next AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
BennyBB Posted December 16, 2009 Posted December 16, 2009 If _ArraySearch($sString & $x & $sString2, $urllist_array[$w]) > -1 Then I think the 1st parameter for _ArraySearch has to be an variable (an array) here it is a string, I think. I've worked a bit with it and maybe this works, but probably you could give us some example values for $pr1list and so one, so that we can test our code... expandcollapse popup#include <Array.au3> #include <Math.au3> ;--------- My test values $pr0list = "2" $pr1list = "1,2" $pr2list = "344,55" $pr3list = "44,87" $urllist_array = 10 :--------------------- #cs ;If anybody has a solution for this problem...please let me know... :D For $i= 0 to 2 Step 1 $var = String($i) For $l=0 to $h2-1 ;Assign("prlist_array[$i][$l]","pr" & $var & "list_array[$i][$l]") $prlist_array[$i][$l] = Eval("pr" & $var & "list_array[$i][$l]") MsgBox(0,"",Eval("pr" & $var & "list_array[$i][$l]")) MsgBox (0,"",$prlist_array[$i][$l]) Next Next #ce $pr1list_array = StringSplit($pr1list, @LF, 2) ; I tested with "," instead of @LF $pr2list_array = StringSplit($pr2list, @LF, 2) $pr3list_array = StringSplit($pr3list, @LF, 2) $h1 = _Max(Ubound($pr1list_array),Ubound($pr2list_array)) $h2 = _Max($h1,Ubound($pr3list_array)) MsgBox(0,"",$h2) Dim $prlist_array[3][$h2+1] For $i=0 to Ubound($pr1list_array)-1 $prlist_array[0][$i] = $pr1list_array[$i] MsgBox(0,"",$pr1list_array[$i]) Next For $i=0 to Ubound($pr2list_array)-1 $prlist_array[1][$i] = $pr2list_array[$i] Next For $i=0 to Ubound($pr3list_array)-1 $prlist_array[2][$i] = $pr3list_array[$i] Next _ArrayDisplay($prlist_array) Dim $fpr[3] = [0,0,0] For $x = 1 To 3 For $w = 0 To UBound($urllist_array) - 1 If _ArraySearch($prlist_array[$x-1][...fill here in which index you want..], $urllist_array[$w]) > -1 Then ; Syntax error in Array to search ;"$fpr" & $x += 1 ; Syntax Error $fpr[$x-1] += 1 EndIf Next Next hope this works now
james3mg Posted December 16, 2009 Posted December 16, 2009 I think Assign() would let you do what you wanted to in your OP... Assign("fpr" & $x, Eval("fpr" & $x)+1) You'd probably have to add in an IsDeclared() function above it to make sure the var exists before you try to read it to increment it... "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Developers Jos Posted December 16, 2009 Developers Posted December 16, 2009 Don't you all think that the use of an Array is a lot more appropriate here in stead of a kludgy Assign()? 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.
BennyBB Posted December 16, 2009 Posted December 16, 2009 As you can see in my post I've done it with arrays but now all this Eval () and Assign() stuff seems to be interesting for me
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