The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Find the number of identical String in a range
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Robinou

France
14 Posts

Posted - 10/18/2022 :  4:55:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi guys,

I would like to know how to find the number of specific string on a range.

I show my exemple below.



Thanks a lot

Castiel

343 Posts

Posted - 10/19/2022 :  06:37:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by Robinou

Hi guys,

I would like to know how to find the number of specific string on a range.

I show my exemple below.



Thanks a lot



Define the range with "-v" switch, then you loop over each item in it. For example,

%A = "MG";
range -v rr = 4[3]:9[3];
int count = 0;
for(int ii = 1; ii <= rr.GetSize(); ii++)
{
    string ss$ = rr[ii]$;
    if(compare(ss$, %A) == 1)
    {
        count += 1;
    }
}
type "%A" Found: $(count);



------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

minimax

348 Posts

Posted - 11/27/2022 :  9:43:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Robinou,

Besides the script Castiel mentioned, you can also try using function countif, like


string str1$= "MG";
range -v r1 = [basesaison]cycle_1_dev!4[3]:9[3];
int ic=countif(r1, "r1==str1$");
ic=;


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000