Math problem here.. displaying controls depending on a variable

Recommended Posts

So I have a program I'm creating for my work that will allow us to track the work order of a battery that we are working on. These batteries range from a common size of 6, 12, 18, 24, 36.

So I need a way to create a GUI that I can input data into a InputBox corresponding with each cell the battery has (The Size)

I've been able to pretty much do that but I want a cleaner way of doing it and I know there is one but I can't seem to think of the right sequence to do it in.

So what happens is someone puts in the cell size and then the GUI automatically creates input boxes for each one, so a 36 cell battery will have 36 input boxes. Obviously that's a lot to have one a single GUI so I made it to where I can rotate between Hide/Show sets of 12 to clean it up. Each time you press the "Next Set" button it will cycle to the next 12. Now my problem is when I have an odd number, not divisible by 12. I have it already parsing it to find the divisor I just need a clean way to Hide/Show and cycle between them.

Here is a cut out of the program just thrown into a generic GUI to help since I can't share the whole thing.

```#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

HotKeySet("{ESCAPE}", "_Exit")

Opt("GUIOnEventMode", 1)

Global \$MaxSetOfCells

Dim \$Box[50], \$CellNumberDisplay[50]

Global \$CellCount = 36

GuiCreate("Test Box", 600, 600)

For \$i = 1 To \$CellCount
If \$i = 1 Then
\$Y = 50
\$CellNumberDisplay[\$i] = GUICtrlCreateLabel("Cell #" & \$i, 10, 50)
GUICtrlSetFont(-1, 10)
Else
\$Y += 27
If \$i = 13 Then
\$Y = 50
EndIf
If \$i = 25 Then
\$Y = 50
EndIf
If \$i = 37 Then
\$Y = 50
EndIf
If \$i = 49 Then
\$Y = 50
EndIf
\$CellNumberDisplay[\$i] = GUICtrlCreateLabel("Cell #" & \$i, 10, \$Y)
GUICtrlSetFont(-1, 10)
EndIf
Next

For \$i = 1 To \$CellCount
If \$i = 1 Then
\$Y = 50
\$Box[\$i] = GUICtrlCreateInput("", 100, 50, 80, 20, \$ES_CENTER)
GUICtrlSetFont(-1, 10)
Else
\$Y += 27
If \$i = 13 Then
\$Y = 50
EndIf
If \$i = 25 Then
\$Y = 50
EndIf
If \$i = 37 Then
\$Y = 50
EndIf
If \$i = 49 Then
\$Y = 50
EndIf
\$Box[\$i] = GUICtrlCreateInput("", 100, \$Y, 80, 20, \$ES_CENTER)
GUICtrlSetFont(-1, 10)
EndIf
Next

If \$CellCount > 12 Then
For \$i = 13 To \$CellCount
GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_HIDE)
GUICtrlSetState(\$Box[\$i], \$GUI_HIDE)
Next
EndIf

\$NextButton = GuiCtrlCreateButton("Next Set", 300, 300, 200, 40)
GUICtrlSetOnEvent(-1, "_NextSet")

GuiSetState()

Func _Exit()
Exit
EndFunc

Func _NextSet()
Global \$SubtractCells = \$CellCount
For \$i = 1 To \$CellCount
\$SubtractCells -= 12
If \$SubtractCells >= 0 Then
\$MaxSetOfCells += 1
Else
\$OddNumber = \$SubtractCells * -1
ExitLoop
EndIf
Next

If \$OddNumber = 12 Then
\$OddNumber = 0
EndIf

;;;; Stumped Here

MsgBox(0, "Test", \$MaxSetOfCells & @CRLF & @CRLF & \$OddNumber)
EndFunc

While 1
Sleep(10)
WEnd```

So if you run the program you'll see that you can only see 12 cells but it created 36. Now I can easily cycle through these 36 because their even by using something like

```;~ Func _NextSet()
;~  If \$CellSplitCount[1] = 24 Then
;~      \$MaxSetOfCells = 2
;~      If \$SetOfCells = 1 Then
;~          For \$i = 1 To 12
;~              GUICtrlSetState(\$Volts[\$i], \$GUI_HIDE)
;~              GUICtrlSetState(\$Gravity[\$i], \$GUI_HIDE)
;~              GUICtrlSetState(\$Temp[\$i], \$GUI_HIDE)
;~              GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_HIDE)
;~          Next
;~          For \$i = 13 To 24
;~              GUICtrlSetState(\$Volts[\$i], \$GUI_SHOW)
;~              GUICtrlSetState(\$Gravity[\$i], \$GUI_SHOW)
;~              GUICtrlSetState(\$Temp[\$i], \$GUI_SHOW)
;~              GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_SHOW)
;~          Next
;~      ElseIf \$SetOfCells = 2 Then
;~          For \$i = 13 To 24
;~              GUICtrlSetState(\$Volts[\$i], \$GUI_HIDE)
;~              GUICtrlSetState(\$Gravity[\$i], \$GUI_HIDE)
;~              GUICtrlSetState(\$Temp[\$i], \$GUI_HIDE)
;~              GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_HIDE)
;~          Next
;~          For \$i = 1 To 12
;~              GUICtrlSetState(\$Volts[\$i], \$GUI_SHOW)
;~              GUICtrlSetState(\$Gravity[\$i], \$GUI_SHOW)
;~              GUICtrlSetState(\$Temp[\$i], \$GUI_SHOW)
;~              GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_SHOW)
;~          Next
;~      EndIf
;~  EndIf

;~  If \$SetOfCells = \$MaxSetOfCells Then
;~      \$SetOfCells = 1
;~  Else
;~      \$SetOfCells += 1
;~  EndIf
;~ EndFunc```

That's what I was using in my program to Hide/Show the next set but it only worked for Cell Size of 24, I could bump it up to 36 of course but there will be times like on a 18 Cell battery it will not be divisible by 12. So, instead of creating an IF statement for each cell size and using a huge block like that I wanted to find a way to cleanly do it which I'm sure can be done using some math but... I suck at that.

So yeah, sorry for the long text but I really want to get this done ASAP!

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

Damien,

Have you considered using tabs with each tab representing a cell size?  All controls would then fit.

Kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share on other sites

I did not look at your code, but you might want to create a tab for each set of cells, 12 on first tabl 13 - 24 on second, ect?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace \$ghGDIPDll with \$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share on other sites

I haven't thought of tabs but even if using tabs would I not still need a way to determine how to limit the amount of cells displayed accordingly? I still would only want 12 on the first tab and 6 on the other tab if its a 18 cell battery. But I think the showing all on one gui and using a next button is cleaner and more.. Linear then a tab. One can simply just click next and it will cycle through all the cells.

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

I did not study your code to closely, but I think this is what you are asking.  Instead of using blocks of for loops that are evenly divisible you could use nested for loops and figure out the total number of pages/iterations like this:

```\$cells=37
if mod(\$cells,12)=0 then; is it evenly divisible by 12?
\$pages=\$cells/12
Else
\$pages=Ceiling(\$cells/12); if not evenly then round up or not
EndIf

for \$a=1 to \$pages
for \$b=1 to 12; or make the upper limit something variable - I don't know the requirements
;DO SOMETHING LIKE YOU ALREADY HAVE ...
;   GUICtrlSetState(\$Volts[\$i], \$GUI_HIDE)
;~  GUICtrlSetState(\$Gravity[\$i], \$GUI_HIDE)
;~  GUICtrlSetState(\$Temp[\$i], \$GUI_HIDE)
;~  GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_HIDE)
Next
Next```

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share on other sites

Ok, well maybe find the common denominator on the cells, I think 6 might work, and that should clear your math issue?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace \$ghGDIPDll with \$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share on other sites

Hmm, I've never used Mod or Ceiling. But what I can tell from that it still only gives me a rounded number of pages. I need a way to determine exactly how many cells to display. I never want more than the cell count displayed. Unless I'm mistaken your example, if say Cells is 37 it will display 4 pages full of 12. But I would want 3 pages full of 12 and then one with one just a single cell. Until I hear back I'll test this out and go from there.

Thanks so far for the help

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

Tested ... this should do what you want, check the console ...

```\$cells=39
;ConsoleWrite(@crlf&mod(\$cells,12)&@CRLF)
;ConsoleWrite(@crlf&floor(\$cells/12)&@crlf)

if mod(\$cells,12)=0 then
\$pages=\$cells/12
\$cellsPerPage=12
Else
\$pages=Ceiling(\$cells/12)
EndIf

\$twelvePageCount=0
for \$a=1 to \$pages
ConsoleWrite(@crlf&\$twelvePageCount&@CRLF)
if \$twelvePageCount<floor(\$cells/12) Then
\$cellsPerPage=12
Else
\$cellsPerPage=mod(\$cells,12)
EndIf
ConsoleWrite(@crlf&"This is page number: "&\$a&" and there are: "&\$cellsPerPage&" cells per page on this page"&@CRLF)
for \$b=1 to \$cellsPerPage
ConsoleWrite(@crlf&"testing"&@crlf)
Next

\$twelvePageCount=\$twelvePageCount+1
Next```

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share on other sites

I'm sorry but I've spent the last hour and a half trying to work this out.

I understand that your script gives the page count and the cells per page but I still can't translate that unto showing / hiding controls properly.

I must be being dense or something because its frustrating the hell out of me and I can't seem to wrap my head around it... Sorry

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

Okay, maybe this will get you started ... I made it work for labels only - and you can only go to the next page (not backward yet).  You can easily add inputs and follow the same approach.

```#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
GuiCreate("Test Box", 600, 600)
\$nextBtn = GUICtrlCreateButton("Next", 408, 240, 129, 49)
GUISetState(@SW_SHOW)

\$cells=39
dim \$labelsInUse[12]

if mod(\$cells,12)=0 then
\$pages=\$cells/12
\$cellsPerPage=12
Else
\$pages=Ceiling(\$cells/12)
EndIf
\$twelvePageCount=0

func _setLabels()
_clearLabels()
if \$twelvePageCount<floor(\$cells/12) Then
\$cellsPerPage=12
Else
\$cellsPerPage=mod(\$cells,12)
EndIf
ReDim \$labelsInUse[\$cellsPerPage]
\$y=50; will be used to position top of labels
for \$b=0 to \$cellsPerPage-1; creates some labels vertically 25 px apart
\$labelsInUse[\$b]=GUICtrlCreateLabel("Cell #" & \$b+1, 10, \$y)
\$y+=25;increments spacing of vertical labels
Next
\$twelvePageCount=\$twelvePageCount+1
EndFunc
_setLabels()

func _clearLabels()
for \$startClear=0 to UBound(\$labelsInUse)-1
guictrlsetdata(\$labelsInUse[\$startClear],"")
Next
EndFunc

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

EndSwitch
WEnd```

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share on other sites

Alright, I'll look more closer to this while I await for your reply if you so choose to grace me with it xD

But at first glance it looks as if you're recreating the labels each _setLabels()

Now that would be fine but it also seems like it is only giving me truly 12 unique labels (Or input boxes in my case)

Once all the data is input into the program, so for a 36 cell battery, all 36 cells hold data (Each one can be different from the rest) then I save it into an INI. With the process above I would only be able to save 12 cells of data, not 36 correct? Maybe I'm looking at it wrong, I'll check.

Thanks again!

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

Let me try and illustrate a bit further.. maybe I haven't been clear, I apologize.

First Step = Create GUI and All Input/Labels (All 36 if Cells = 36) at once.

Second Step > Hide 13-36

Third Step > When Next is pressed, it will figure out if I am on range 1-12, 13-24 or 25-36 (But this has to be a variable, with no limit)

Fourth Step > Hide 1-12 Input/Label, Show 13-24 Input/Label

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

Alright, so I made some head way just to show you how I for sure want it to work. And I almost got it, the only problem is after the first cycle through all the pages the last one no longer works.

```#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

HotKeySet("{ESCAPE}", "_Exit")

Opt("GUIOnEventMode", 1)

Global \$MaxSetOfCells, \$CurrentSet = 2

Dim \$Box[50], \$CellNumberDisplay[50]

Global \$CellCount = 36

GUICreate("Test Box", 600, 600)

For \$i = 1 To \$CellCount
If \$i = 1 Then
\$Y = 50
\$CellNumberDisplay[\$i] = GUICtrlCreateLabel("Cell #" & \$i, 10, 50)
GUICtrlSetFont(-1, 10)
Else
\$Y += 27
If \$i = 13 Then
\$Y = 50
EndIf
If \$i = 25 Then
\$Y = 50
EndIf
If \$i = 37 Then
\$Y = 50
EndIf
If \$i = 49 Then
\$Y = 50
EndIf
\$CellNumberDisplay[\$i] = GUICtrlCreateLabel("Cell #" & \$i, 10, \$Y)
GUICtrlSetFont(-1, 10)
EndIf
Next

For \$i = 1 To \$CellCount
If \$i = 1 Then
\$Y = 50
\$Box[\$i] = GUICtrlCreateInput("", 100, 50, 80, 20, \$ES_CENTER)
GUICtrlSetFont(-1, 10)
Else
\$Y += 27
If \$i = 13 Then
\$Y = 50
EndIf
If \$i = 25 Then
\$Y = 50
EndIf
If \$i = 37 Then
\$Y = 50
EndIf
If \$i = 49 Then
\$Y = 50
EndIf
\$Box[\$i] = GUICtrlCreateInput("", 100, \$Y, 80, 20, \$ES_CENTER)
GUICtrlSetFont(-1, 10)
EndIf
Next

If \$CellCount > 12 Then
For \$i = 13 To \$CellCount
GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_HIDE)
GUICtrlSetState(\$Box[\$i], \$GUI_HIDE)
Next
EndIf

\$NextButton = GUICtrlCreateButton("Next Set", 300, 300, 200, 40)
GUICtrlSetOnEvent(-1, "_NextSet")

;~       if mod(\$CellCount , 12) = 0 then
;~     \$pages = \$CellCount / 12
;~     \$cellsPerPage=12
;~ Else
;~     \$pages=Ceiling(\$CellCount/12)
;~ EndIf
\$twelvePageCount = 0

GUISetState()

Func _Exit()
Exit
EndFunc   ;==>_Exit

Func _NextSet()
_clearLabels()
If \$twelvePageCount < Floor(\$CellCount / 12) Then
\$cellsPerPage = 12
Else
\$cellsPerPage = Mod(\$CellCount, 12)
EndIf

If \$CurrentSet = 1 Then
\$Y = 50
For \$b = 1 To \$cellsPerPage
GUICtrlSetState(\$Box[\$b], \$GUI_SHOW)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_SHOW)
\$Y += 25
Next
For \$b = 13 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
\$CurrentSet = 2
ElseIf \$CurrentSet = 2 Then
\$Y = 50
For \$b = 1 To \$cellsPerPage
\$CountCells = 12
GUICtrlSetState(\$Box[\$CountCells + \$b], \$GUI_SHOW)
GUICtrlSetState(\$CellNumberDisplay[\$CountCells + \$b], \$GUI_SHOW)
\$Y += 25
Next
For \$b = 1 To 12
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
For \$b = 25 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
\$CurrentSet = 3
ElseIf \$CurrentSet = 3 Then
\$Y = 50
For \$b = 1 To \$cellsPerPage
\$CountCells = 24
GUICtrlSetState(\$Box[\$CountCells + \$b], \$GUI_SHOW)
GUICtrlSetState(\$CellNumberDisplay[\$CountCells + \$b], \$GUI_SHOW)
\$Y += 25
Next
For \$b = 1 To 24
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
For \$b = 37 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
\$CurrentSet = 1
\$twelvePageCount = 0
EndIf

\$twelvePageCount = \$twelvePageCount + 1

EndFunc   ;==>_NextSet

Func _clearLabels()
For \$startClear = 0 To UBound(\$Box) - 1
GUICtrlSetState(\$Box[\$startClear], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$startClear], \$GUI_HIDE)
Next
EndFunc   ;==>_clearLabels

While 1
Sleep(10)
WEnd```

Now what I am trying to avoid is having to create an ElseIf for each of the cycles since the number of cycles is going to be a variable and ever changing. But its the only way I knew how to show case what I meant.

*** EDIT ***

This problem was fixed with removing

`\$twelvePageCount = \$twelvePageCount + 1`

From the bottom of the IF statemenet

`\$twelvePageCount += 1`

After each ElseIf

Edited by Damein

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

Don't mean to triple post but I'm almost there and I didn't want it to seem like I gave up lol

```_clearLabels()
If \$twelvePageCount < Floor(\$CellCount / 12) Then
\$cellsPerPage = 12
Else
\$cellsPerPage = Mod(\$CellCount, 12)
EndIf

If \$Add12 = 0 Then
For \$b = 1 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
For \$b = 1 To 12
GUICtrlSetState(\$Box[\$b], \$GUI_SHOW)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_SHOW)
Next
Else
If \$Add12 < \$CellCount Then
\$Y = 50
For \$b = 1 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
For \$b = 1 To \$cellsPerPage
GUICtrlSetState(\$Box[\$Add12 + \$b], \$GUI_SHOW)
GUICtrlSetState(\$Add12 + \$CellNumberDisplay[\$b], \$GUI_SHOW)
Next
EndIf
EndIf

If \$Add12 >= \$CellCount Then
\$twelvePageCount = 0
EndIf```

That's what I've gotten it down to. And it works just fine if the number is divisible by 12 so now all I need to work out is how to make it still go to the remainder but hide the rest.

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share on other sites

Alright, I think I've done it.

If there's a simpler way then by all means let me know. But this way seems to work 100%

```#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

HotKeySet("{ESCAPE}", "_Exit")

Opt("GUIOnEventMode", 1)

Global \$MaxSetOfCells, \$CurrentSet = 2, \$Add12 = 12, \$AddToFinal

Dim \$Box[100], \$CellNumberDisplay[100]

Global \$CellCount = 63

GUICreate("Test Box", 600, 600)

For \$i = 1 To \$CellCount
If \$i = 1 Then
\$Y = 50
\$CellNumberDisplay[\$i] = GUICtrlCreateLabel("Cell #" & \$i, 10, 50)
GUICtrlSetFont(-1, 10)
Else
\$Y += 27
If \$i = 13 Then
\$Y = 50
EndIf
If \$i = 25 Then
\$Y = 50
EndIf
If \$i = 37 Then
\$Y = 50
EndIf
If \$i = 49 Then
\$Y = 50
EndIf
\$CellNumberDisplay[\$i] = GUICtrlCreateLabel("Cell #" & \$i, 10, \$Y)
GUICtrlSetFont(-1, 10)
EndIf
Next

For \$i = 1 To \$CellCount
If \$i = 1 Then
\$Y = 50
\$Box[\$i] = GUICtrlCreateInput("", 100, 50, 80, 20, \$ES_CENTER)
GUICtrlSetFont(-1, 10)
Else
\$Y += 27
If \$i = 13 Then
\$Y = 50
EndIf
If \$i = 25 Then
\$Y = 50
EndIf
If \$i = 37 Then
\$Y = 50
EndIf
If \$i = 49 Then
\$Y = 50
EndIf
\$Box[\$i] = GUICtrlCreateInput("", 100, \$Y, 80, 20, \$ES_CENTER)
GUICtrlSetFont(-1, 10)
EndIf
Next

If \$CellCount > 12 Then
For \$i = 13 To \$CellCount
GUICtrlSetState(\$CellNumberDisplay[\$i], \$GUI_HIDE)
GUICtrlSetState(\$Box[\$i], \$GUI_HIDE)
Next
EndIf

\$NextButton = GUICtrlCreateButton("Next Set", 300, 300, 200, 40)
GUICtrlSetOnEvent(-1, "_NextSet")

\$twelvePageCount = 0

GUISetState()

Func _Exit()
Exit
EndFunc   ;==>_Exit

Func _NextSet()
_clearLabels()
If \$twelvePageCount < Floor(\$CellCount / 12) Then
\$cellsPerPage = 12
Else
\$cellsPerPage = Mod(\$CellCount, 12)
EndIf

If \$Add12 = 0 Then
For \$b = 1 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
For \$b = 1 To 12
GUICtrlSetState(\$Box[\$b], \$GUI_SHOW)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_SHOW)
Next
Else
If \$Add12 < \$CellCount Then
\$Y = 50
For \$b = 1 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
For \$b = 1 To \$cellsPerPage
GUICtrlSetState(\$Box[\$Add12 + \$b], \$GUI_SHOW)
GUICtrlSetState(\$Add12 + \$CellNumberDisplay[\$b], \$GUI_SHOW)
Next
EndIf
EndIf

If \$Add12 > \$CellCount Then

\$MaxSetOfCells = \$CellCount - \$Add12 - 12 * -1

\$AddToFinal = \$CellCount - \$MaxSetOfCells

\$Y = 50
For \$b = 1 To \$CellCount
GUICtrlSetState(\$Box[\$b], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$b], \$GUI_HIDE)
Next
For \$b = 1 To \$MaxSetOfCells
GUICtrlSetState(\$Box[\$AddToFinal + \$b], \$GUI_SHOW)
GUICtrlSetState(\$AddToFinal + \$CellNumberDisplay[\$b], \$GUI_SHOW)
Next

EndIf

If \$Add12 >= \$CellCount Then
\$twelvePageCount = 0
EndIf

EndFunc   ;==>_NextSet

Func _clearLabels()
For \$startClear = 0 To UBound(\$Box) - 1
GUICtrlSetState(\$Box[\$startClear], \$GUI_HIDE)
GUICtrlSetState(\$CellNumberDisplay[\$startClear], \$GUI_HIDE)
Next
EndFunc   ;==>_clearLabels

While 1
Sleep(10)
WEnd```

Thanks so much for all the help!

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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