Sign in to follow this  
Followers 0
Jonniy

[Help] Declaring an array with a variable & "For" missing Next & FileInstall error

3 posts in this topic

Hello fellow coders, today my problem is that I can't declare an array using a variable. Also the SyntaxCheck doesn't recognize the "Next". Maybe it's because of the Array error, but I dunno. Script:

Func LocalSearch()
    Local $Success = 0
    Local $sSearchedFoundCount = 0
    Local $sWantedWord = InputBox("Search", "Enter the word you want to search.")
    For $i = 0 To $CurrentDicSize Step 1
        Local $sTmpArray = StringSplit(IniRead($DicIni, "Vocabs", "Voc" & $i, ""),"|")
        If StringInStr($sTmpArray[2], $sWantedWord) <> 0 Then
            Local $Success = 1
            Local $sLocalSearchArray[$sSearchedFoundCount] = $i ;The error occurs here. (ERROR: syntax error)
            $sSearchedFoundCount + 1
        ElseIf StringInStr($sTmpArray[3], $sWantedWord) <> 0 Then
            Local $Success = 1
            Local $sLocalSearchArray[$sSearchedFoundCount] = $i
            $sSearchedFoundCount + 1
        EndIf
    Next ;Here is the Next, which isn't recognized.
    If $Success = 1 Then
        _GUICtrlListView_BeginUpdate($ListView1)
        _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))

        For $i = 0 To $sSearchedFoundCount Step 1
            Local $sTmpArray = StringSplit(IniRead($DicIni, "Vocabs", "Voc" & $i, ""), "|", 1)
            _GUICtrlListView_AddItem($ListView1, $sTmpArray[1])
            _GUICtrlListView_AddSubItem($ListView1, $i, $sTmpArray[2], 1)
            _GUICtrlListView_AddSubItem($ListView1, $i, $sTmpArray[3], 2)
        Next
            MsgBox(0, "List", "If you want to see the Main List again, press: STRG+ALT+ESC, or press hide/show spanish." & @CRLF & '"Hide spanish" does NOT work with search results!')
            _HotKey_Assign(BitOR($CK_CONTROL, $CK_ALT, $VK_ESCAPE), "ReDrawListView")
            _HotKey_Enable()
    Else
            MsgBox(0, "Not found", "I haven't found anything, please use the translate online button, or redefine your search term!")
    EndIf
EndFunc   ;==>LocalSearch

All vars used, are already declared smoothly. Also, for some reason the FileInstall() func, does't work anymore since I patched to the latest "automatic installer" beta, also now of a sudden, the includes are messed up. I'm always getting already declared erros, before it worked fine. It's a pain to test with "Go", if you're used to "Beta-Run" :/ BTW: I also attached my main script folder with everything, I hope it's easier for you with it.

FileInstall("C:\Benutzer\Jonniy\Downloads\Autoit\Spanisch\dic.ini", @AppDataDir & "\dic.ini", 1)

It worked before, so it can't be me I think.

ScriptResources.rar


Thanks for your help & have a good day. Yours sincerely, -Jonniy-  

Share this post


Link to post
Share on other sites



Don't declare your array in the loop, declare it then start adding things to it.

 

Also, this is written wrong, and $searchfoundcount is going to be zero the first time through the loop.

 

             Local $sLocalSearchArray[$sSearchedFoundCount] = $i
            $sSearchedFoundCount + 1
It should look something like this.

$sLocalSearchArray[$sSearchedFoundCount] = $i
            $sSearchedFoundCount += 1

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

OK, I'll try your suggestion, thx.

EDIT:
The += doesn't fix it because I dont want to add it, I rather want that the $array[NumberOfFoundStrings] = $i, because $i is the line of the string, and I want that number in that array. I use the [$var], so the first string in the array is the first string found and so on.  And I can't really declare it outside the loop, because I need the current $i value for that issue.

EDIT2:
Sorry, I also didn't mean "declare", I meant "input data into the array". Stupid not native language problem :/

Edited by Jonniy

Thanks for your help & have a good day. Yours sincerely, -Jonniy-  

Share this post


Link to post
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
Sign in to follow this  
Followers 0