Jump to content

move into array


Recommended Posts

I want move values from XXXX into an array and the use the array as the values for a combobox- is there a clean way to do this?

Hi,

XXXX = c:\test.txt

Coding:

#include <file.au3>
#include <GUIConstantsEx.au3>
#Include <GuiComboBox.au3>

Dim $aArray
$file = "c:\test.txt"
$hgui = GUICreate("Test", 320, 180, -1, -1)
$hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)
If Not _FileReadToArray ($file, $aArray) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf

For $x = 1 to UBound ($aArray) - 1
    _GUICtrlComboBox_AddString($hCombo, $aArray [$x])
Next
_GUICtrlComboBox_SetCurSel ($hCombo, 0)
GUISetState()
Do
    $msg = GUIGetMsg()
    Sleep (50)
Until $msg = $GUI_EVENT_CLOSE

You may sort Array $aArray before filling combo (see help _ArraySort). If you want the values reading from an ini file, look for IniRead... in helpfile.

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

Hi,

XXXX = c:\test.txt

Coding:

#include <file.au3>
#include <GUIConstantsEx.au3>
#Include <GuiComboBox.au3>

Dim $aArray
$file = "c:\test.txt"
$hgui = GUICreate("Test", 320, 180, -1, -1)
$hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)
If Not _FileReadToArray ($file, $aArray) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf

For $x = 1 to UBound ($aArray) - 1
    _GUICtrlComboBox_AddString($hCombo, $aArray [$x])
Next
_GUICtrlComboBox_SetCurSel ($hCombo, 0)
GUISetState()
Do
    $msg = GUIGetMsg()
    Sleep (50)
Until $msg = $GUI_EVENT_CLOSE

You may sort Array $aArray before filling combo (see help _ArraySort). If you want the values reading from an ini file, look for IniRead... in helpfile.

;-))

Stefan

thanks!

what if the values are coming from a variable received by another function? so I be reading the values from a function call into an array - how?

Link to comment
Share on other sites

thanks!

what if the values are coming from a variable received by another function? so I be reading the values from a function call into an array - how?

Hi,

just define your variable as global, e.g:

Global $aArray instead of Dim $aArray.

So you can fill array with your function and then fill combobox with array, e.g:

; Fillin the includes you need
Global $aArray
Global $hgui = GUICreate("Test", 320, 180, -1, -1)
Global $hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)

_fillarray ()
_fillcombo ()

GUISetState()

Do
    $msg = GUIGetMsg()
    Sleep (50)
Until $msg = $GUI_EVENT_CLOSE

Func _fillarray ()
    ;filling $aArray with whatever you want
EndFunc

Func _fillcombo ()
    For $x = 1 to UBound ($aArray) - 1 ; depending how your array is created you may need at For $x = 0. 
        _GUICtrlComboBox_AddString($hCombo, $aArray [$x])
    Next
    _GUICtrlComboBox_SetCurSel ($hCombo, 0)
EndFunc

;-))

Stefan

Link to comment
Share on other sites

Hi,

just define your variable as global, e.g:

Global $aArray instead of Dim $aArray.

So you can fill array with your function and then fill combobox with array, e.g:

; Fillin the includes you need
Global $aArray
Global $hgui = GUICreate("Test", 320, 180, -1, -1)
Global $hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)

_fillarray ()
_fillcombo ()

GUISetState()

Do
    $msg = GUIGetMsg()
    Sleep (50)
Until $msg = $GUI_EVENT_CLOSE

Func _fillarray ()
    ;filling $aArray with whatever you want
EndFunc

Func _fillcombo ()
    For $x = 1 to UBound ($aArray) - 1 ; depending how your array is created you may need at For $x = 0. 
        _GUICtrlComboBox_AddString($hCombo, $aArray [$x])
    Next
    _GUICtrlComboBox_SetCurSel ($hCombo, 0)
EndFunc

;-))

Stefan

wow-that looks so easy ! thanks!
Link to comment
Share on other sites

How would I fill the array with the value from an object (really bad code here as its coming back with badly formatted "For") - set up the obect and now trying to gat all possible domains - maximum domains is 10 so I guess I can put a for loop with For $count = 1 To 10

;move into array - but I don't know how to address the object to move into array !!!!!!!!!!!!

Next

Global $tdc = ObjCreate("TDApiOle80.TDConnection")

MsgBox(-1, " ", $qcServer)

$tdc.InitConnectionEx("http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/")

$tdc.Login("joseph.loyzaga", "password1")

Global $aArray

Global $hgui = GUICreate("Test", 320, 180, -1, -1)

Global $hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)

For each $tdc.mDomain in $tdc.QCConnection.VisibleDomains

$aArray = $tdc.mDomain

Next

Hi,

XXXX = c:\test.txt

Coding:

#include <file.au3>
#include <GUIConstantsEx.au3>
#Include <GuiComboBox.au3>

Dim $aArray
$file = "c:\test.txt"
$hgui = GUICreate("Test", 320, 180, -1, -1)
$hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)
If Not _FileReadToArray ($file, $aArray) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf

For $x = 1 to UBound ($aArray) - 1
    _GUICtrlComboBox_AddString($hCombo, $aArray [$x])
Next
_GUICtrlComboBox_SetCurSel ($hCombo, 0)
GUISetState()
Do
    $msg = GUIGetMsg()
    Sleep (50)
Until $msg = $GUI_EVENT_CLOSE

You may sort Array $aArray before filling combo (see help _ArraySort). If you want the values reading from an ini file, look for IniRead... in helpfile.

;-))

Stefan

Link to comment
Share on other sites

How would I fill the array with the value from an object (really bad code here as its coming back with badly formatted "For") - set up the obect and now trying to gat all possible domains - maximum domains is 10 so I guess I can put a for loop with For $count = 1 To 10

;move into array - but I don't know how to address the object to move into array !!!!!!!!!!!!

Next

Global $tdc = ObjCreate("TDApiOle80.TDConnection")

MsgBox(-1, " ", $qcServer)

$tdc.InitConnectionEx("http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/")

$tdc.Login("joseph.loyzaga", "password1")

Global $aArray

Global $hgui = GUICreate("Test", 320, 180, -1, -1)

Global $hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)

For each $tdc.mDomain in $tdc.QCConnection.VisibleDomains

$aArray = $tdc.mDomain

Next

Hi,

Global $tdc = ObjCreate("TDApiOle80.TDConnection")
MsgBox(-1, " ", $qcServer)
$tdc.InitConnectionEx("http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/")
$tdc.Login("joseph.loyzaga", "password1")
Global $aArray [9] ; as you wrote max items 10: 0-9
Global $hgui = GUICreate("Test", 320, 180, -1, -1)
Global $hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)

$i = 0
For each $tdc.mDomain in $tdc.QCConnection.VisibleDomains
    $aArray [$i] = $tdc.mDomain
    $i += 1
Next

:-))

Stefan

Link to comment
Share on other sites

any chance you can help with a gui thing?

$tdc.InitConnectionEx("http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/")

$tdc.InitConnectionEx($qcServer)

$tdc.Login($qcUser, $qcPassword)

I got $qcUser from input from gui and it doesn't work - why does it work when I use literals? Do I have to do something with the value coming from GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)

$tdc.Login("USERNAME", "PASSWORD")

Link to comment
Share on other sites

Hi,

Global $tdc = ObjCreate("TDApiOle80.TDConnection")
MsgBox(-1, " ", $qcServer)
$tdc.InitConnectionEx("http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/")
$tdc.Login("joseph.loyzaga", "password1")
Global $aArray [9] ; as you wrote max items 10: 0-9
Global $hgui = GUICreate("Test", 320, 180, -1, -1)
Global $hCombo = GUICtrlCreateCombo ("", 150, 10, 150, 150)

$i = 0
For each $tdc.mDomain in $tdc.QCConnection.VisibleDomains
    $aArray [$i] = $tdc.mDomain
    $i += 1
Next

:-))

Stefan

I get error for loop badly formatted

Link to comment
Share on other sites

I get error for loop badly formatted

looks like stephan is used to VBScript.

Remove the "each" in the For...In.. Statement.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

OK

Got it to move into array!! but now I want to populate the combobox ($hCombo)with $array but it doesn't pls see attached

$i = 0

$j=1

For $wrk in $tdc.VisibleDomains

$aArray [$i] = $wrk

;For $wrk1 in $tdc.VisibleProjects

;$aArray1 [$j] = $wrk1

;$j += 1

;Next

$i += 1

Next

_fillcombo1 ()

;_fillarray ()

GUISetState()

Do

$msg = GUIGetMsg()

Sleep (50)

Until $msg = $GUI_EVENT_CLOSE

Func _fillcombo1 ()

For $x = 1 to UBound ($aArray) - 1 ; depending how your array is created you may need at For $x = 0.

_GUICtrlComboBox_AddString($hCombo, $aArray [$x])

Next

_GUICtrlComboBox_SetCurSel ($hCombo, 0)

EndFunc

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