Jump to content
Sign in to follow this  
mistersquirrle

[SOLVED] Using an array for a function that returns the variable as an array...

Recommended Posts

So, I'm using the UDF to create a label that has formatted text, which creates a bunch of smaller labels with the text in different formats in different labels, so it returns the label as an array.

So if you used $Label1 = _GUICtrlCreateTFLabel(blah blah) and had a couple different type of formatted text, it would return $Label1[5] or something. My problem is that I used an array as the variable in the first place, and I don't know how to call the variable of the labels returned in *the* array that the UDF created. When I try what I think, it just crashes.

Sorry if this isn't very clear, I don't really know what the problem is myself.

Here's an example of what I'm talking about, you need the UDF, in the script dir, above for it to run.

#include-once

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "GUICtrlCreateTFLabel.au3"
#include <Array.au3>

Global $Label1[3]

$Form1 = GUICreate("asdf", 617, 441, 192, 124)
$Label1[0] = _GUICtrlCreateTFLabel("LABEL!", 56, 80)
$Label2 = GUICtrlCreateLabel("Try to show a msgbox with $Label1[0][1] as the text... (click this)" & @CRLF & @CRLF & "I just figured that this should be the format ( $label1[0][1]) since $label1[0] has an array attached to it...", 56, 120)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xffffff)
GUISetState(@SW_SHOW)

_ArrayDisplay($Label1, "$Label1 display")
_ArrayDisplay($Label1[0], "$Label1[0] display")

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

        Case $Label2
            MsgBox(0, '', $Label1[0][1])

    EndSwitch
WEnd
Edited by mistersquirrle

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

As far as I understand it, a single dimensional array which holds other dimensional array items is not the same animal as a two dimensional array. I believe that AutoIt does not work the same as Java for instance in this regard. I am certainly no pro at this, but what if you did something like...

Case $Label2
            Local $myLabel[1]
            $myLabel = $label1[0]
            MsgBox(0, '', $myLabel[1])
            ;;MsgBox(0, '', $Label1[0][1])
Edited by Fubarable

Share this post


Link to post
Share on other sites

So you're saying that I can't do what I'm trying, in AutoIt? Why can I then parse the info with _ArrayDisplay() from $Label1[0], and why is it different than the 0 index of $Label[3]


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

mistersquirrle,

I have answered in more detail here in the Examples thread for the UDF as I saw that one first. Basically Fubarable is correct. :)

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

 

Share this post


Link to post
Share on other sites

Yeah, thanks Melba and Fubarable. I didn't see Fubarables edit until a few hours after he posted it so I was to tried to respond and say that that worked.

If a mod wants put [sOLVED] or something, then feel free

Edited by mistersquirrle

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

mistersquirrle,

You can add [sOLVED] yourself if you wish. Just edit the first post and select the "Use Full Editor" option - that allows you to edit the title as well. :)

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

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...