Jump to content

How Set Size of 2D Variable ??


Recommended Posts

I can't imagine how to set the size of a variable. To make sure I never exceed it, I should set 9999999999999 ??

 

#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>
#include <GUIListView.au3>
HotKeySet("{F2}", "_xxx")

$GUI = GUICreate("gui", 670, 500)
GUISetState()
$ListView = GUICtrlCreateListView("Name|No Name|Surrname|Next Name|U cant do it name", 10, 200, 450, 250,$LVS_SHOWSELALWAYS)
$LV = GUICtrlGetHandle($ListView)
$q = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    Sleep(10)
WEnd

Func _xxx()
    HotKeySet("{F2}")
    Local $asdf[1000]
    $var2 = _GUICtrlListView_GetSelectedIndices($LV)
    $asdf[$q] = _GUICtrlListView_InsertItem($LV,"Name "& $q, $var2 + 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "IS", 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "THIS", 2)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "WROKING", 3)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "RIGHT", 4)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q], True)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q] - 1, False)
    $q = $q + 1
    HotKeySet("{F2}", "_xxx")
EndFunc

also what can be said about my new method of putting the item in any chosen place without any delay.
script result based on trial and error
how to set item to always be visible??

Link to comment
Share on other sites

  • Moderators

Verssuss,

If you look at the Recursion tutorial in the Wiki and scroll down to the "A little added extra" section at the end you will see a good way of getting an array to expand dynamically to fit any size of data.

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

so i set Global $asdf[16777216] is this any problem with anything now or later ??

i also fixed function a bit and every day it is better :P (i think)

If _GUICtrlListView_GetItemCount($LV) = 1 Then _GUICtrlListView_ClickItem($LV,0) :] just to insert first one

Func _xxx()
    
    HotKeySet("{F2}")
    $var2 = _GUICtrlListView_GetSelectedIndices($LV)
    $asdf[$q] = _GUICtrlListView_InsertItem($LV, "Name "& $q, $var2 + 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "IS", 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "THIS", 2)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "WROKING", 3)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "RIGHT", 4)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q], True)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q] - 1, False)
    _GUICtrlListView_EnsureVisible($LV, $q)
    If _GUICtrlListView_GetItemCount($LV) = 1 Then _GUICtrlListView_ClickItem($LV,0)
    $q = $q + 1
    HotKeySet("{F2}", "_xxx")
EndFunc

 

Edited by Verssuss
Link to comment
Share on other sites

  • Moderators

Verssuss,

I have just pointed you at some code which means you do not have to set any form of limit and can keep your variables at a sensible size and so save memory. Why not use it?

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

coz i dont know how use it right or it is really needed
i never before use redim but i know it is needed and its slowdown program ??

 

Func _xxx()
;~  HotKeySet("{F2}")
    If @extended Then
    $asdf[0] += 1
    If UBound($asdf) <= $asdf[0] Then ReDim $asdf[UBound($asdf) * 2]
    EndIf
    $var2 = _GUICtrlListView_GetSelectedIndices($LV)
    $asdf[$q] = _GUICtrlListView_InsertItem($LV, "Name " & $q, $var2 + 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "IS", 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "THIS", 2)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "WROKING", 3)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "RIGHT", 4)
    _GUICtrlListView_SetItemSelected($LV, $asdf[$q], True)
    _GUICtrlListView_SetItemSelected($LV, $asdf[$q] - 1, False)
    _GUICtrlListView_EnsureVisible($LV, $q)
    If _GUICtrlListView_GetItemCount($LV) = 1 Then _GUICtrlListView_ClickItem($LV, 0)
    $q = $q + 1
;~  HotKeySet("{F2}", "_xxx")
EndFunc   ;==>_xxx

anyway it dont work yet :P

Edited by Verssuss
Link to comment
Share on other sites

  • Moderators

Verssuss,

Here you go:

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <Array.au3> ; Just for the demonstration

HotKeySet("{F2}", "_xxx")

Global $asdf[3] ; Set a ridiculously low size - normally I would use at least 100
$q = 0

$GUI = GUICreate("gui", 670, 500)

$ListView = GUICtrlCreateListView("Name|No Name|Surrname|Next Name|U cant do it name", 10, 200, 450, 250,$LVS_SHOWSELALWAYS)
$LV = GUICtrlGetHandle($ListView)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    ; Sleep(10) ; Not needed - there is an automatic Sleep in GUIGetMsg
WEnd

Func _xxx()
    HotKeySet("{F2}")

    $var2 = _GUICtrlListView_GetSelectedIndices($LV)
    $asdf[$q] = _GUICtrlListView_InsertItem($LV,"Name "& $q, $var2 + 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "IS", 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "THIS", 2)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "WROKING", 3)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "RIGHT", 4)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q], True)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q] - 1, False)
    $q = $q + 1
    ; Check if array needs resizing
    If $q = UBound($asdf) Then
        ReDim $asdf[$q * 2]
        ; Just to show you what is happening
        _ArrayDisplay($asdf, "", Default, 8)
    EndIf

    HotKeySet("{F2}", "_xxx")
EndFunc

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

thanks

 

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <Array.au3> ; Just for the demonstration

HotKeySet("{F2}", "_xxx")

Global $asdf[10] ; Set a ridiculously low size - normally I would use at least 100
$q = 0

$GUI = GUICreate("gui", 670, 500)

$ListView = GUICtrlCreateListView("Name|No Name|Surrname|Next Name|U cant do it name", 10, 200, 450, 250,$LVS_SHOWSELALWAYS)
$LV = GUICtrlGetHandle($ListView)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If $q = UBound($asdf) Then
        ReDim  $asdf[$q +100]
        _ArrayDisplay($asdf, "", Default, 8)
    EndIf
    WEnd

Func _xxx()
    HotKeySet("{F2}")
    $var2 = _GUICtrlListView_GetSelectedIndices($LV)
    $asdf[$q] = _GUICtrlListView_InsertItem($LV,"Name "& $q, $var2 + 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "IS", 1)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "THIS", 2)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "WROKING", 3)
    _GUICtrlListView_AddSubItem($LV, $asdf[$q], "RIGHT", 4)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q], True)
    _GUICtrlListView_setItemSelected($LV, $asdf[$q] - 1, False)
    $q = $q + 1
    HotKeySet("{F2}", "_xxx")
EndFunc

 

Link to comment
Share on other sites

  • Moderators

Verssuss,

If you are concerned about performance - which your question about ReDim suggests you are - why have you moved the size check into the idle loop from the function? Now you are carrying out an If statement every few milliseconds rather then just once when you need it. I put the that check where I did for a reason.

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

well. that stupid but i realy knew it.I gonna look for a way to insert this function from outside the xxx function also outside from main loop.

just tested it is any working for now
be sure m23 this wont be in main loop in later
 

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