Jump to content

Help! Basic syntax error


Dieuz
 Share

Recommended Posts

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

#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 :evil:

Edited by BennyBB
Link to comment
Share on other sites

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

Assign() lets you do this, but an array is much better.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

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

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.

Link to comment
Share on other sites

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

#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 ;)

Link to comment
Share on other sites

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

  • Developers

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

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