Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Recommended Posts

Posted

I have a list and I want to separate it into chunks of, let's say, five values each, and then present it in colums.

I think the way goes through the while function in which I'm not very good...

I can make the chunks, and in another while emulate the final result I want to accomplish, but I can't connect the dots...

Any advise?

0.jpg

1.jpg

Posted

So is that the final result you're looking for, shown at the bottom of the picture*? Does the order (down-first) matter? Or could it be across-first? 

Also, wouldn't a portal (or, if you prefer, portals) be a better tool to present this data?

--
P.S. Please post your code as code, not as picture, so that we can copy it and work on it.

Posted

I'm sorry about the code. I thouhgt it was going to be too long.

While (
    [
        ls = List ( 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 12 )
    ;     vc = ValueCount ( ls )
    ;     chunk = 5
    ;     counter = -2
    ;     result = ""
    ]
;
    counter < vc
;
    [
        counter = counter + 3
    ;     result = result &  MiddleValues ( ls ; counter ; chunk ) & ¶
    ;     counter = counter + 2
    ]
;
    result
)

The second while...
 

While (
    [
        ls1 = List ( 1 ; 2 ; 3 ; 4 ; 5 )
    ;    ls2 = List ( 6 ; 7 ; 8 ; 9 ; 10 )
    ;     ls3 = List ( 11 ; 12 )
    ;     counter = 0
    ;     qty = 5
    ;     result = ""
    ]
;
    counter < qty
;
    [
        counter = counter + 1
    ;     result = result & GetValue ( ls1 ; counter ) & "    "& GetValue ( ls2 ; counter ) & "    "& GetValue ( ls3 ; counter ) & ¶

    ]
;
    result
)

I hope this is a better way.

And yes, the final result is the one shown at the bottom of the last picture.

It is the result of test exams. Sometimes are 10 or 20 questions and some others are 100 questions, so I'd like to present it in columns of 5, 10... or so values.

Example:

1. a)
2. c)
3. c)
4. a)
5. b)
6. b)
7. a)
8. a)
9. b)
10. b)
11. b)
12. a)...

Result to accomplish:

1. a)   6. b)   11. b)
2. c)   7. a)   12. a)
3. c)   8. a)  
4. a)   9. b)  
5. b)   10. b) 

Ten or fifteen values are easy to show, but one hundred not that much (ten columns of ten values is best).

Posted

You haven't answered the most important question:

59 minutes ago, comment said:

Does the order (down-first) matter? Or could it be across-first? 

Before you do, consider that even in a text field the number of displayed columns cannot be arbitrary. You cannot scroll a field in the horizontal direction, and you must prepare enough tab stops in advance in order to accommodate the maximum expected number of columns.

OTOH, producing the table in across-first order is relatively simple and you can show as many rows as necessary by making the field tall enough and/or scrolling.

 

Posted

I'm sorry but I don't understand the expressions (down-first, across-first). English is not my native language.

Could this be what they mean?

1     4

2     5

3     6

or

1     2

3     4

5     6

If this is what it means, I thought it was already answered with the example. If not, the first example shown is what I try to accomplish.

Posted (edited)

I am still confused regarding your specification. You started by saying:

2 hours ago, Enigma20xx said:

I want to separate it into chunks of, let's say, five values each, and then present it in colums.

To me that means you will always want to have 5 rows, and as many columns as it takes. 

The problem with this is that a table must be written row-by-row. You cannot fill out a column first, then move to the next column, and so on. So in order to display the values down-first, you need to write them in different order than they appear in the given list. And - as I said - the number of columns will be determined dynamically. What you have done in your 2nd calculation is cheating: you have hard-coded 3 values in each row - but there could be only 2 (if you have 6 to 10 values) or as many as 20 (if you have 100 values). To do this correctly, you would have to use another While() function to generate a row. This is much more complicated than across-first, where the number of columns is fixed, and the number of rows is determined dynamically.

And that's in addition to the display issue I mentioned earlier.

 

 

Edited by comment
  • Like 1
Posted

I am curious where the list comes from, Enigma.  You self-rate yourself as Novice and without knowing your setup and purpose, it is possible there are far simpler ways of achieving what you wish.  Are the list items records?  What do you plan to do with the columns once generated?

We are missing the bigger picture here which I believe potentially complicates your request.  Can you create a simple file showing your structure and then explain where the list comes from and what you wish to do with the resulting columns?  A user won't be able to click on a column entry and do anything (easily) but if the 'list' is (or can be) records then it is far simpler as Comment mentioned originally.

Comment is the best assistance you can get but context is king. 😃

Posted
2 hours ago, LaRetta said:

You self-rate yourself as Novice

I simply forgot about the profile, and don't even know if intermediate fits ok to my knowledge (I have updated it).

2 hours ago, LaRetta said:

Comment is the best assistance you can get but context is king.

I know, many of you have helped me many times, most of those times, Comment. I understand the importance of context. Excuse me if I didn't express myself better before.

The example is a solution for exams. As I create the related records, questions and answers, I also set the correct answer and using a while function the list of questions and its correct answer get populated automatically.

Not only for viewing purposes but also for printing is not easy to work with a such long list.

I hope the sample file sheds some light.

Exámenes - copia.fmp12

Posted
12 minutes ago, Enigma20xx said:

Not only for viewing purposes but also for printing is not easy to work with a such long list.

If your values are records, then at least for printing Filemaker provides a built-in solution:

 

image.png.8d4dd83754e899b315359be49c3d6393.png

But do note that even with "Down first" selected, you need to specify the number of columns, not the number of rows. Filemaker will add as many rows as required (spilling to additional pages, if necessary). It will not produce columns dynamically. That's a general rule that applies to list views, table views, portals and practically everything (except a web viewer).

Speaking of web viewers, make this would be a better tool for viewing?

 

 

Posted

I understand now the mystery about down-first/across-first. As you can see, in spanish is translated as left-right/up-down, that's why I couldn't make the connection.

0.thumb.png.1c940efe431107686ecaa1ca18ed29ff.png

 

10 hours ago, comment said:

If your values are records, then at least for printing Filemaker provides a built-in solution:

The data is just a list, not records.

For printing purpouses, maybe I could use a global table to transform the list into records and have a few different printing layouts (2 columns, 3..., 5...). Across-first balances the columns...

1.thumb.png.21b999f73e0f06f078b3e575c4866a29.png

I'm trying to keep the solution as much simple as possible, so I'm not planning to use web viewer.

I'll keep researching and working on it. If I achieve something that works, unless for me, I will post it.

As always, I very much appreciate your help.

I missed that the type of paper selected in the printer is key.

  • Plus1 1
Posted

If you do want to use a text field for this, maybe something like the attached demo could work for you. However, you need to be careful not to exceed the width of the field - otherwise the display will be mangled.

I would also like to point out again that the calculation could be significantly simpler if the order were across-first.

 

ListToArray_DownFirst.fmp12

  • Thanks 1
Posted

Sorry I've been desconnected these holidays.

On 12/28/2023 at 1:11 AM, LaRetta said:

Wow.  This is incredible! :shocked: Thank you for sharing it with us, Michael!!

comment is the rosetta stone of Filemaker 😄😄

I really appreciate how much he has help me many times.

I have dared to make a small change in comment's file.

ListToArray_DownFirst - mod 1.fmp12

Posted

Wow, I thought I had "invented the wheel", but not 😄😄

I didn't know you had that great custom function.

I'll definitely use it.

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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.