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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Find the number of identical String in a range

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Robinou Posted - 10/18/2022 : 4:55:37 PM
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
2   L A T E S T    R E P L I E S    (Newest First)
minimax Posted - 11/27/2022 : 9:43:24 PM
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=;


Castiel Posted - 10/19/2022 : 06:37:49 AM
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
------------------------------------------

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000