Jump to content

Assign, Arrays, and Checkboxes


Recommended Posts

I need some help figuring out why Assign doesn't seem to be assigning. The basic premise is to create a selectable list of items read in from a dynamic file and create an addressable variable tagged to each item in the list.

I create a dynamic 2-dimensional array composed of the contents of a file and a counter element that is to be used later as a variable to create a checkbox and keep track of the selected items.

The array creates correctly, yet when it gets to the point of creating the checkboxes, it creates and displays them BUT they aren't really addressable or readable as variables for later processing. I confirmed that using 'is declared'.

Perhaps I'm just approaching this from the wrong direction, so any suggestions are appreciated.

CODE
#include <Array.au3>

#include <WindowsConstants.au3>

#include <array.au3>

;

$tempf = FileOpen("C:\temp\caltemp.txt", 0)

;Representative Data in File is as below

; 101 XXA YYA

; 934 XXB YYB

;1471 XXC YYC

$CalArry = ""

$ActArry = ""

Local $CalArry[1], $ActArry[1][2], $sActive[1]

$nt = 1

$line = FileReadLine($tempf, 0) ;first line activity display

$x = 0

While 1 ;build activity array

$line = FileReadLine($tempf) ;

If @error = -1 Or $line = "" Then ExitLoop

$tp = StringLeft($line, 4)

If StringStripWS(StringIsInt($tp), 1) And $tp <> 0 Then

$tp = StringStripWS($tp, 1)

$tp = StringFormat("%04d", $tp)

EndIf

$x += 1

ReDim $ActArry[$x + 1][2]

$CalStr = $tp & " | " & StringMid($line, 6, 3) & " | " & StringMid($line, 10, 3)

$ActArry[$x][0] = '$chk' & $x

$ActArry[$x][1] = $CalStr

WEnd

;

FileClose($tempf)

_ArrayDisplay($ActArry,"") ;Array is built correctly

GUIDelete("main")

$BoxsizeW = 700

$BoxSizeH = 590

$calx1 = GUICreate("Activity Export", $BoxsizeW, $BoxSizeH, (@DesktopWidth - $BoxsizeW) / 2, (@DesktopHeight - $BoxSizeH) / 2.5, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS)

$w = .07

$h = .07

GUISetFont(11, 600, 1, "arial")

$label1 = GUICtrlCreateLabel("Click to choose items to export", $BoxsizeW * .07, $BoxSizeH * .02, 350, 20)

GUISetFont(10, 500, 4, "courier new bold")

$label1a = GUICtrlCreateLabel(" Trip | Cat | Asg ", $BoxsizeW * .053, $BoxSizeH * .07, 650, 20)

GUISetFont(10, 500, 1, "courier new bold")

For $x = 1 To UBound($ActArry) - 1

$h = $h + 0.035

$sAct = $ActArry[$x][0]

Assign($sAct, GUICtrlCreateCheckbox($ActArry[$x][1], $BoxsizeW * .05, $BoxSizeH * $h, 650, 20), 2)

Next

$button1 = GUICtrlCreateButton("Export Selected Items", $BoxsizeW * .583, $BoxSizeH * .02, 200, 20)

GUISetState(@SW_SHOW)

While 1

$msgA = GUIGetMsg()

Select

Case $msgA = $GUI_EVENT_CLOSE

GUIDelete("Activity")

Exit

Case $msgA = $button1

For $x = 1 To UBound($ActArry) - 1

$sAct = $ActArry[$x][0]

$boxval = GUICtrlRead($sAct)

MsgBox(0, "", $boxval) ;Assign doesn't appear to yield a readable variable

Next

GUIDelete("Activity")

Exit

EndSelect

WEnd

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