Jump to content

Help with arrays


Recommended Posts

im trying to make a simple scripting language and for some reason when i add a second command it wont run the command and i get an error saying

Subscript used with non-Array variable.
$mousego = StringSplit($mousegopos[0], ";") 
$mousego = StringSplit($mousegopos^ ERROR

CODE
#include <GUIConstants.au3>
#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <String.au3>
#include <GUIConstants.au3>

$error = ""

$Form1 = GUICreate("Test", 633, 447, 337, 125)
$Edit1 = GUICtrlCreateEdit("", 33, 10, 581, 391)
$Button1 = GUICtrlCreateButton("Run", 40, 410, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Clear", 130, 410, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Save", 220, 410, 75, 25, 0)
$Graphic1 = GUICtrlCreateGraphic(10, 10, 21, 391,$SS_SUNKEN)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _runscript()
        Case $Button2
            GUICtrlSetData($Edit1, "")
        Case $Button3
            FileWrite("Save.apl", _StringToHex(GUICtrlRead($Edit1)))
    EndSwitch
WEnd

Func _runscript()
    GUICtrlDelete($Graphic1)
    Global $Graphic1 = GUICtrlCreateGraphic(10, 10, 21, 391,$SS_SUNKEN)
    For $x = 1 To _GUICtrlEditGetLineCount($Edit1)
        $command = StringSplit(_GUICtrlEditGetLine($Edit1, $x), "=")
        Switch $command[1]
            GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & @CR & ":::>>> " & $command[2] & " <<<:::")
            Case "mousego"
                $mousegopos = _StringBetween($command[2], "{", "}")
                $mousego = StringSplit($mousegopos[0], ";")
                If $mousego[0] = 3 Then
                    MouseMove($mousego[1], $mousego[2], 100 - $mousego[3])
                ElseIf $mousego = 2 Then
                    MouseMove($mousego[1], $mousego[2])
                EndIf
            Case "click"
                $mouseclick = _StringBetween($command[2], "{", "}")
                $mouseclickstuff = StringSplit($mouseclick[0], ";") 
                If $mouseclick = 1 Then
                    if $mouseclick[0] = 0 Then
                        MouseClick("Left")
                    elseif $mouseclick[0] = 1 Then
                        if $mouseclick[1] = 0 Then
                            MouseClick("left")
                        elseif $mouseclick[1] > 1 Then
                            MouseClick("right")
                        EndIf
                    elseif $mouseclick[0] > 1 Then
                        if $mouseclick[1] = 0 Then
                            MouseClick("left",$mouseclick[2],$mouseclick[3])
                        elseif $mouseclick[1] > 1 Then
                            MouseClick("right"$mouseclick[2],$mouseclick[3])
                        EndIf
                    EndIf
                EndIf
            Case Else
                $error = Execute($error & "Error: line " & $x & " command " & $command[1] & @CR)
                GUICtrlSetGraphic($Graphic1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
                GUICtrlSetGraphic($Graphic1, $GUI_GR_ELLIPSE, 10, (((10 * $x) - 10) + 3 * $x) + 2, 10, 10)
                GUICtrlSetGraphic($Graphic1, $GUI_GR_REFRESH)
        EndSwitch
    Next
    If $error <> "" Then
        MsgBox(48, "Error", $error)
        $error = ""
    EndIf
EndFunc   ;==>_runscript

its proberly really crapy but im still learning, im only makeing it to learn stringcommands and arrays a bit better.

Commands:

mousego={x;y;speed(100 is fast and 1 is slow, if not input the speed 97 (3 in autoit))}

click={button(0 for left, 1 or more for right);x(if no input then click current pos);y(if no input then click current pos)}

it also has a half working debuging system.

[font="Impact"]Never fear, I is here.[/font]

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