[Gambas-devel] Gambas-devel Digest, Vol 21, Issue 14
Carlos Pinto
pintocar83 at ...176...
Mon Apr 28 04:05:03 CEST 2008
Hello to all. My name is Carlos Pinto and I am from Venezuela, I would like
to collaborate with the project.
I have just finished a class similar to the QString of Qt, I would like to
share it with you and I would like to know that possibilities it's to
include it as a component of Gambas.
Translation Spanish -> English
http://www.elmundo.es/traductor/
======================================================================
Hola a todos. Mi nombre es Carlos Pinto y soy de Venezuela, me gustaría
colaborar con el proyecto.
Acabo de terminar una clase parecida a la QString de Qt, me gustaría
compartirla con ustedes y me gustaría saber que posibilidades hay de
incluirla como un componente de gambas.
======================================================================
' Gambas class file
' QString.class
EXPORT
PRIVATE __String AS String
PROPERTY Value AS String
PUBLIC SUB _new(OPTIONAL _Str AS String = "")
Set(_Str)
END
SUB Value_Read() AS String
RETURN __String
END
SUB Value_Write(_Str AS String)
__String = _Str
END
PUBLIC SUB AppEnd(_Str AS String)
Set(Get() & _Str)
END
PUBLIC SUB Character(Index AS Integer) AS String
RETURN Chr(Asc(__String, Index))
END
PUBLIC SUB Clear()
Set("")
END
PUBLIC SUB Compare(_Str AS String, OPTIONAL CaseSensitive AS Boolean = TRUE)
AS Integer
IF CaseSensitive THEN
RETURN Comp(Get(), _Str, gb.Binary)
ELSE
RETURN Comp(Get(), _Str, gb.Text)
ENDIF
END
PUBLIC SUB Contains(_Str AS String, OPTIONAL CaseSensitive AS Boolean =
TRUE) AS Boolean
IF IndexOf(_Str, 0, CaseSensitive) <> 0 THEN RETURN TRUE
RETURN FALSE
END
PUBLIC SUB Fill(_Str AS String, OPTIONAL N AS Integer = 0)
IF N = 0 THEN
Set(String$(Length(), _Str))
ELSE
Set(String$(N, _Str))
ENDIF
END
PUBLIC SUB Get() AS String
RETURN __String
END
PUBLIC SUB IndexOf(_SubStr AS String, OPTIONAL Start AS Integer = 0,
OPTIONAL CaseSensitive AS Boolean = TRUE)
IF CaseSensitive THEN
Set(InStr(Get(), _SubStr, Start, gb.Binary))
ELSE
Set(InStr(Get(), _SubStr, Start, gb.Text))
ENDIF
END
PUBLIC SUB Insert(Position AS Integer, _Str AS String)
ReplacePosition(Position, 0, _Str)
END
PUBLIC SUB ToInvert()
DIM i AS Integer
DIM _Str AS String
_Str = ""
FOR i = Length() TO 1 STEP -1
_Str = _Str & Character(i)
NEXT
Set(_Str)
END
PUBLIC SUB IndStr(_SubStr AS String, OPTIONAL Start AS Integer = 0, OPTIONAL
CaseSensitive AS Boolean = TRUE)
IndexOf(_SubStr, Start, CaseSensitive)
END
PUBLIC SUB IsEmpty() AS Boolean
IF Get() = "" THEN RETURN TRUE
RETURN FALSE
END
PUBLIC SUB LastIndexOf(_SubStr AS String, OPTIONAL Start AS Integer = 0,
OPTIONAL CaseSensitive AS Boolean = TRUE)
IF CaseSensitive THEN
Set(RInStr(Get(), _SubStr, Start, gb.Binary))
ELSE
Set(RInStr(Get(), _SubStr, Start, gb.Text))
ENDIF
END
PUBLIC SUB Left(Position AS Integer)
Set(Left$(Get(), Position))
END
PUBLIC SUB Length() AS Integer
RETURN Len(Get())
END
PUBLIC SUB Mid(Position AS Integer, ...)
IF Param.Count = 0 THEN
Set(Mid$(Get(), Position))
ELSE
Set(Mid$(Get(), Position, Param[0]))
ENDIF
END
PUBLIC SUB PrepEnd(_Str AS String)
Set(_Str & Get())
END
PUBLIC SUB Repeat(N AS Integer)
Set(String$(N, Get()))
END
PUBLIC SUB Replace(StrFind AS String, StrNew AS String, OPTIONAL
CaseSensitive AS Boolean = TRUE)
IF CaseSensitive THEN
Set(Replace$(Get(), StrFind, StrNew, gb.Binary))
ELSE
Set(Replace$(Get(), StrFind, StrNew, gb.Text))
ENDIF
END
PUBLIC SUB ReplacePosition(Position AS Integer, NCharacter AS Integer, _Str
AS String)
DIM Pchar AS Integer
DIM Nchar AS Integer
Pchar = Position - 1
Nchar = Length() - (Position + NCharacter) + 1
IF Pchar < 0 THEN Pchar = 0
IF Nchar < 0 THEN Nchar = 0
Set(Left$(Get(), Pchar) & _Str & Right$(Get(), Nchar))
END
PUBLIC SUB Right(Position AS Integer)
Set(Right$(Get(), Position))
END
PUBLIC SUB RIndStr(_SubStr AS String, OPTIONAL Start AS Integer = 0,
OPTIONAL CaseSensitive AS Boolean = TRUE)
LastIndexOf(_SubStr, Start, CaseSensitive)
END
PUBLIC SUB Search(_Str AS String, OPTIONAL CaseSensitive AS Boolean = TRUE)
AS Boolean
RETURN IndexOf(_Str, 0, CaseSensitive)
END
PUBLIC SUB Set(_Str AS String)
__String = _Str
END
PUBLIC SUB Split(Separator AS String, OPTIONAL Escape AS String = "",
OPTIONAL IgnoreVoids AS Boolean = FALSE) AS String[]
RETURN Split(Get(), Separator, Escape, IgnoreVoids)
END
PUBLIC SUB ToLower()
Set(LCase(Get()))
END
PUBLIC SUB ToUpper()
Set(UCase(Get()))
END
PUBLIC SUB Trim()
Set(Trim$(Get()))
END
PUBLIC SUB TrimLeft()
Set(LTrim$(Get()))
END
PUBLIC SUB TrimRight()
Set(RTrim$(Get()))
END
PUBLIC SUB ToValue() AS Variant
RETURN Val(Get())
END
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20080428/c16e4290/attachment.html>
More information about the Devel
mailing list