Jump to content

need help with GUI---> $ var (+)


 Share

Recommended Posts

hi,

I have the following code:

#include <string.au3>
#include <File.au3>
#include <Array.au3>
Local $r, $u1
Global $e
Dim $myArray[1120]
Dim $yuArray[1120]

$i = "erez"
$s = "1"
$erez = "c:\erez.txt"
_FileReadToArray($erez, $myArray)
_ArrayDisplay($myArray)

For $o = 1 To 10
    $e = _ArraySearch($myArray, $i & $s, 0, 0, 1, True)
    If $e > -1 Then
        $u1 = FileReadLine($erez, $e)
        $infou1 = StringSplit($u1, "=")
        $u1 = $infou1[2]
        Call("levi", $u1, $e)
    Else
        Call("levi", $u1 = "")
    EndIf
    $s = $s + 1
Next

Func levi($m1, $y)
    _ArrayInsert($yuArray, $y, $m1)
EndFunc ;==>levi
_ArrayDisplay($yuArray)
$gui2 = GUICreate("9620 - PhoneMain", 240, 320, 200, 130)
GUISetIcon("c:\ring.ico")
Opt("GUICoordMode", 1)
GUICtrlCreateLabel("please insert new lables then press change", 10, 10)
$p=60
For $o = 1 To 10
    GUICtrlCreateInput($yuArray[$o], 30, $p, 80, 20)            ; line of question
Next
;MsgBox (0,"$o=",$o)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Is there a way to put GUICtrlCreateInput inside a variable that keeps growinng? like $s=$s+1? the scipt don't let me to do that.

I need the FOR proc to do that:

$Q1=GUICtrlCreateInput($yuArray[$o], 30, $p, 80, 20)

$Q2=GUICtrlCreateInput($yuArray[$o], 30, $p, 80, 20)

....

till the $o=10. how can I put the $Q there with the 1,2,3... I tried this: $Q&$o=GUICtrlCreateInput($yuArray[$o], 30, $p, 80, 20)

but it does not let me....help.........

hi me again:

tried this also:

Dim $array5[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

then,

For $o = 1 To 10

$array5[$o] = GUICtrlCreateInput($yuArray[$o], 30, $p, 80, 20)

Next

and didn't work as well.

Edited by erezlevi
Link to comment
Share on other sites

Not sure this is what you are asking, but in your version all the inputs wind up stacked on top of each other. You need to increment the y coordinates of the controls:

; Make an array for demo
Global $yuArray[11]
For $n = 0 To UBound($yuArray) - 1
    $yuArray[$n] = $n
Next

; Make GUI
$gui2 = GUICreate("9620 - PhoneMain", 240, 320, 200, 130)
GUICtrlCreateLabel("please insert new lables then press change", 10, 10)
$p = 30
For $o = 1 To 10
    GUICtrlCreateInput($yuArray[$o], 30, $p + (($o - 1) * 30), 80, 20) ; line of question
Next

; Show GUI
GUISetState()
Do
    Sleep(20)
Until GUIGetMsg() = -3

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Not sure this is what you are asking, but in your version all the inputs wind up stacked on top of each other. You need to increment the y coordinates of the controls:

; Make an array for demo
Global $yuArray[11]
For $n = 0 To UBound($yuArray) - 1
    $yuArray[$n] = $n
Next

; Make GUI
$gui2 = GUICreate("9620 - PhoneMain", 240, 320, 200, 130)
GUICtrlCreateLabel("please insert new lables then press change", 10, 10)
$p = 30
For $o = 1 To 10
    GUICtrlCreateInput($yuArray[$o], 30, $p + (($o - 1) * 30), 80, 20) ; line of question
Next

; Show GUI
GUISetState()
Do
    Sleep(20)
Until GUIGetMsg() = -3

:D

hi, first thanks for answering me.

that's not my problem but you are right I'v fixed that after submitting the question. The problem is that I can't get the control of the "GUICtrlCreateInput" into a variable that keeps increment itself so when called upon using GuictrlRead I will have smaller number of lines of code. I am looking for a solution not to do that:

$q1 = GUICtrlCreateInput($u1, 60, 60, 70, 15)

$q2 = GUICtrlCreateInput($u2, 60, 80, 70, 15)

$q3 = GUICtrlCreateInput($u3, 60, 100, 70, 15)

$q4 = GUICtrlCreateInput($u4, 60, 120, 70, 15)

$q5 = GUICtrlCreateInput($u5, 60, 140, 70, 15)

$q6 = GUICtrlCreateInput($u6, 60, 160, 70, 15)

$q7 = GUICtrlCreateInput($u7, 60, 180, 70, 15)

$q8 = GUICtrlCreateInput($u8, 60, 200, 70, 15)

$q9 = GUICtrlCreateInput($u9, 60, 220, 70, 15)

$q10 = GUICtrlCreateInput($u10, 60, 240, 70, 15)

$q11 = GUICtrlCreateInput($u11, 60, 260, 70, 15)

$q12 = GUICtrlCreateInput($u12, 60, 280, 70, 15)

I want one line so $q1... will keep growing using the FOR function too.

Link to comment
Share on other sites

hi,

I will try to ask it more simply:

how can I make a loop doing this:

$u1=guictrlread ($p1)
$u2=guictrlread ($p2)
$u3=guictrlread ($p3)
.
.
.

for both varibles $u and $p ? for $p I can with defining a second one: $m and increment it by 1 if doing it under "For" statment. but how to do it for $u?

Thanks,

Link to comment
Share on other sites

Just keep the control IDs in an array. Here I just reuse the same array, but it could be a different one:

; Make an array for demo, has intitial text at first, then stores control IDs
Global $yuArray[11] = [10] ; [0] = count
For $n = 1 To $yuArray[0]
    $yuArray[$n] = $n ; Set initial text = box number
Next

; Make GUI
$gui2 = GUICreate("9620 - PhoneMain", 240, 370, 200, 130)
GUICtrlCreateLabel("please insert new lables then press change", 10, 10)
$p = 30
For $o = 1 To $yuArray[0]
    $yuArray[$o] = GUICtrlCreateInput($yuArray[$o], 30, $p + (($o - 1) * 30), 80, 20) ; line of question
Next
$ButtonId = GUICtrlCreateButton("OK", 70, 330, 100, 30)

; Show GUI
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $ButtonId
            _ReadAllInputs()
    EndSwitch
WEnd

Func _ReadAllInputs()
    Local $sMsg = "Input text:" & @CRLF
    For $n = 1 To $yuArray[0]
        $sMsg &= $n & ":  " & GUICtrlRead($yuArray[$n]) & @CRLF
    Next
    MsgBox(64, "Inputs", $sMsg)
EndFunc

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Developers

No need to create a new thread with the same question ... stick to the original thread.

This is a piece of code from SciTEConfig which creates multiple rows of controls.Just Dim the array before the loop and do something like:

For $x = 1 To 16
    $H_Syn_Label[$x] = GUICtrlCreateLabel($Syn_Label[$x], $BaseX + 5, $BaseY + 20 * $x, 150, 20)
    $H_Syn_Bold[$x] = GUICtrlCreateCheckbox("", $BaseX + 170, $BaseY + 20 * $x, 20, 20)
    $H_Syn_Italic[$x] = GUICtrlCreateCheckbox("", $BaseX + 195, $BaseY + 20 * $x, 20, 20)
    $H_Syn_Underline[$x] = GUICtrlCreateCheckbox("", $BaseX + 220, $BaseY + 20 * $x, 20, 20)
    $H_Syn_fColor[$x] = GUICtrlCreateButton("Fore", $BaseX + 245, $BaseY + 20 * $x, 40, 20)
    $H_Syn_bColor_Standard[$x] = GUICtrlCreateCheckbox("", $BaseX + 295, $BaseY + 20 * $x, 20, 20)
    $H_Syn_bColor[$x] = GUICtrlCreateButton("Back", $BaseX + 320, $BaseY + 20 * $x, 40, 20)
Next
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Just keep the control IDs in an array. Here I just reuse the same array, but it could be a different one:

; Make an array for demo, has intitial text at first, then stores control IDs
Global $yuArray[11] = [10] ; [0] = count
For $n = 1 To $yuArray[0]
    $yuArray[$n] = $n ; Set initial text = box number
Next

; Make GUI
$gui2 = GUICreate("9620 - PhoneMain", 240, 370, 200, 130)
GUICtrlCreateLabel("please insert new lables then press change", 10, 10)
$p = 30
For $o = 1 To $yuArray[0]
    $yuArray[$o] = GUICtrlCreateInput($yuArray[$o], 30, $p + (($o - 1) * 30), 80, 20) ; line of question
Next
$ButtonId = GUICtrlCreateButton("OK", 70, 330, 100, 30)

; Show GUI
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $ButtonId
            _ReadAllInputs()
    EndSwitch
WEnd

Func _ReadAllInputs()
    Local $sMsg = "Input text:" & @CRLF
    For $n = 1 To $yuArray[0]
        $sMsg &= $n & ":  " & GUICtrlRead($yuArray[$n]) & @CRLF
    Next
    MsgBox(64, "Inputs", $sMsg)
EndFunc

:D

Thanks, it is working now....
Link to comment
Share on other sites

You mean erezlevi has been cheating on me in another topic behind my back... WITH ONE OF THE DEVs!!!

I'm crushed... ;)

No, I'm mad... :D

No, I'm still better looking than Jos, so I'm just over it... :P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I merged the 2 topics .... now please stick to this one.

Thanks, sorry, I got it working. so it must be wrriten this way : $q[$s] that what I was looking for. but I couldn't initialize it using Dim $G[10] only using:

global $G[11] = [10]

for $n=1 to $G[0]

$G[$n]=$n

Next

why? does an Array must be filed with values before using it?

Thanks JOS. :D

Link to comment
Share on other sites

You mean erezlevi has been cheating on me in another topic behind my back... WITH ONE OF THE DEVs!!!

I'm crushed... ;)

No, I'm mad... :D

No, I'm still better looking than Jos, so I'm just over it... :P

I am so sorry, didn't ment for it to sound like it did. just that I though no one understand what I wanted in the begining.... forgive me?

Link to comment
Share on other sites

I am so sorry, didn't ment for it to sound like it did. just that I though no one understand what I wanted in the begining.... forgive me?

ok, got it working finally as I wanted here is the example.

Thanks for JOS and PsaltyDS.

#include <Array.au3>

;$i=
Dim $s[10]
Dim $G[11]
Dim $K[11] = [0,11,12,13,14,15,16,17,18,19,20]
;_ArrayDisplay ($s)
$p=30
GUICreate("IP phone selection", 250, 300, 0, 0)
GUISetIcon("c:\ring.ico")
Opt("GUICoordMode", 1)
for $o=1 to 10
    $G[$o]=GUICtrlCreateInput ($K[$o],30,$p,70,15)
    
    $p=$p+20
Next

GUISetState()
Do
    Sleep(20)
Until GUIGetMsg() = -3
Link to comment
Share on other sites

  • Developers

No, I'm still better looking than Jos, so I'm just over it... :P

Don't mind when an ugly penguin say that :D

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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