How does one modify groups? - livecode

I have a hopefully easy to solve problem with my program. My program works 99% (haven't tried to break it yet haha) and I'm on to formatting for scaling to multiple platforms etc. There is one small part of my program that is particularly hard to position, however, as I have multiple objects which are not individually always visible. I wrote some example pseudocode for what I want to do, but I was unable to find a lot of helpful syntax to help me fulfill the pseudocode. The pseudocode is as follows (apologies because my pseudocode is probably not formally correct):
FOR each object
IF object required then
Add object to group
ELSE
Hide object
END IF
END FOR
CENTER group
After this I should have a completed minimum viable product for my program, so help is much appreciated. Cheers!

Use the showcommand to show objects and the hidecommand to hide objects. Don't forget to refer to your group: control x of group yor control x of meif the script is in the group itself.
examples:
show field 1 of group "Purple"
hide button "Click Me" of me

A group's rectangle can be a different size than the controls it contains, so I wouldn't bother adding or removing controls, I'd just resize the group itself to fit the visible ones. Then just center the group as needed.
If this is part of the hangman game you're developing, the left of the first visible field will become the left edge of the group and the right of the last visible field will be the right side of the group. The top and bottom remain the same.
Try this, using the correct field names for "firstfield" and "lastfield":
put the rect of grp "foo" into tRect
put the left of field "firstfield" into item 1 of tRect
put the right of field "lastField" into item 3 of tRect
set the rect of grp "foo" to tRect -- resizes group to fit visible controls
-- now center the group along the horizontal axis:
set the loc of grp "foo" to (item 1 of the loc of this cd),item 2 of the loc of grp "foo"

Here's some of the code for your pseudocode. (Note sure I'm capturing the nuances of what you're trying to do.)
repeat with x = 1 to the number of buttons in group "foo"
put the long id of button x of group "foo" into tBtn
if tObjectIsNeeded then
show tBtn
else
hide tBtn
end if
end repeat
# this centers the group horizontally and vertically
set the loc of group "foo" to the loc of this card
You can add an object to a group using the copy command:
copy button "bar" into group "foo"
You can use the delete command to delete a control from a card:
delete button "bar" from group "foo"
If you only want to align the group horizontally, modify its location property. The location property is a comma-separated list of two integers, the first one giving the number of pixels from the left edge of the card, and the second one giving the number of pixels from the top of the card. It would look something like this:
set the itemDelimiter to comma # comma is default, so this line might not be needed
put item 1 of the loc of this card into tXloc
put item 2 of the loc of group "foo" into tYloc
set the loc of group "foo" to tXloc,tYloc

Related

Getting multiple drop down dynamically in JSF

I have a hierarchy of parent child relationship in database and based on those values, I need to add new values. The hierarchy could be different and the drop down needs to be displayed dynamically. E.g. Lets say we have 2 hierarchies: NorthAmerica>USA>California and NorthAmerica>USA>GWA>Seattle. So when I try to add a new Location, if I select NA at first level, USA at second level and California at third level, then the last drop down should be of the locations which are children of California. In other case, if I select NA at first level, USA at second level, GWA at third level, then fourth drop down should show of Seattle and the last drop down should be of the locations which are children of Seattle.
The number of drop downs are shown based on the values present in the database. I doubt that it can be done using ui:repeat but I am not getting the right direction. It would be great if someone could help with any positive pointers.
If you are able to make Map<K,V> map
Where K=String(Id for value) and V= List<SomeObjectClass>
SomeObjectClass=> String id, String Value.
Now Map will looks like Key
Key Value
1 1.1,1.2
2 2.1,2.2
1.1 1.1.1,1.1.2
1.2 1.2.1,1.2.2
2.1 2.1.1,2.1.2
2.2 2.2.1,2.2.2
So if I use key 1.1 I will get list of 1.1.1, 1.1.2
One more List<ID> this will holds your selected value from drop down. And size will tell you how many drop down need to display.
Put “0” at index 0 in list, list should not be empty. Now loop over List and show number of drop down as size of list.
Dropdown value will be come from map.get(K).
UI:repeat over List<ID> var=varlistId (You know how)
Dropdown: value=#{map.get(VarID)} iteamlevel=” somevariable.level” ItemValue=”somevariable.id” var=”somevariable” DropDown END
UI:repeat END
You need to add selected Id From dropdown to list, and remove if user make any change in previous drop down, and remove all element from List.
Example:
At Page load, you list size will be 1 you have add 0 at 0 index of list, now your UI will show one drop down with map vale where you have two element 1,2;
If you select 1 or 2 from drop down, add this in list at index 1 as add method will add at last.
Now you have to drop down in UI repeat, first drop down will how 1,2 and second drop down will show 2.1,2.2,
Now if you have ten drop down and user change value in 5th drop down, now you need to loop over list and need to remove element from 6th so you list have 6 value and you UI will show only 6 drop down.
Give your suggestion below
Edited:
We can replace the map by some method which will give the next value for drop down. As suggest by #Kukeltje.

Bar chart with Trellis--How to remove categories that are filtered?

The question is regarding the top bar chart.
I used Trellis tab in Properties to divide among AL and NL. As you can see, the values of the team that belong to the other league were filtered, and yet there still is an empty space allotted for the filtered columns. How to I remove the filtered columns, and display only the categories that are relevant?
So basically I do not want any empty spaces for each AL and NL chart.
Thank you
This is how Trellis works. If you want them completely separated create two separate bar charts and limit the data using expressions, or apply a custom filtering scheme. The first option is the simplest and is my preferred method.
Right Click > Properties > Data > Limit Data Using Expressions > Edit
Expression: [leagueColumn] = 'AL' or if you want to be explicit, yet have the same effect, if([leagueColumn] = 'AL', TRUE, FALSE)
Do this for the other chart, using NL as well.

Graphing nr of threads in WPA

I want to graph the number of threads in a process, have found the
ThreadID coloumn and set the Unique Count aggregation which is what I want to see over time. I have this field alone to the right of the blue bar, but no graph is shown (yes I have selected the legend colour).
How is this possible ?
Right click on the Thread ID column name, and choose Open View Editor.
In the opened window, scroll the list down until you see the Thread ID entry. Under the Aggregation column, select Count.
Now it should display a graph of the amount of threads.
Notice that you should correctly set the first column in the left-most part of the table, to either Process, or Thread Start Module, according to your need.

iReport: How can i display this layout?

Let say I used this query Select customerName From tbCustomer.
How can I display the result in this layout:
CUSTOMER : customerA, customerB, customerC
NOT
CUSTOMER
-customerA
-customerB
-customerC
Normally this is done using columns and horizontal filling. That's the simplest solution. It should be easy for you to figure out how to do this if you know to define how many columns are in the report and set the "Print order" to Horizontal.
That would not have the commas that you show in your example, but it would be quite similar.
If you really want exactly what you have shown, then you could create a variable that appends each customer name to it as it iterates. In your simple example you would display this value in the Summary band (or Title or other band... but not the detail band).

Crystal Reports - my formula works, but when repeated in more than 1 subreport, all records disappear

I'm not a developer but I'm supposed to create a report by C.R., so excuse me in advance if it is an obvious question for you, and please keep in mind that I'm a real beginner.
I have a job composed of 3 different workings (3 out of 5, which is the maximum workings I can have for a job).
In my SQL database, the table.field corresponding to those workings is job.phase, so when I put, in my report details, the field "job.phase", I get 3 rows for that job.
The point is that my report printout always has to show 5 different text objects (one below the other), corresponding to the descriptions of all the 5 possible table.field-records, and a 'X' should appear next to text objects when each one of the workings listed there is a part of my job (otherwise nothing should appear).
What I have done is the following:
- created a subreport containing the "job.phase" field
- put it near my first text object
- specified in my subreport the following "show string" formula:
if job.phase = 'working1' then 'X' else ''
and it works: a X appears if working1 is part of my job, nothing appears if working1 is not part of my job.
Then I have created 4 subreports more, equal to the first one, and specified the same for job.phase = working2, working3, working4 and working5, BUT, after doing that, no X is shown (even though working 1, 2 and 3 are part of my job)...
Is there anybody who can help me, please? It's so frustrating...
Using subreports for something like this is overkill for what you're trying to do and could be causing any number of things to behave badly. I'd recommend you abandon that idea. Here's how I would do it:
The first thing you'll want to do is group by job (if more than one will appear in your report, which I'll assume it will). The Group Footer section is where you can display the labels and Xs. You'll need to create 5 formulas as you did before if {job.phase} = "working1" then "X", one for each of the phases/workings. Drop all 5 of those formulas into the Details section of the report and then suppress that entire section so that it doesn't display.
To show the Xs, you can use a Maximum summary in the Group Footer for each of the five formulas you created. To do this, right-click each of the formulas in turn, select Insert -> Summary. Choose Maximum as the summary, and "Group 1" (Your job ID or whatever field you are using to group the job) as the Location. That will insert a field into the Group Footer that will display an X when that particular working is specified for the job, otherwise it won't display anything. Move them to display next to the appropriate label/text field and you're done.

Resources