Jump to content

Array & with Headers and Content


Recommended Posts

Hello to all in the AutoIT Community. First and foremost, I have love how active the moderators are and how interactive they are with the community. AutoIT and its community is by far the most "complete" language/community I've found though my travels of ineptly playing around with programming.

With that being said, I've spent the last two or three months playing around with AutoIT making various programs and updating various scripts as I find new and interesting snippets to play around with. And thus far I have been able to frankenstein a program together that performs as intended but is very "primitive" as far as the script is concern. So what I am attempting to do now is polish the script and make it more efficient and easier to edit without having to modify the code itself. About 90% of the code is Labels and ComboBoxes.

So my question is, how do I create an array to pull headers and keys from an ini file and correctly turn them into labels.

A little about my idea...

<AutoIt>
GUI ()
Func GUI ()
   GUI = GUICreate ("My Sample GUI", 500, 400)

   $Button1 = GUICtrlCreateButton ("Exit", 100, 200, 115, 30)

GUISetState(@SW_SHOW)

   While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
            Exit
      EndSwitch
   WEnd
EndFunc
; ==============================================================================;

[Header 1]         ;<== X, Y will be controlled through predefined coords in the script itself
Question 1        ;<== Header1 x, y + 30
Question 2        ;<== Header1 x, y + 60
Question 3        ;<== Header1 x, y + 90
Question 4        ;<== Header1 x, y + 120
Question 5        ;<== Header1 x, y + 150

[Header 2]
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6
Question 7

[Header 3]
Question 1
Question 2
Question 3
</AutoIT>

And just to exonerate myself, I have spent days searching the forums looking for arrays and labels and tried all sorts of different search terms and I been unable to find an example for what I want to do. I've stared blankly at the ini help files in the tutorial section and it's all greek to me. The best way for me to learn to find something that works and tinker around with it so I understand what does what. I appreciate all that view this form and post constructive feedback! 

Link to comment
Share on other sites

give us a small example .ini

and a small picture of what you want the resulting array to look like.

No accompanying text necessary, just a sample valid source and expected result.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <GUIScrollbars_Ex.au3>


GUI()
Func GUI()
   Local $X1 = 10
   Local $X2 = 700
   Local $Y1 = 325
   Local $Y2 = 525
   Local $Y3 = 775
   Local $Y4 = 945
   Local $Y5 = 1085
   Local $Y6 = 1195
   Local $Y7 = 1365
   Local $Y8 = 1475
; ==============================================================================;
   $GUI = GUICreate ("GUI", 950, 975)
   _GUIScrollbars_Generate($GUI, 949, 1680)
; ==============================================================================;
   $Button1 = GUICtrlCreateButton ("Exit", 400, 900, 115, 30)
; ==============================================================================;
   GUICtrlCreateLabel ("Header",  $X1, $Y1)
   GUICtrlCreateLabel ("Question 1", $X1, $Y1 + 30)
   GUICtrlCreateLabel ("Question 2", $X1, $Y1 + 60)
   GUICtrlCreateLabel ("Question 3", $X1, $Y1 + 90)
   GUICtrlCreateLabel ("Question 4", $X1, $Y1 + 120)
   GUICtrlCreateLabel ("Question 5", $X1, $Y1 + 150)

   GUICtrlCreateLabel ("Header",  $X1, $Y2)
   GUICtrlCreateLabel ("Question 1", $X1, $Y2 + 30)
   GUICtrlCreateLabel ("Question 2", $X1, $Y2 + 60)
   GUICtrlCreateLabel ("Question 3", $X1, $Y2 + 90)
   GUICtrlCreateLabel ("Question 4", $X1, $Y2 + 120)
   GUICtrlCreateLabel ("Question 5", $X1, $Y2 + 150)
   GUICtrlCreateLabel ("Question 6", $X1, $Y2 + 120)
   GUICtrlCreateLabel ("Question 7", $X1, $Y2 + 150)

    GUISetState(@SW_SHOW)

   While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
            Exit
      EndSwitch
   WEnd
EndFunc

 

Link to comment
Share on other sites

I've managed to piece together a semi-functioning idea.. however,  there is one glaring issue. Perhaps someone can tell me where this went wrong. I've been working all day on this. 

 

#include <GUIConstantsEx.au3>
#include <GUIScrollbars_Ex.au3>
#include <Array.au3>

Root ()
Func Root ()
   $GUI_ROOT = GUICreate("AQS v 1.1", 475, 20, @DesktopWidth - 1200, 5)
; ============================================================================== ;
   Global $RPos = WinGetPos($GUI_ROOT)
; ============================================================================== ;
   $Menu_IBT = GUICtrlCreateMenu        ("IB Tools")
      $Button1 = GUICtrlCreateMenuItem  ("&Genesys", $Menu_IBT)

   GUISetState(@SW_SHOW)

   While 1
       Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
               Exit
            Case $Button1
               GUI ()
      EndSwitch
   WEnd
EndFunc

GUI()
Func GUI()
; ============================================================================== ;
   Dim $Labels[26]
; ============================================================================== ;
   $GUI = GUICreate ("Function Test", 950, 975, $RPos[0], $RPos[1] + 50, $WS_POPUP+$WS_THICKFRAME)
; ============================================================================== ;
   Local $TEST_DIRECTORY = @ScriptDir & "\Config\TEST.ini"
; ============================================================================== ;
   Local $TEST_HEADERS1 = IniReadSection($TEST_DIRECTORY, "Header1")
; ============================================================================== ;
   Local $TEST1_STRING_RESULTS  = ""
; ============================================================================== ;
    For $a = 1 To $TEST_HEADERS1[0][0]
        $TEST1_STRING_RESULTS &= $TEST_HEADERS1[$a][1] & "|"
    Next
; ============================================================================== ;
    $TEST1_STRING_RESULTS = StringTrimRight($TEST1_STRING_RESULTS, 1)
; ============================================================================== ;
   Local $X1 = 10
   Local $Y1 = 325
   Local $Y2 = 525
   Local $Y3 = 755
   Local $Y4 = 925
   Local $Y5 = 1065
   Local $Y6 = 1175
   Local $Y7 = 1345
   Local $Y8 = 1455
; ============================================================================== ;
   $Button1 = GUICtrlCreateButton ("Exit", 425, 925, 125, 25)
; ============================================================================== ;
   For $N = 0 To 25
   $LABELS[$N] = GUICtrlCreateLabel($TEST1_STRING_RESULTS, $X1, $Y1)
   Next
; ============================================================================== ;
   GUISetState(@SW_SHOW)

   While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
            Exit
      EndSwitch
   WEnd
EndFunc

All of the labels are created next to each other as shown in the photo. This is certainly not the desired results. I prefer them to be on their own separate lines.

I've also included the INI used to pull the info from if it helps. Good night and thanks for any help.

GUI.jpg

TEST.ini

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