forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


String evaluation - word count

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Sep 19, 2002 10:16 am    Post subject: String evaluation - word count Reply with quote

Well another one for handling strings: This routine counts the number of words in a string, as defined by the delimiter supplied
(variable %%delim)

Greetz
Dr. Dread

Code:

  list create,1
  %%string = "   This is a test string holding 11 words in all (space-delimited)     "
  %%delim = " "
  %%pos = @pos(%%delim,%%string)
  if @greater(%%pos,0)

    rem If the string starts out with one or more delim chars, we need to trim it
    repeat
   %%pos = @pos(%%delim,%%string)
    if @equal(%%pos,1)
     %%string = @strdel(%%string,1,)
   end
   until @greater(%%pos,1)
    rem If the string ends with one or more delim chars, we need to trim it also
    repeat
    if @equal(@substr(%%string,@len(%%string)),%%delim)
     %%string = @strdel(%%string,@len(%%string))
   end
   until @not(@equal(@substr(%%string,@len(%%string)),%%delim))

    repeat
        %%pos = @pos(%%delim,%%string)
        list add,1,@substr(%%string,1,@sum(%%pos,@pred(@len(%%delim))))
        %%string = @strdel(%%string,%%pos,@sum(%%pos,@pred(@len(%%delim))))
    until @equal(@pos(%%delim,%%string), 0)
  end
  info The string holds @succ(@count(1)) word(s)
  list close,1
  exit

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group