Sign in to follow this  
Followers 0
JonBMN

[SOLVED]Putting Array values into GUI box (getting all values into the array)

15 posts in this topic

#1 ·  Posted (edited)

I'm trying to take array values which I can't seem to get all the values into the array to send to the GUI window and I can't seem to get the array to even go into the GUI window. Here is the FULL code I'm working with.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Green.ico
#AutoIt3Wrapper_Outfile=DriverInstall.exe
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
AutoItWinSetTitle("Driver Install")
AutoItSetOption("MustDeclareVars", 1)
Opt("TrayMenuMode", 0)
#NoTrayIcon
#include-once
#RequireAdmin

#include <GUIconstants.au3>
#include <myerror.au3>
#include <misc.au3>
#include <Array.au3>

If _Singleton("Driver Install", 1) = 0 Then
Exit
EndIf

Local $Result
Local $NumComports = -1, $OrigPortNum[30]
Local $NewPortNum[30], $NewNumComports = -1
Local $GUIhandle, $CM[10], $AddedPort, $msg, $newports[20], $oldports[20]

; Update registry to ignor dongle serial number
$Result = RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\UsbFlags", "IgnoreHWSerNum04036001", "REG_BINARY", Chr(1))
If $Result = 0 Then
$ErrorTitle = "Error Updating Registry"
$ErrorMessage = "Unable to update registry UsbFlags"
$IsErrorFatal = True
MyError()
EndIf

MsgBox(0, "Alert!", "Please make sure OBD processor is not plugged into the computer.")

BuildOriginal()
Run("CDM20828.EXE")
MsgBox(0, "Alert!", "Now plug in the OBD processor into the USB port on the computer. When you have plugged it in click OK.")
BuildNew()
GUIwindow()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Quit()
EndSelect
WEnd
Exit

Func Quit()
Exit
EndFunc

Func BuildOriginal()
Local $Instance = 1, $Key = "", $Port = "", $Found = False
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NumComports += 1
$OrigPortNum[$NumComports] = $Port
$Instance += 1
WEnd
for $Instance = 0 To $NumComports
_ArrayPush($OrigPortNum,$OrigPortNum[$Instance], 0)
Next
EndFunc




Func BuildNew()
Local $Instance = 1, $Key = "", $Port = "", $Found = False, $i = 0
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NewNumComports += 1
$NewPortNum[$NewNumComports] = $Port
$Instance += 1
WEnd
for $Instance = 0 To $NewNumComports
_ArrayPush($NewPortNum,$NewPortNum[$Instance], 0)
Next
For $i = 0 To $NewNumComports
If ($NewPortNum[$i] <> $OrigPortNum[$i]) Then
;MsgBox(0, "Alert!", "Found new Port!" & $NewPortNum[$i])
$Addedport = $NewPortNum[$i]
ExitLoop
EndIf
Next
EndFunc

Func GUIwindow()
$GUIhandle = GUICreate("Port Settings", 455, 325)
GUICtrlCreateLabel("-Before OBD doggle plugin-", 15, 25)
$CM[1] = GUICtrlCreateEdit("", 15, 45, 180, 100, 400)
GUICtrlSetData($CM[1], $OrigPortNum, $OrigPortNum)
GUICtrlCreateLabel("-After OBD doggle plugin-", 250, 25)
$CM[2] = GUICtrlCreateEdit("", 250, 45, 180, 100, 400)
GUICtrlSetData($CM[2], $NewPortNum, $NewPortNum)
GUICtrlCreateLabel("This is the added port:", 15, 300)
$CM[3] = GUICtrlCreateEdit("", 120, 300, 150, 20)
GUICtrlSetData($CM[3], $AddedPort, $AddedPort)
GUISetState(@SW_SHOW) ;shows the GUI window
EndFunc
Edited by JonBMN

Share this post


Link to post
Share on other sites

Well, you can't apply the contents of an array to an edit box directly. You should loop through the array and add each value to a string, and then use the string to update the edit control.


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

Any chance you could give me a basic example of this?

Share this post


Link to post
Share on other sites

JonBMN,

About as basic as I can make it: ;)

#include <GUIConstantsEx.au3>

; Here is the array
Global $aLines[4] = [3, "Line 1", "Line 2", "Line 3"]

$hGUI = GUICreate("Test", 500, 500)

$cEdit = GUICtrlCreateEdit("", 10, 10, 200, 200)

$cButton = GUICtrlCreateButton("Load Array", 10, 400, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            ; Start with an empty string
            $sData = ""
            ; Loop through the array and add each line to the string - do not forget the line break
            For $i = 1 To $aLines[0]
                $sData &= $aLines[$i] & @CRLF
            Next
            ; And finally, add the string to the edit
            GUICtrlSetData($cEdit, $sData)
    EndSwitch

WEnd

All clear?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Yes, thank you!

Share this post


Link to post
Share on other sites

This example is a very basic demo that shows what I was talking about.

You don't really need the _ArrayToString function if you build the string as you build the array, but I used it for simplicity.

#include <GUIconstants.au3>
#include <misc.au3>
#include <Array.au3>

If _Singleton("Driver Install", 1) = 0 Then
    Exit
EndIf

Local $Result
Local $NumComports = -1, $sOrigPortNum
Local $sNewPortNum, $NewNumComports = -1
Local $GUIhandle, $CM[10], $AddedPort, $msg, $newports[20], $oldports[20]

BuildOriginal()
BuildNew()
GUIwindow()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Quit()
    EndSelect
WEnd

Func BuildNew()
    Local $NewPortNum[30]
    For $I = 0 To 29
        $NewPortNum[$I] = $I
    Next
    $sNewPortNum = _ArrayToString($NewPortNum, @CRLF)
EndFunc   ;==>BuildNew

Func BuildOriginal()
    Local $OrigPortNum[30]
    For $I = 0 To 29
        $OrigPortNum[$I] = $I
    Next
    $sOrigPortNum = _ArrayToString($OrigPortNum, @CRLF)
EndFunc   ;==>BuildOriginal

Func GUIwindow()
    $GUIhandle = GUICreate("Port Settings", 455, 325)
    GUICtrlCreateLabel("-Before OBD dongle plugin-", 15, 25)
    $CM[1] = GUICtrlCreateEdit("", 15, 45, 180, 100, 400)
    GUICtrlSetData($CM[1], $sOrigPortNum)
    GUICtrlCreateLabel("-After OBD dongle plugin-", 250, 25)
    $CM[2] = GUICtrlCreateEdit("", 250, 45, 180, 100, 400)
    GUICtrlSetData($CM[2], $sNewPortNum)
    GUICtrlCreateLabel("This is the added port:", 15, 300)
    $CM[3] = GUICtrlCreateEdit("", 120, 300, 150, 20)
    GUICtrlSetData($CM[3], $AddedPort, $AddedPort)
    GUISetState(@SW_SHOW) ;shows the GUI window
EndFunc   ;==>GUIwindow

Func Quit()
    Exit
EndFunc   ;==>Quit


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

Thank you both. Both examples will give me a better understanding of what is going on.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It seems to be only putting in the last value of the array that's being looped through into the $orig = "" which is my initialized string variable that I want to hold all my array values.

Func BuildOriginal()
Local $Instance = -1, $Key = "", $Port = "", $Found = False
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NumComports += 1
$OrigPortNum[$NumComports] = $Port
$Instance += 1
WEnd
for $Instance = 0 To $NumComports
$orig = $OrigPortNum[$Instance] & @CRLF
Next
EndFunc

so if I had two com ports 13 and 35 the only one it sends to the GUI is 35.

Edited by JonBMN

Share this post


Link to post
Share on other sites

You're missing the "&" before the "=".

$orig &= $OrigPortNum[$Instance] & @CRLF


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

#10 ·  Posted (edited)

After adding that, I seem to get nothing from the BuildOriginal() function, but the BuildNew() function seems to be working perfectly...

Local $orig = "", $new = ""
Func BuildOriginal()
Local $Instance = -1, $Key = "", $Port = "", $Found = False
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NumComports += 1
$OrigPortNum[$NumComports] = $Port
$Instance += 1
WEnd
for $Instance = 0 To $NumComports
$orig &= $OrigPortNum[$Instance] & @CRLF
Next
EndFunc




Func BuildNew()
Local $Instance = 1, $Key = "", $Port = "", $Found = False, $i = 0
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NewNumComports += 1
$NewPortNum[$NewNumComports] = $Port
$Instance += 1
WEnd
for $Instance = 0 To $NewNumComports
$new &= $NewPortNum[$Instance] & @CRLF
Next
For $i = 0 To $NewNumComports
If ($NewPortNum[$i] <> $OrigPortNum[$i]) Then
;MsgBox(0, "Alert!", "Found new Port!" & $NewPortNum[$i])
$Addedport = $NewPortNum[$i]
ExitLoop
EndIf
Next
EndFunc
Edited by JonBMN

Share this post


Link to post
Share on other sites

You declared the $Instance variable in BuildNew as -1 instead of 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

Ah the little things! thanks for catching that one BrewManNH

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

My program seems to be working perfectly, but when I move it over to a windows XP for testing the $orig and $new values do not show up in the edit control, but I put a msgbox and saw all the com ports from these variables. Any answers to why it may not be showing up?

Edited by JonBMN

Share this post


Link to post
Share on other sites

No clue, I don't have an XP machine to test it on.


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

#15 ·  Posted (edited)

Local $orig = "", $new = ""
Func BuildOriginal()
Local $Instance = -1, $Key = "", $Port = "", $Found = False
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NumComports += 1
$OrigPortNum[$NumComports] = $Port
$Instance += 1
WEnd
for $Instance = 0 To $NumComports
$orig &= $OrigPortNum[$Instance] & @CRLF
Next
EndFunc




Func BuildNew()
Local $Instance = 1, $Key = "", $Port = "", $Found = False, $i = 0
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NewNumComports += 1
$NewPortNum[$NewNumComports] = $Port
$Instance += 1
WEnd
for $Instance = 0 To $NewNumComports
$new &= $NewPortNum[$Instance] & @CRLF
Next
For $i = 0 To $NewNumComports
If ($NewPortNum[$i] <> $OrigPortNum[$i]) Then
;MsgBox(0, "Alert!", "Found new Port!" & $NewPortNum[$i])
$Addedport = $NewPortNum[$i]
ExitLoop
EndIf
Next
EndFunc

Figured out what was going wrong on the XP machine. It was not the fact that it was an XP it had to many values in the array for the SetData to put into the Edit control. Posting BuildOriginal() function, BuildNew() function along with GUI function.. Not going to post first half as it is posted at top.

Local $orig = "", $new = ""
Func BuildOriginal()
Local $Instance = 1, $Key = "", $Port = "", $Found = False
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NumComports += 1
$OrigPortNum[$NumComports] = $Port
$orig &= $Port & " ** " & $Key & @CRLF
$Instance += 1
WEnd
EndFunc




Func BuildNew()
Local $Instance = 1, $Key = "", $Port = "", $Found = False, $i = 0
While 1
$Key = RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $Instance)
If @error = -1 Then
ExitLoop
     EndIf
$Port = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM",$Key )
$NewNumComports += 1
$NewPortNum[$NewNumComports] = $Port
$new &= $Port & " ** " & $Key & @CRLF
$Instance += 1
WEnd
For $i = 0 To $NewNumComports
If ($NewPortNum[$i] <> $OrigPortNum[$i]) Then
$Addedport = $NewPortNum[$i]
ExitLoop
EndIf
Next
EndFunc

Func GUIwindow()
$GUIhandle = GUICreate("Port Settings", 455, 325)
GUICtrlCreateLabel("-Before OBD doggle plugin-", 15, 25)
$CM[1] = GUICtrlCreateEdit("", 15, 45, 180, 200)
GUICtrlSetData($CM[1], $orig, $orig)
GUICtrlCreateLabel("-After OBD doggle plugin-", 250, 25)
$CM[2] = GUICtrlCreateEdit("", 250, 45, 180, 200)
GUICtrlSetData($CM[2], $new, $new)
GUICtrlCreateLabel("This is the added port:", 15, 300)
$CM[3] = GUICtrlCreateEdit("", 120, 300, 150, 20)
GUICtrlSetData($CM[3], $AddedPort, $AddedPort)
GUISetState(@SW_SHOW) ;shows the GUI window
EndFunc

EDIT: cleaned up the code a bit in BuildOriginal() and BuildNew()

Edited by JonBMN

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

  • Similar Content

    • Ascer
      By Ascer
      1. Description.
      Udf working with MSDN System.Collections.ArrayList. Allow you to make fast operations on huge arrays, speed is even x10 better than basic _ArrayAdd.  Not prefered for small arrays < 600 items. 2. Requirements
      .NET Framework 1.1+ System Windows 3. Possibilities.
      ;=============================================================================================================== ; UDF Name: List.au3 ; ; Date: 2018-02-17, 10:52 ; Description: Simple udf to create System Collections as ArrayList and make multiple actions on them. ; ; Function(s): _ListCreate -> Creates a new list ; _ListCapacity -> Gets a list size in bytes ; _ListCount -> Gets items count in list ; _ListIsFixedSize -> Get bool if list if fixed size ; _ListIsReadOnly -> Get bool if list is read only ; _ListIsSynchronized -> Get bool if list is synchronized ; _ListGetItem -> Get item on index ; _ListSetItem -> Set item on index ; ; _ListAdd -> Add item at end of list ; _ListClear -> Remove all list items ; _ListClone -> Duplicate list in new var ; _ListContains -> Get bool if item is in list ; _ListGetHashCode -> Get hash code for list ; _ListGetRange -> Get list with items between indexs ; _ListIndexOf -> Get index of item ; _ListInsert -> Insert a new item on index ; _ListInsertRange -> Insert list into list on index ; _ListLastIndexOf -> Get index last of item ; _ListRemove -> Remove first found item ; _ListRemoveAt -> Remove item in index ; _ListRemoveRange -> Remove items between indexs ; _ListReverse -> Reverse all items in list ; _ListSetRange -> Set new value for items in range ; _ListSort -> Sort items in list (speed of reading) ; _ListToString -> Get list object name ; _ListTrimToSize -> Remove unused space in list ; ; Author(s): Ascer ;=============================================================================================================== 4. Downloads
      List.au3 5. Examples
      SpeedTest _ArrayAdd vs ListAdd SpeedTest ArraySearch vs ListIndexOf Basic usage - crating guild with members  
    • FMS
      By FMS
      Hello,
      I'm trying to read a binary file to an array but couln't get it to work.
      Also I coul not find any help in the forum around this subject whish was helpfull.
      Is there any way it could be done?
      I tried a lot of ways but maybe somebody know's the right way?
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <File.au3> #include <Array.au3> #include <AutoItConstants.au3> Local $in=FileOpen("TEST_labels.idx1-ubyte",16) ; 16+0=Read binary Local $data = FileRead($in) Local $FileArray = BinaryToString($data,4) ;~ $FileArray = StringSplit($BinarydData, @CRLF, 1+2) ;~ Local $FileArray = StringRegExp($BinarydData, "[^\r\n]+", 3) FileClose($in) _ArrayDisplay($FileArray,"$FileArray","",32) MsgBox($MB_SYSTEMMODAL, "", "$FileArray = " & $FileArray )  
      TEST_labels.idx1-ubyte
    • ur
      By ur
      I am reading a CSV file which is tab seperated as below.
      Local $aArray = FileReadToArray($file) And now, I am splitting this main array record wise so that Array contains internally another arrow to represent each row.
      For $i = 0 to (UBound($aArray) - 1) ;MsgBox(0,"",$aArray[$i]) $aArray[$i] = StringSplit(StringStripCR($aArray[$i]), Chr(9),2);Chr(9) for tab ;_ArrayDisplay($aArray[$i]) Next Afther that, _ArrayDIsplay is able to see the individual internal arrays.
      _ArrayDisplay($aArray[1]) But If I try to access the individual element of it as below.It is not showing any result.
      MsgBox(0,"",$aArray[1][1]) Any suggestion, below is the sample csv file.
      New Text Document.csv
    • Amixg
      By Amixg
      Hi! I have another problem with AutoIT.  You see, I'm still the one who's just starting out with this great programming language. I have a problem with AutoIT, it seems not to recognize the "StringReplace" function even when it is by default. The code was made half in KODA and half of my own. It is a software programmed for the Italian language (I am Italian) and translate the SMS language into Italian correct. Would you help me? Thanks in advance.
       
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $hull = "hello" StringReplace($hull, "hello", "hellx") $Form1 = GUICreate("Linguaggio SMS A Italiano", 507, 498, 192, 124) $Edit1 = GUICtrlCreateEdit("", 24, 40, 465, 177) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("Inserisci qui il testo che non riesci a capire:", 24, 8, 205, 17) $Label2 = GUICtrlCreateLabel("Ecco il testo tradotto(non toccare questo campo):", 27, 237, 237, 17) $Edit2 = GUICtrlCreateEdit("", 24, 264, 465, 137) GUICtrlSetData(-1, "") $Button1 = GUICtrlCreateButton("Traduci", 104, 424, 249, 49) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 StringReplace(GUICtrlGetData($Label1), "qlc", "qualcuno") StringReplace(GUICtrlGetData($Label1), "qls", "qualcosa") StringReplace(GUICtrlGetData($Label1), "ke", "che") StringReplace(GUICtrlGetData($Label1), "x", "per") StringReplace(GUICtrlGetData($Label1), "pls", "per favore") StringReplace(GUICtrlGetData($Label1), "tu6", "tu sei") StringReplace(GUICtrlGetData($Label1), "zzz", "mi fai dormire") StringReplace(GUICtrlGetData($Label1), "hagn", "Buonanotte") StringReplace(GUICtrlGetData($Label1), "tvtb", "Ti voglio tanto bene") StringReplace(GUICtrlGetData($Label1), "tat", "Ti amo tanto") StringReplace(GUICtrlGetData($Label1), "lafs", "Amore a prima vista") StringReplace(GUICtrlGetData($Label1), "fli?", "Flirtiamo?") StringReplace(GUICtrlGetData($Label1), "msidt", "Mi sono innamorato di te") StringReplace(GUICtrlGetData($Label1), "ba", "Bacio") StringReplace(GUICtrlGetData($Label1), "midi", "Mi dispiace.") StringReplace(GUICtrlGetData($Label1), "ntm", "Non ti merito") StringReplace(GUICtrlGetData($Label1), "tdp", "Togliti dai piedi.") StringReplace(GUICtrlGetData($Label1), "amò", "Amore") StringReplace(GUICtrlGetData($Label1), "ap", "A presto!") StringReplace(GUICtrlGetData($Label1), "cmq", "comunque") StringReplace(GUICtrlGetData($Label1), "cvd", "Ci vediamo dopo") StringReplace(GUICtrlGetData($Label1), "Tvb", "Ti voglio bene") StringReplace(GUICtrlGetData($Label1), "nn", "non") StringReplace(GUICtrlGetData($Label1), "risp", "rispondimi") StringReplace(GUICtrlGetData($Label1), "cel", "cellulare") StringReplace(GUICtrlGetData($Label1), "dom", "qualcosa") StringReplace(GUICtrlGetData($Label1), "nm", "numero") StringReplace(GUICtrlGetData($Label1), "fv", "favore") StringReplace(GUICtrlGetData($Label1), "-male", "meno male") StringReplace(GUICtrlGetData($Label1), "disc", "discoteca") StringReplace(GUICtrlGetData($Label1), "se#", "settimana") StringReplace(GUICtrlGetData($Label1), "+ o -", "più o meno") StringReplace(GUICtrlGetData($Label1), "ts", "torno subito") StringReplace(GUICtrlGetData($Label1), "tvtbcoa", "Ti voglio tanto bene come amica") EndSwitch WEnd  
    • Jibsbrown
      By Jibsbrown
      Need some help understanding why the ConsoleWrite works inside 2nd For loop but not out side. Between Audit Wiki, Help file , Forum searching (lots of code reading), and YouTube ( shout out to TutsTeach), I have not been able to find the reason why. 
      $sIniPath = "installLog.ini" ; - Get section name $iniSctionNames = IniReadSectionNames($sIniPath) ; - Get Keys and Vaules For $a = 1 to UBound($iniSctionNames) - 1 $keys = IniReadSection($sIniPath , $iniSctionNames[$a]) For $b = 1 to UBound($keys) - 1 $oldSysInfo = IniRead($sIniPath , $iniSctionNames[1], $keys[$b][0], "") $PntIPInfo = IniRead($sIniPath , $iniSctionNames[2], $keys[$b][0], "") $NewPCInfor = IniRead($sIniPath , $iniSctionNames[3], $keys[$b][0], "") ;ConsoleWrite($oldSysInfo & @LF) Next ;ConsoleWrite($oldSysInfo & @LF) Next ConsoleWrite($oldSysInfo) My intention is to use the variables later for Listboxes. Any explanation, forum post links or whatever would help. Sorry also very very new to Autoit.
      Also here's the ini file.
      [OldSysInfo] 4=192.168.0.4|DESKTOP-RDIU2SN|R90M05Q8 5=192.168.0.5|SD0123456789101|R9WGP9P 6=192.168.0.6|SD0123456789102|R9WGP9PT 3=192.168.0.3|DESKTOP-3RS4LKL|R9WGP9P 23=192.168.0.23|SD0123456789102|MXL1234P5I [PrinterIp] 50=192.168.0.50 48=192.168.0.48 47=192.168.0.47 [NewSysInfo] newPC = SD0123456789adfs|192.168.0.185|2UA1234FTR Thank you for your time.