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

This topic is 5874 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello, i have an interesting issue here that would like to share with you guys and hopefully solve it since its very important for a process which i am working in my company.

The process is based on a scan of products in a global fields formatted as text. The scan may contain numbers from 2 digits until 6 for example:

12

123

1234

12345

123456

After the scan is done i do a process which looks for the related parts in our inventory which thats already working good, after that it goes to the first part and checks on the global scanned how many times that part has been scanned, this is where the problem comes.

Lets say i scanned 35 parts with the part number 2222, i use the patterncount function to count how many repetitions of this number is in the field, the result should be 35 but if there is another part that has a number 12222 will count is as 36 when only 35 of the parts are the same.

Is there any way to count only the exact string?

I prepared this example so you can see it, i hope you guys can help me on this issue, i will be more than appreciated.

test.zip

Posted

Try

PatternCount( ¶ & test::g_text & ¶ ; ¶ & test::int & ¶ )

Posted

unfortunally it doesn't work, i have tried with the part 5639 which has 35 parts and the result returned 19, i have formatted the function like this:

PatternCount( "¶" & test::g_text & "¶" , "¶" & test::int & "¶" )

Posted

Ah oops. Should have thought it out more.

Here

PatternCount( test::g_text & "¶" ; test::int & "¶" )

Posted

AFAICT, the global field in the above file contains 36 values of "5639", not 35.

PatternCount( test::g_text & "¶" ; test::int & "¶" )




returns 37, because it includes "15639" in the count.





Try:




PatternCount( "¶" & Substitute( g_text , "¶", "¶¶" ) & "¶" , "¶" & int & "¶" )

See the help on PatternCount() why this needs to be so.

Note that the relationship is not required for this.

Posted

Comment:

YOU ARE THE MAN, i mean, i don't understand the theory you used that much, it's kind of catchy but it does the job it has to do, im really impressed, a million thanks, i'll keep checking this out to see how it really works.

Again, thanks a bunch!!!

Posted

Michael has corrected it once again. I was correct in the orginal path I was heading down with both Pilcrows. The thing was that I had forgotten that PatternCount was not inclusive.

So when you have

[color:red]

5639

5639

It only counts it once and returns 1.

So Michael used a subsitute to change all the single returns into double returns. Once that is done, the PatternCount will work.

[color:red]

5639

¶[color:green]

5639

This counts twice and returns 2.

Posted (edited)

Ohh i see, because if you don't include double return the patternCount would take the return of the next string and there would a return missing for the next repetition so it skips one repetition and goes to the next one.

Very well, i guess i learned something new very interesting today.

Thanks for the support guys!

Edited by Guest
Posted

As always, I learn something new from you every day. :

This topic is 5874 days old. Please don't post here. Open a new topic instead.

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.