Can someone help with a count of certain records in a Browse

I have a browse, which has, for example, a serial number
Nt410-1
Nt410-2
Nt420-1
Nt430-1
Nt440-1

Need a code that says when the serial number begins with Nt410, Nt410 should be counted.

If the serial number starts with Nt440, Nt440 must be counted

Didn’t you ask this before (and get an answer) ?

https://clarionhub.com/t/can-somone-help-with-a-code/5966

No, then I was going to add to a database.

Now I want to count different snr in a browse

ons. 12. apr. 2023 kl. 10:38 skrev Julian via ClarionHub <[email protected]>:

Create a queue(snr, count), then for each datarow add new record: q(datarow:snr[1:5], 1) or update existing: q(datarow:snr[1:5], count+1).

2 Likes

Assuming ABC, you just need to add code to the Browse TakeRecord embed to look at the code and decide to add to a count or not

Does anyone have an example of a program that uses queue

QUEUEs can be used in numerous scenarios. What purpose(s) are you going to use them for?

I have a browse, which has, for example, a serial number
Nt410-1
Nt410-2
Nt420-1
Nt430-1
Nt440-1

Need a code that says when the serial number begins with Nt410, Nt410 should be counted.

If the serial number starts with Nt440, Nt440 must be counted

And I got this answer

Create a queue(snr, count), then for each datarow add new record: q(datarow:snr[1:5], 1) or update existing: q(datarow:snr[1:5], count+1).

Why are you duplicating a topic?

you have already asked the same thing here

and you have been replied already there

I merged that new topic into this one. Thanks.

The Count with Queue is complicated that the Browse is Page Loaded. Seems you would only want One record counted Once. Paging Up would reload the same records.

You would want a count of All records without having to page thru it all of it, so File Load the Browse but it may have a lot of records. A Process template could scan all the records and build the count queue. Is this a small subset of records?

A screen capture of the browse window may help.

1 Like

For a file loaded browse. use the method I posted earlier,
or look at the Totalling tab of the browse. Add a conditional total of type sum.
the condition would be INSTRING(‘Nt440’,my:Field)

1 Like

image

Thanks for the help
Did this instead

That [1:5] is a String Slice. A caution that a Slice with a bad Start or End can GPF your program. Or it can corrupt memory which you won’t know unless you have Debug Index Array Checking on in the Project.

The safer code is to use the SUB(String,Start, Length) function SUB(CSV:stock,1,5) which will never GPF or corrupt no matter how wrong the you have (Start, Length).

Note that the Browse Total does have to scan the entire file. You may see it slow things on a network drive or a very large file.

2 Likes

Perfect
Here is the result

I will put the result here

I am reading in the code from an excel sheet

I will send various things for repair

fre. 14. apr. 2023 kl. 18:55 skrev Carl Barnes via ClarionHub <[email protected]>:

I certainly would not be providing a “business solution” like that … It’s very much hard-coded (in both logic and presentation).

What will you do when someone expects to see new code, say; NT480 ?

It is always between NT410 AND NT470

tor. 20. apr. 2023 kl. 08:10 skrev John Morter via ClarionHub <[email protected]>:

Yes - until it isn’t.

1 Like