I am not so fluent in Gambas, but have made many char converters in the
past...

Instead of using IFs it is better to work with char codes (ASCII, UTFxx).

Create Array with suitable char width (8, 16, 32 Byte) and fill in with what
you need.

As example: on InChar "A" should be shown sth. other. put in your array's
65-th element what you wish to have as "answer".

Than the whole code reduces to:

sRetChar=YOURARRAY(ASC(sInChar))

It is much faster than multiple IFs

kind regards

Emil





-----Ursprungliche Nachricht-----
Von: ad...@micro-source.ch [mailto:ad...@micro-source.ch]
Gesendet: Donnerstag, 2. April 2009 01:01
An: gambas-user@lists.sourceforge.net
Betreff: Re: [Gambas-user] (no subject)


First you set the Return String to the Input value and none of the If's
is proceed. So, what goes In is coming Out.

Regards, Werner

FUNCTION Gronverter(sInChar AS String) AS String
DIM sRetChar AS String = sInChar

IF sInChar = "?" THEN sRetChar = "a"
IF sInChar = "?" THEN sRetChar = "v"
IF sInChar = "?" THEN sRetChar = "g"
IF sInChar = "?" THEN sRetChar = "d"
IF sInChar = "?" THEN sRetChar = "e"
IF sInChar = "?" THEN sRetChar = "z"
IF sInChar = "?" THEN sRetChar = "?"
IF sInChar = "?" THEN sRetChar = "th"
IF sInChar = "?" THEN sRetChar = "i"
IF sInChar = "?" THEN sRetChar = "k"
IF sInChar = "?" THEN sRetChar = "l"
IF sInChar = "?" THEN sRetChar = "m"
IF sInChar = "?" THEN sRetChar = "n"
IF sInChar = "?" THEN sRetChar = "x"
IF sInChar = "?" THEN sRetChar = "o"
IF sInChar = "?" THEN sRetChar = "p"
IF sInChar = "?" THEN sRetChar = "r"
IF sInChar = "?" THEN sRetChar = "s"
IF sInChar = "?" THEN sRetChar = "t"
IF sInChar = "?" THEN sRetChar = "i"
IF sInChar = "?" THEN sRetChar = "f"
IF sInChar = "?" THEN sRetChar = "h"
IF sInChar = "?" THEN sRetChar = "ps"
IF sInChar = "?" THEN sRetChar = "o"
RETURN sRetChar

END




----------------------------------------------------------------------------
--
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


------------------------------------------------------------------------------
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to