Documentation
No edit summary
No edit summary
Line 187: Line 187:
   
 
==ChangeLog==
 
==ChangeLog==
  +
  +
===0.0.4===
  +
* Soundex()
  +
* Soundex4()
  +
* ReverseSoundex()
  +
* SoundsLike()
  +
* Levenshtein()
  +
* SqlName()
  +
 
===0.0.3===
 
===0.0.3===
 
* License is now AGPL v3
 
* License is now AGPL v3

Revision as of 00:29, 12 February 2009

Overview

This is the strLib documentation. strLib does not have an home page yet. You can download it from: this topic in a Gambas italian forum.

System requirements

strLib is written with Gambas 2.8. I didn't test it with any earlier versions. Also, strLib has only been tested with GNU/Linux. Should work with any other system supported by Gambas, but... who knows?

The only requested module is gb. You can use strLib in a command-line application.

License

0.0.1 and 0.0.2 versions were released under GNU GPL version 3. I forgotten that the library can be used for www applications. 0.0.3 is release under GNU AGPL version 3.

The difference is that if one uses program, he ALWAYS has the right to get its source; even if he's using it via web browser. GPL doesn't specify this. This is why public web applications with GPL license are not free software.

This documentation is public domain. It doesn't have a license or an owner. Do anything you want with it, I don't care.

Credits

Author's email is: federico_raz _AT_ yahoo ,. DOT it

Please, feel free to write me; I'll probably feel free to ignore you.

What to do if you find a bug

If the bug is in the library and you can fix the bug
  1. Fix the bug.
  2. Send me the correct function.
  3. Thanx. Now you are a better person.
If the bug is in the lib and you can't fix the bug
  1. Copy your code into an email. Include all that is needed to make your code work. If you don't, I'll insult you.
  2. Tell me exactly what results you would expect.
  3. Tell me exactly what results you get on your system.
  4. Thanx. Now you are a better person.
If the bug is in this docs
  1. Edit the docs. In case you didn't notice, this is a wiki :)
  2. Thanx. Now you are a better person.
If it is a feature request (not a bug)
  1. When you see a comet, desire that I'll implement it. Remember: you don't have to tell your desire to anyone.
  2. Thanx. Now you are a better person.

Usage

Functions

The following is a list of all implemented functions.

Infos about string
  • StartsWith()
  • EndsWith()
  • WordsCount()
String Manipulation
  • Implode()
  • Reverse()
  • LeftPad(), RightPad(), Pad()
  • InPad(), OutPad()
  • Fill()
  • Translate()
Case manipulation
  • ICase()
  • UCWords()
  • UCFirst()
Get substring
  • CharAt()
  • CharFromLast()
  • Substring()
Substring manipulation
  • Insert()
  • Drop()
  • SubReplace()
Databases
  • SqlQuote()

Below, they are listed alphabetically.


CharAt

Syntax
String CharAt(String Input, Integer Position)

Returns a character from Input placed at Position. Position is an index starting from 0.

Examples
CharAt("Ravachol", 0) ' returns "R"
CharAt("Ravachol", 1) ' returns "a"

CharFromLast

Syntax
String CharFromLast(String Input, Integer Position)

Returns a character from Input placed at Position. Position starts from 0, which represents the last character.

Examples
CharFromLast("Ravachol", 0) ' returns "l"
CharFromLast("Ravachol", 1) ' returns "o"

Drop

Syntax
String Drop(String Input, Integer Start[, Variant End])

Drops from Input a substring and returns it. The substring's first character is pointed by Start and the last character is pointer by End. Both Start and End start from 0. If End is not specified or null, it points to the last character.

Examples
Drop("i don't like you", 2, 7) ' returns "i like you"
Drop("0123456789", 5) ' returns "01234"
Drop("0123456789", 5, NULL) ' returns "01234"
Drop("0123456789", 0) ' returns ""
s = "i don't want to hurt you"
s2 = "don't"
s3 = " hurt"
s = Drop(s, InStr(s, s2) - 1, InStr(s, s3) - 1)
' returns "i hurt you"

Fill

Syntax
String Fill(Integer Length, String Pattern)

Returns a string long Length characters, made with characters from Pattern.

Examples
Fill(10, "NO ") ' returns "NO NO NO N"
Fill(1, "ABCDE") ' returns "A"

ICase

Syntax
Strign ICase(String Input)

Returns Input with all lower case letters turned to upper case and vice versa.

Examples
ICase("HI THERE!") ' returns "hi there!"
ICase("hello world") ' returns "HELLO WORLD"
ICase("Nowhere Man") ' returns "nOWHERE mAN"

Implode

I have to redo this. Please, ignore it. It's definitely useless now.

InPad

Insert

LeftPad

Levenshtein

EndsWith

OutPad

Pad

Reverse

ReverseSoundex

RightPad

SqlName

SqlQuote

StartsWith

Soundex

Soundex4

SoundsLike

SubReplace

SubString

Translate

UCFirst

Syntax
String UCFirst(String Input)

Returns Input with the first character turned to upper case. Other characters are left unchanged.

Examples
UCFirst("supercalifragilistic") ' returns "Supercalifragilistic"
UCFirst("ETA) ' returns "ETA"

UCWords

WordsCount

The past and the future

ChangeLog

0.0.4

  • Soundex()
  • Soundex4()
  • ReverseSoundex()
  • SoundsLike()
  • Levenshtein()
  • SqlName()

0.0.3

  • License is now AGPL v3
  • ICase()
  • UCWords()
  • UCFirst()
  • Insert()
  • Drop
  • SubReplace()
  • SqlQuote()

0.0.2

  • CharFromLast() was the same as CharAt(). Now, it does what docs say.
  • Substr() and Repeat$() were removed, because Gambas already has these features. Implode() will be modified.
  • CharAt() is faster
  • Pad(), LeftPad(), RightPad() added
  • WordsCound() added

0.0.1

  • This version exist. Previous version didn't. In other words, this is the first version. It doesn't include the version number.

To-Do

  • strLib should become a component
  • More presentation (esthetic) functions.
  • More functions to build Sql statements.
  • Something useful for web applications.

Of course I won't implement these tomorrow, because I'm busy and lazy.