Jump to content

Subscript used with non-Array variable


upi
 Share

Recommended Posts

I have this little code to check a folder if new files are added. But i am keep getting this error "Subscript used with non-Array variable"

#include "File.au3"

#include "SendMail.au3"

$list=_FileListToArray('C:\Documents and Settings\Desktop\TestFolder',"*", 1);

MsgBox(0, "ListofFiles", "You have "&$list[0]&" files in this folder");

Link to comment
Share on other sites

The error kind of suggests there are no files in the folder or that the folder doesn't exist. Use @error to determine what the error is and use the help file for reference.

#include <File.au3>

Local $aArray = _FileListToArray('C:Documents and SettingsDesktopTestFolder', "*", 1) ; Returns Files Only.
If Not @error Then
    Exit MsgBox(0, "ListofFiles", "You have " & $aArray[0] & " file(s) in this folder.")
EndIf
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

By checking if an @error occurs, just see my previous example.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 3 months later...

I have this same ,

Func Start_dalej_xml()
...
For ; For $x = 0 To UBound($stringbetween) -1
If FileExists(@WorkingDir"UstawieniaTlumacz.ini") Then
$jjdefault = IniReadSection(@WorkingDir"UstawieniaTlumacz.ini", "Tlumacz" )
Endif
$il_kluczyy1 =$jjdefault[0][0]
MsgBox(0, "Postęp $x0: ",$il_kluczyy1 )
$1wartXml = $jjdefaultXml[1][1]
Next
...
EndFunc

MsgBox =$jjdefault[0][0] = 16

MsgBox = $jjdefaultXml[1][1]= Error

And I don't know , why?

Ini file is ok , but when

If FileExists(@WorkingDir"UstawieniaTlumacz.ini") Then

$jjdefault = IniReadSection(@WorkingDir"UstawieniaTlumacz.ini", "Tlumacz" )

Endif

I use second, third time in program , I have error.

I need paste IniReadSection because I need refresh $jjdefault from .ini file.

Edited by tele123
Fixed AutoIt tags
Link to comment
Share on other sites

  • Moderators

tele123,

Please do not keep editing your post - it makes it very difficult to keep up! ;)

Can you see the difference in these lines: ;)

MsgBox =$jjdefault[0][0] = 16
MsgBox = $jjdefaultXml[1][1]= Error

As you are not referencing the same array it is hardly surprising that you get an error. :)

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

"Autoit code " in this forum created the stamps and put all the code in one line , and I needed edit.

As you are not referencing the same array it is hardly surprising that you get an error

Ok.... So, how to read and write again, the same file and line in the ini file.

many times?

Can you see the difference in these lines: :)

you're right

But I use

If FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
               $jjdefault = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )
Endif

            $il_kluczy =$jjdefault[0][0]
           Next

And working

second

If   FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
                      $jjdefaultXml = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )

                 endif
                $il_kluczyy1 =$jjdefaultXml[0][0]

I use other name " $ " because this same name too not working.

Like , File not exist.

File exist , but data in the file are different. ( Name [Tlumacz], in .ini file is this same )

Edited by tele123
Link to comment
Share on other sites

  • Moderators

tele123,

I am afraid I do not understand your question. ;)

If you know the section name and the key name that you can use IniRead/IniWrite to read/rewrite the value in the ini file directly. If that is not the case then please xplain further. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

tele123,

Can I paste the whole code?

Of course. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I ' clik "otwórz" test.xml and "Start "

Line 221 $il_kluczyy1 = $jjdefaultXml[0][0]

$il_kluczy1= ^ ERROR

Error:Variable used without being declared.

I changed a little, before I gave also Local

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <ToolbarConstants.au3>
#include <WindowsConstants.au3>
#Include <String.au3>

#Region ### START Koda GUI section ### Form=C:Documents and SettingsgPulpitKalc-auttransgoog.kxf
$GUI = GUICreate("Translator-.xml-.ini", 1174, 788, -1, -1)
GUISetBkColor(0xF7EA9F)
$edit731 = GUICtrlCreateEdit("", 8, 104, 486, 637)   ;   1 edit
;GUICtrlSetData(-1, "1")
$edit732 = GUICtrlCreateEdit("", 511, 104, 486, 637) ;   2 edit
;GUICtrlSetData(-1, "2")
$label652 = GUICtrlCreateLabel("Orginalny tekst", 13, 59, 477, 31, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$label214 = GUICtrlCreateLabel("Przetłumaczony tekst", 512, 60, 481, 31, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
;$combo35 = GUICtrlCreateCombo("", 1009, 297, 158, 25)
;GUICtrlSetData(-1, "Mein Text")
;$label640 = GUICtrlCreateLabel("Zmień kodowanie", 1008, 270, 153, 15, $SS_CENTER)
$Otworz = GUICtrlCreateButton("Otwórz", 1029, 376, 119, 40)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Start = GUICtrlCreateButton("Start", 1030, 478, 116, 39)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
;$Stop  = GUICtrlCreateButton("Stop", 1032, 554, 113, 40)
;GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Zapisz = GUICtrlCreateButton("Zapisz", 1031, 640, 113, 40)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$label414 = GUICtrlCreateLabel("0 %", 939, 762, 70, 23, $SS_CENTER)
$progressbar1 = GUICtrlCreateProgress(8, 760, 918, 16)
;----------------------------
If FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
               $jjdefault = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )
Endif

            $il_kluczy =$jjdefault[0][0]
$Combo1 = GUICtrlCreateCombo("", 1032, 104, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("", 1032, 168, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Jcombo1 = $jjdefault [($jjdefault [1][1])][1]
$Jcombo2 = $jjdefault [($jjdefault [2][1])][1]
For $x=4 to $il_kluczy step +2
    GUICtrlSetData($Combo1, $jjdefault [$x][1],$Jcombo1)
    GUICtrlSetData($Combo2, $jjdefault [$x][1],$Jcombo2)
Next
;---------------------------

$Label1 = GUICtrlCreateLabel("Z", 1032, 72, 115, 17, $SS_CENTER)
$Label2 = GUICtrlCreateLabel("Na", 1032, 144, 114, 17, $SS_CENTER)
;$ToolBar1 = _GUICtrlToolbar_Create($GUI, 0)
;$Combo3 = GUICtrlCreateCombo("Otwórz plik", 1008, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Input1 = GUICtrlCreateInput("Otwórz plik", 1008, 8, 145, 25)
$Label3 = GUICtrlCreateLabel("Typ pliku:", 848, 8, 138, 17, $SS_RIGHT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Otworz
            Otworz()

        Case $Start ; po nacisnieciu Start wykonuje
            Start()

        Case $Zapisz ;zapisz
            zapisz()

        Case   $Combo1
                combo1()

        Case   $Combo2
                combo2()

    EndSwitch
WEnd


;Func combo1()   ; FUNKCJA 1

;EndFunc

Func combo1()   ; FUNKCJA 1
Local $jjdefault

                   ; czyta combo6 i przyrównuje z tekstem
             $last=''
             $read = GUICtrlRead($Combo1)
             If $last <> $read Then
             $last = $read



        ;-----------------------PETLA------------------------------------------------------
;If FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
;              $jjdefault = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )
;Endif
Local $jjdefault
          For $i = 4 to $jjdefault[0][0] Step +2  ; ma dodawać od 4 wartosci do konca co 2
                    If $read = $jjdefault[$i][1] Then  ;  Jezeli tekst z combo1 = tekstowi z pliku to...

                     IniWrite(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz", $jjdefault [1][0], $i)  ;Zapisuje: plik,secja,klucz,wartosc

                    EndIf
           Next
        ;  --------------------------KONIEC PETLI ------------------------------------------


        Endif

  EndFunc

Func combo2()   ; FUNKCJA 2
Local $jjdefault

                   ; czyta combo6 i przyrównuje z tekstem
             $last=''
             $read = GUICtrlRead($Combo2)
             If $last <> $read Then
             $last = $read

            Endif

        ;-----------------------PETLA------------------------------------------------------
Local       $jjdefault
If FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
;              $jjdefault = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )
Endif
          For $i = 4 to $jjdefault[0][0] Step +2  ; ma dodawać od 4 wartosci do konca co 2
                    If $read = $jjdefault[$i][1] Then  ;  Jezeli tekst z combo1 = tekstowi z pliku to...

                     IniWrite(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz", $jjdefault [2][0], $i)  ;Zapisuje: plik,secja,klucz,wartosc

                    EndIf
           Next
        ;  --------------------------KONIEC PETLI ------------------------------------------




  EndFunc


Func Otworz() ; funkcja wybierania pliku
    $File = FileOpenDialog("Wybierz pliczek",@WorkingDir, "Pliki .xml , .ini , .txt (*.xml;*.ini;*.txt)") ;otwiera okno dialogowe i umozliwia wybór pliki tekstowego  ; "c:"
    GUICtrlSetData($edit731, FileRead($File)) ; wpisuje zawartoć pliku do okienka edit
    ;$odczytzpliku = 1
EndFunc


;----------------------------------------------------------------------------------------------------------------

Func Start()
$plik_zrodlowy = GUICtrlRead($edit731)
$stringbetween = _StringBetween($plik_zrodlowy,'<v>','</v>')
;$iloscWtablicy=UBound($stringbetween) ; liczy ilość słów w tablicy
$stringbetween2 = _StringBetween($plik_zrodlowy,'[',']')

If ((UBound($stringbetween)) <= 0  and (UBound($stringbetween2)) <= 0 ) then  MsgBox(16, "Error ", "Nie rozpoznano pliku.")
If  (UBound($stringbetween)) > 0  then  Start_dalej_xml()
If  (UBound($stringbetween2)) > 0  then  Start_dalej_ini()
EndFunc



Func Start_dalej_xml()
GUICtrlSetData($Input1, ".XML")
$plik_zrodlowy = GUICtrlRead($edit731)
$stringbetween = _StringBetween($plik_zrodlowy,'<v>','</v>')
MsgBox(0, "Ilosc w tablicy" , UBound($stringbetween))
GUICtrlSetData($edit732, $plik_zrodlowy)


$s = 0; progressbar-saveposition
       $msg = GUIGetMsg()
; $msg = $Start Then
            GUICtrlSetData($Start, "Stop")
       For $x = 0 To UBound($stringbetween) -1
     ;  sleep(500)
           $m = GUIGetMsg()

            If $m = -3 Then ExitLoop

            If $m = $Start Then
           ;    GUICtrlSetData($Start, "Next")
          ;  $s = $x  ;save the current bar-position to $s
                 ExitLoop

                 Else
                    $s = 0
                    $k= UBound($stringbetween)
                    $ka = 100/$k
                    $kl = $ka * ($x+1)
                    $S1 = StringFormat("%d", $kl)  ; zamiana na całe bez zaokraglania
                    GUICtrlSetData($progressbar1,  $S1)

            Endif

                   $nazwa_en = $stringbetween[$x]
;combo1()
;combo2()

                 If   FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
                      $jjdefaultXml = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )

                  endif
                $il_kluczyy1 =$jjdefaultXml[0][0]
                  MsgBox(0, "Postęp $x0: ",$il_kluczyy1 )
                $1wartXml = $jjdefaultXml[1][1]
                MsgBox(0, "Postęp $x0: ",$1wartXml )
                  $Ang = $jjdefaultXml[$1wartXml-1][1]
                    $Pol = $jjdefaultXml[$jjdefaultXml [2][1]-1][1]

  $read = BinaryToString(InetRead("http://translate.google.pl/m?hl=en&sl="&$Ang&"&tl="&$Pol&"&ie=UTF-8&q="& _URIEncode($nazwa_en)), 1) ; & _URIEncode
  ;sleep(1000)
  $regexp2 = StringRegExp($read, '<div dir="ltr" class="t0">(.*?)</div>', 1)

  $nazwa_pl1 =ISO88592_to_ANSI_1($regexp2[0])
  ;$nazwa_pl1 =   _ConvertAnsiToUtf8($nazwa_pl1a)


  $nazwa_pl = '<v>'&$nazwa_pl1&'</v>'
  $nazwa_en2 = '<v>'&$nazwa_en&'</v>'
;MsgBox(0, "Postęp tłumaczenia: ",$nazwa_en2 &'-'&$nazwa_pl )

  $x0 = GUICtrlRead($edit732)
  ;MsgBox(0, "Postęp $x0: ",$x0 )
  $tresc2 = StringReplace($x0 , $nazwa_en2, $nazwa_pl)


  GUICtrlSetData($edit732, $tresc2)
  GUICtrlSetData($label414, $S1 & "%")
  Sleep(1000)
Next
GUICtrlSetData($Start, "Start")
EndFunc



Func Start_dalej_ini()
GUICtrlSetData($Input1, ".INI")
$plik_zrodlowy = GUICtrlRead($edit731)
; = ()
$stringbetween = _StringBetween($plik_zrodlowy,'=', @CRLF )
MsgBox(0, "Ilosc w tablicy" , UBound($stringbetween))
GUICtrlSetData($edit732, $plik_zrodlowy)


$s = 0; progressbar-saveposition
       $msg = GUIGetMsg()
; $msg = $Start Then
            GUICtrlSetData($Start, "Stop")
For $x = 0 To UBound($stringbetween) - 1
     ;  sleep(500)
           $m = GUIGetMsg()

            If $m = -3 Then ExitLoop

            If $m = $Start Then
           ;    GUICtrlSetData($Start, "Next")
          ;  $s = $x  ;save the current bar-position to $s
                 ExitLoop

                 Else
                    $s = 0
                    $k= UBound($stringbetween)
                    $ka = 100/$k
                    $kl = $ka * ($x+1)
                    $S1 = StringFormat("%d", $kl)  ; zamiana na całe bez zaokraglania
                    GUICtrlSetData($progressbar1,  $S1)

            Endif
                    $nazwa_en = $stringbetween[$x]

;   $jen='en'
;   $jpl='pl'
Local $jjdefault
combo1()
combo2()
If FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
    $jjdefault = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )
Endif
    $Ang = $jjdefault[($jjdefault [1][1])-1][1]
    $Pol = $jjdefault[($jjdefault [2][1])-1][1]
MsgBox(0, "Postęp tłumaczenia: ",$Ang )
MsgBox(0, "Postęp tłumaczenia: ",$Pol )
  $read = BinaryToString(InetRead("http://translate.google.pl/m?hl=en&sl="&$Ang&"&tl="&$Pol&"&ie=UTF-8&q="& _URIEncode($nazwa_en)), 1) ; & _URIEncode
  ;sleep(1000)
  $regexp2 = StringRegExp($read, '<div dir="ltr" class="t0">(.*?)</div>', 1)

  $nazwa_pl1 =ISO88592_to_ANSI_1($regexp2[0])
  ;$nazwa_pl1 =   _ConvertAnsiToUtf8($nazwa_pl1a)


  $nazwa_pl  =  '='&$nazwa_pl1 &@CRLF
  $nazwa_en2 =  '='&$nazwa_en  &@CRLF
  ;MsgBox(0, "Postęp tłumaczenia: ",$nazwa_en2 &'-'&$nazwa_pl )

  $x0 = GUICtrlRead($edit732)
  ;MsgBox(0, "Postęp $x0: ",$x0 )
  $tresc2 = StringReplace($x0 , $nazwa_en2, $nazwa_pl)


  GUICtrlSetData($edit732, $tresc2)
  GUICtrlSetData($label414, $S1 & "%")
  Sleep(1000)


Next
GUICtrlSetData($Start, "Start")






EndFunc


;----------------------------------------------------------------------------------------------------




Func  zapisz()

$var = FileSaveDialog ( "nazwa",@WorkingDir , "Pliki (*.txt)|(*.ini)|(*.xml)",4)

If @error Then
    MsgBox(4096,"","Nie zapisano.")

Else

    $plik_docelowy = GUICtrlRead($edit732)

$file = FileOpen($var, 2 + 8)
FileWrite($file, $plik_docelowy)
FileClose($file)


    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","Zapisano do:  " & $var)


EndIf
EndFunc






Func ISO88592_to_ANSI_1($sText = "")
Local $sRet = "", $CODEPAGE[19][2] = [[179, "ł"],[163, "Ł"],[230, "ć"],[198, "Ć"],[166, "Ś"],[182, "ś"],[211, "ó"],[243, "ó"],[177, "ą"],[161, "Ą"],[202, "Ę"],[234, "ę"],[188, "ź"],[172, "Ź"],[175, "Ż"],[191, "ż"],[209, "Ń"],[241, "ń"]]
For $iIter = 1 To StringLen($sText) Step 1
$itmp = StringMid($sText, $iIter, 1)
For $iRep = 1 To 18 Step 1
If Asc($itmp) = $CODEPAGE[$iRep][0] Then $itmp = $CODEPAGE[$iRep][1]
Next
$sRet &= $itmp
Next
Return $sRet
EndFunc ;==>ISO88592_to_UNICODE





; zrodlo: http://www.autoitscript.com/forum/topic/95850-url-encoding/page__view__findpost__p__689060
Func _URIEncode($sData)
; Prog@ndy
Local $aData = StringSplit(BinaryToString(StringToBinary($sData, 4), 1), "")
Local $nChar
$sData = ""
For $i = 1 To $aData[0]
;ConsoleWrite($aData[$i] & @CRLF)
$nChar = Asc($aData[$i])
Switch $nChar
Case 45, 46, 48 - 57, 65 To 90, 95, 97 To 122, 126
$sData &= $aData[$i]
Case 32
$sData &= "+"
Case Else
$sData &= "%" & Hex($nChar, 2)
EndSwitch
Next
Return $sData
EndFunc ;==>_URIEncode

Programik.zip

Test.tra.xml

Edited by tele123
Link to comment
Share on other sites

You're redeclaring $jjdefault as a local variable inside your functions so when you do that, they're not the arrays you think they are.

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

Link to comment
Share on other sites

Where I'm redeclaring $jjdefault?

$jjdefault working inside

Func Start_dalej_xml()

, because I' don' understand - Can you explain or and change it?

$jjdefault, is old $jjdefault, from first IniReadSection, and I can not put new IniReadSection.

And when I use Func Start_dalej_xml() , I can not change the language in Combo1 and combo2.

Edited by tele123
Link to comment
Share on other sites

Everytime you enter any of your functions, you're redeclaring $jjdefault as a local variable, which means you're not using the array variable you created before entering the function. That means you are using the local version of the variable inside the functions, this local variable is a simple variable and not an array, so you get errors everytime you try to access the array version of it.

Look in the help file for explanations about variable scope, because your script is seriously broken because you're not understanding the difference. Also, you are declaring the local variable at least twice in some of your functions.

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

Link to comment
Share on other sites

If "ini file" exists --> load ini values into $jjdefault Array

But if "ini file" doesnt exist? (and that is what happens when you run the script the first time)

Then the $jjdefault variable has not been created.

Solution: Define the $jjdefault as empty Array before you use it.

dim $jjdefault[10][10]
If FileExists(@WorkingDir&"UstawieniaTlumacz.ini") Then
               $jjdefault = IniReadSection(@WorkingDir&"UstawieniaTlumacz.ini", "Tlumacz" )
Endif

No warranties all works correct with an empty array at first start, you have to check and for yourself.

Edit: I saw that in the rar archive an ini file is included, but anyway you should mind the possibiltiy that the ini is not always there. And of course you should fix the local declaration in the funcs. If you want to use the global ini array in a function, you dont need to redeclare it local. You can just use it. However if you want to read new/other values you should also use a new variable.

Edited by qsek
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Link to comment
Share on other sites

I don't understant why I' can 't change name $jjdefault

example :

$jjdefaultXml = IniReadSection(@WorkingDir&"\Ustawienia\Tlumacz.ini", "Tlumacz" )

and this is the same $jjdefault and 1 Local I can not replace the other (of the same name )

Look in the help file for explanations about variable scope

Ok, I'm try . Thanks

Edit:

I placed each in a separate function IniReadSection

variable used without being declared

Dim or local

Subscript used with non-Array variable

Now I read this http://www.autoitscript.com/wiki/Variables_-_using_Global,_Local_and_ByRef

_______________________________________________

Edit2 :

;)

If can't use

...
Func 1
  variable = IniReadSection("The same name, path , etc. " )
EndFunc

Func 2
  variable other = IniReadSection("The same name, path , etc. " )
EndFunc
...

Can I redeclare and again declare?

How do you call a library that supports IniReadSection?

For the evening, try with:

#include <Array.au3>

$var = IniReadSection("The same name, path , etc. ")

Local $arr[$var[0][0]]
For $i = 1 To $var[0][0]
    $arr[$i-1] = $var[$i][1]
Next
_ArrayDisplay($arr)

_______________________

Edit:

I don't know how , I can't use IniReadSection .

I use FileOpen and _StringBetween for read

$plik_xml = Fileopen(@WorkingDir&"\Ustawienia\Tlumacz.ini",0)
$string1 = _StringBetween($plik_xml,'1=',@CRLF)
$Ang = _StringBetween($plik_xml,($string1-1)&'=',@CRLF)
$string3 = _StringBetween($plik_xml,'2=',@CRLF)
$Pol = _StringBetween($plik_xml,($string3-1)&'=',@CRLF)
Fileclose($plik_xml)

Only , not working for me ;), but maybe will.

I put

If FileExists(@WorkingDir&"\Ustawienia\Tlumacz.ini") Then
               $plik_xml = FileOpen(@WorkingDir&"\Ustawienia\Tlumacz.ini", 0 )
               Else
    MsgBox(4096, "File", "File:@WorkingDir&\Ustawienia\Tlumacz.ini, Does NOT exists")
Endif

And... I have "File:@WorkingDir&\Ustawienia\Tlumacz.ini, Does NOT exists"

But file exist :)

_____________________________________________________________

Edit.

I have done differently,

the program uses only one function IniReadFile,

and resets

there is only one drawback, pressing the "Start" program breaks down (do not see this) :)

Then when you press the "combo" program closes, but will not start a new one.

If you won try - "Run" working only with .exe files.

Programik.zip

Edited by tele123
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...