I have a series of records that I have loaded into a queue. The primary key field is StepId and I want to find the largest value of StepId in the queue. I could inspect each record as I load it into the queue, but I’m wondering if there is a quicker way. Also, if the queue is in a browse form, the data has already been loaded. I don’t want to have to rummage through several thousand records to find it.
In Visual Basic there is a function DMAX(“field”,“domain”,“where clause”) which returns the maximum value of a field in the domain (usually a table or query) that corresponds to the optional where clause. Similarly, Visual Basic has a DMIN function for the minimum value.
Is there a Clarion equivalent or a preferred method? I appreciate any thoughts or suggestions.
If you have a queue as a FROM() in a listbox, can you sort that queue in such a way to get the largest value of a field and not disturb the listbox’s sort order? If not, I am not sure how to take advantage of the multiple sort orders.
In addition, would a SORT() change the value of CHANGES()?
LIST controls with a queue as a parameter of FROM uses the current sort order. Current sort order is the order set by the last SORT statement, or, if none explicit SORT has been executed, it’s the order set by the ADD statement inserted a first record to the empty queue. For example,
...set fields of the que...
sets current sort order to unsorted.
Usage of queues is no limited to LISTs’ FROM attributes.
I do not understand what you mean by this comment.
Assuming you are referring to my suggestion … the number of records in the queue is not relevant, neither are any gaps in the sequence, ADDing to the queue using the ADD(Q,Q.StepiD) method will always ensure that the very last record always has the highest value of StepID and GET(Q,RECORDS(Q)) will allow you to examine Q.StepD value.
The Help says SORT increments CHANGES() ID and it makes sense to me that it does because the is QUEUE changed by SORT.
If any of these five statements act on the QUEUE the Change ID is incremented: FREE() ADD() PUT() DELETE() SORT()… If a SORT does not change the order the Change ID is still incremented. The Change ID is simply a count of likely changes.
Ahhh… I may have written that because I know the original Help discussing a Hash Value was wrong. I’m sure I tested it. IIRC DAB discussed CHANGES() needing to be a simple thing that indicated a “likely change”, it was not worth the effort to precisely determine changes. I use CHANGES() to decide if a LIST needs refreshing, e.g. with a VLB asking for Row -3