Returns string portion before nth occurence of substring


      BeforAtNum( <cStringToMatch>, <cString>, [<nCounter>],
                  [<nIgnore>] ) --> cRestString


<cStringToMatch> is the substring scanned for <cString> is the scanned string [<nCounter>] determines how many occurences are of <cStringToMatch> in <cString> are searched Default: search last occurence [<nIgnore>] determines how many character from the start should be ignored in the search Default: 0


<cRestString> the portion of <cString> before the <nCounter>th occurence of <cStringToMatch> in <cString> If such a string does not exist, an empty string is returned.


This function scans <cString> for <cStringToMatch>. After the <nCounter>th match (or the last one, depending on the value of <nCounter>) has been found, the portion of <cString> before that match will be returned. If there aren’t enough matches or the last match is identical to the start of <cString> (i.e. the last match is the first match), an empty string will be returned. After a match has been found, the function continues to scan after that match if the CSetAtMuPa() switch is turned off, with the second character of the matched substring otherwise. The function will also consider the settings of SetAtLike().


      ? BeforAtNum( "!", "What is the answer ? 4 ! 5 !" ) 
                       // -> "What is the answer ? 4 ! 5 "
      ? BeforAtNum( "!", "What is the answer ? 4 ! 5 ?" ) 
                       // -> "What is the answer ? 4 "
      <TODO: add some examples here with csetatmupa() and setatlike()>


      BeforAtNum( "..", "!" ) == ""
      BeforAtNum( "..", "!", 2 ) == "..This"
      BeforAtNum( "..", "!", 2, 2 ) == ""


BeforAtNum() is compatible with CT3’s BeforAtNum().




Source is atnum.c, library is ct3.


AtNum() AfterAtNum() CSetAtMuPa() SetAtLike()


2 responses to “BeforAtNum()

  1. Pingback: Harbour All Functions – B | Viva Clipper !

  2. Pingback: Harbour String Functions | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s