Jump to content

build a array ( unknow lines x know columns ) by itens number


Luigi
 Share

Go to solution Solved by Luigi,

Recommended Posts

Hi Forum, I need check if this code is write...

That is the fun...
You have a number of items, and need display all in an Array...

The line numbers is unknow...

The columns number is determinate...

So.. how determinate the number of lines?

Local $iQuant = 8

Local $aCell[2] = [0, 4] ; number of lines and colunmns

For $ii = 1 To $iQuant
    If Not Mod($ii, $aCell[1]) And $iQuant > $ii Then $aCell[0] += 1
Next

ConsoleWrite("$iLin->" & $aCell[0] & @LF)
ConsoleWrite("$iCol->" & $aCell[1] & @LF)

$iQuant determine the number of itens...

$aCell is the array, it contaim the number of lines and columns, respective to show elements...

See, $aCell[0]  start with 0 lines, but, $aCell[1] have 4 columns...

So, you have a array with 4 columns and 'n' lines...

If I have $iQuant = 3, my $aCell is [0, 4], ok?

If I have $iQuant = 4, my $aCell is [0, 4], ok?

If I have $iQuant = 5, my $aCell is [1, 4], ok?

If I have $iQuant = 8, my $aCell is [1, 4], ok?

If I have $iQuant = 9, my $aCell is [2, 4], ok?

This algorithm to show the number of elments, with pre-determinad number of columns ir write?

Have any bug?

Someone have a better way to build this?

Thanks for any help

Br, Detefon

Edited by Detefon

Visit my repository

Link to comment
Share on other sites

  • Moderators

Where are you pulling your info from, what type of application? With the references to $aCell I'm guessing Excel?

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi JLogan3o13, this is my application, $aCell is random name.
The scope of this is, I have a number of small applications to show for end user, I want show all this info in a gui, with lines and rows.

Each line have a certain number of columns, I call cells.

Each cell is a small aplication, similar windows control panel and your icons...
This algorithm it is to calculate how many lines and columns I need to show a determinate number of applications, to build this grid or something like this.

Visit my repository

Link to comment
Share on other sites

  • Moderators

Detefon,

This little calculation seems to be what you need: :)

For $i = 1 To 25
    $iRows = Floor(($i - 1) / 4) ; How many 4's are there to fit in?
    ConsoleWrite($i & ": [" & $iRows & ", 4]" & @CRLF)
Next
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

  • Solution

I made this little change...
 

Local $iQuant = 5 ; number of apps to show

Local $aCell[2] = [0, 4]
; $aCell[0] is unknow number of lines
; $aCell[1] is know number of columns

$iRows = Floor(($iQuant - 1) / $aCell[1]) ; How many 4's are there to fit in?
ConsoleWrite("[" & $iRows & ", " & $aCell[1] & "]" & @CRLF)

I do not need itereate all elements, I need know how many lines is necessary to show "n" elments in an array with determinate number of columns...

Your code show this in one line, and more easy to understand than mine first code...

Both work fine, your is more easy.

Thank you again.

Br, Detefon

Edited by Detefon

Visit my repository

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