Jump to content
Sign in to follow this  
kjactive

Words UDF function library

Recommended Posts

kjactive

Well I've always missed some functions from the rexx language that all rmore or less relate to manipulate on words rather than characters - Words.au3...

User Defined Function Description

_CountInStr Returns a count of how many string matches are in a string.

_CountWords Returns a count of how many words are in a string.

_DelString Return String with the contents from integer to integer removed from the string.

_DelWords Excerpts one or more words ( No blank space between is removed ) from string, and returns that excerpt.

_DubString Creates a new string that is another string concatenated (ie, appended) a specified number of times.

_GetWord Excerpts one word from a string, and returns that word without any leading or trawling spaces.

_InString Creates a new string that is another string with insert string from argument location.

_JustifyStr Returns a string justified option with pad characters between each word. Any blank space originally between each word is replaced by the pad characters.

_ProperCase Returns a word or the string justified with words in proper case.

_Say Returns the string as ConsoleWrite with a @CR attached. - take 10 arguments sepparated with commas - result is sepparated with a '|' character

_TrimSpace Removes leading and/or trailing space ( convert tab into space character ) and all multible space characters from a string.

_SubWords Excerpts one or more words (and all blank space between them) from a string, and returns that excerpt.

_MatchInStr Return how many occurations of a string of characters is located in another.

_WordIndex Returns the character position of a particular word within a string.

These UDF functions all come as close as posible to functions in the Reginald rexx language ( maintained by Jeff Glatt ), all comes with topics and a index script too...

Free to download and use:

http://www.sitecenter.dk/latenight/nss-fol...ports/Words.zip

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
Richard Robertson

This looks useful, good job. You may want to throw in a spell checker while you are covering all these types of functions.

A question about the post though: instate doesn't make any sense, what was that supposed to say?

Edited by Mr Icekirby

Share this post


Link to post
Share on other sites
RazerM

I think he means 'instead'. Is _DubString not the same as _StringRepeat?


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites
kjactive

I think he means 'instead'. Is _DubString not the same as _StringRepeat?

Yes I know my english is bad but then you should see my German - afterall I'm from Denmark...

There's some semilare function with string.au3 like _DubString (_StringRepeat) _InString (_StringInsert) but I wanted another errorhandle and functions is very uptimized too, as most of the functions in words.au3 is lent from another language and work mostly on words...

Actually I added one function more - _WordLength ( Returns a count of how many characters are in a particular word within a string. )

Download from site:

http://www.sitecenter.dk/latenight/nss-fol...ports/Words.zip

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
Wooltown

I have another little handy script "_IsBlank", attach it to your collection if you think it is nice to have, returns 1 if the input string is empty or just blank characters otherwise 0.

Func _IsBlank($sValue = "")
    LOCAL $iLen
    $iLen = StringLen($sValue)
    If $iLen = 0 Then Return 1
    For $iPos = 1 to $iLen
        If StringMid($sValue,$iPos,1) <> " " Then Return 0
    Next
    Return 1
EndFunc

Share this post


Link to post
Share on other sites
kjactive

I have another little handy script "_IsBlank", attach it to your collection if you think it is nice to have, returns 1 if the input string is empty or just blank characters otherwise 0.

Func _IsBlank($sValue = "")
    LOCAL $iLen
    $iLen = StringLen($sValue)
    If $iLen = 0 Then Return 1
    For $iPos = 1 to $iLen
        If StringMid($sValue,$iPos,1) <> " " Then Return 0
    Next
    Return 1
EndFunc
Could be handy - but don't your script miss horizont tab characters 0x09 - I would prefer a function name like _EmptyStr

kjactive :)

Share this post


Link to post
Share on other sites
Wooltown

It does, it can easily be added in the line where I test for content.

Share this post


Link to post
Share on other sites
kjactive

It does, it can easily be added in the line where I test for content.

Well Words.au3 already has a function that can do that test on a string ( no matter spaces and tab characters included ) _Getword('') try to get first word in a empty string would return an empty string - actually would _CountWords & _WordLength result in 0 and sets @error = 1 too...

$string = "   "
If _Getword($string,1) = "" then
   _Say('String is Empty',@error)
Else
   _Say('String Contain characters',@error)
Endif

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
kjactive

I add two functions to the Words.au3 UDF

_WordLength ( $sString, $iInt ) ; Returns a count of how many characters are in a particular word within a string.

_JustifyStr ( $sString, $iLength, $sPadchar ) ; Returns a string justified, option with pad characters between each word. Any blank space originally between each word is replaced by the pad characters - default space 0x20.

Download from site:

http://www.sitecenter.dk/latenight/nss-fol...ports/Words.zip

all 14 functions come with topics and a index script...

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
kjactive
Wooltown

Nice functions to have would be:

ProperCase - First letter Big, the rest small

ProperCaseName - First letter Big in all words, the rest small.

Share this post


Link to post
Share on other sites
kjactive

Hallo Wooltown

ProperCase - First letter Big, the rest small

Okay I've attached your wanted function _ProperCase, a topis and index script included

I only added one function but I think that this holds all the functions that you want - return a word with Proper case, or return a string with a particulare word changed to proper case or what ever you want that for - exchange all words in a string to proper cases

Could you check it out for me, please use link below

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
Wooltown

#include "words.au3"

Msgbox(0,"",_ProperCase("tEsT nR 1Tt av fEm",1,1))
Msgbox(0,"",_ProperCase("tEsT nR T2å av fEm",2,0) )
Msgbox(0,"",_ProperCase("tEsT nR 3Re av fEm",4,1) )
Msgbox(0,"",_ProperCase("tEsT nR F4rA av fEm",1,2) )
Msgbox(0,"",_ProperCase("tEsT nR fem av fEm",3,2) )

Thanks, looks nice but how do I change so just the first word in a sentence have the first letter capitalized ant the rest small ?

I now I can use Stringlower first and then use the example in the first msgbox, but it would be nice to have it in the function.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×