Code: Select all
#include "HMG.CH"
FUNCTION MAIN()
SET CODEPAGE TO UNICODE
SET LANGUAGE TO SPANISH
DEFINE WINDOW UNO AT 0,0 WIDTH 0 HEIGHT 0 BACKCOLOR {0,125,250} NOCAPTION MAIN
FRASE := "ESA MÁSCARA CAUSA CÁNCER"
LETRA := { 'A', 'Á' } // LETRA A BUSCAR EN LA FRASE Y MOSTRARLA
LARGO := hb_ULen(ALLTRIM(FRASE))
X := 1
Y := 1
DO WHILE LARGO > 0
LETT := hb_USubStr(FRASE,X,1) // CADA LETRA
L1 := 'L'+ALLTRIM(STR(X)) // LABEL PARA MOSTRAR TODAS LAS LETRAS MENOS LA Á (INCLUYE ESPACIOS)
L2 := 'M'+ALLTRIM(STR(X)) // LABEL PARA LLEVAR NUMERACIÓN DE X
DO CASE
CASE ASCAN ( LETRA, LETT ) = 2 //LETT = "Á"
aColor := { 0 , 255 , 0 } //GREEN
CASE ASCAN ( LETRA, LETT ) = 1 //LETT = "A"
aColor := { 255 , 255 , 0 } //YELLOW
CASE LETT = " "
LETT := "_"
aColor := { 128 , 64 , 64 } //BROWN
OTHER
aColor := { 255 , 255 , 255 } //WHITE
ENDCASE
@ 099,X*50 LABEL &L1 VALUE LETT WIDTH 99 HEIGHT 70 FONT "TAHOMA" SIZE 48 BOLD FONTCOLOR aColor BACKCOLOR {0,125,250}
@ 200,X*50 LABEL &L2 VALUE STR(X,2,0) WIDTH 99 HEIGHT 70 FONT "TAHOMA" SIZE 20 BOLD FONTCOLOR aColor BACKCOLOR {0,125,250}
X++
Y++
LARGO--
ENDDO
ON KEY ESCAPE ACTION UNO.RELEASE
END WINDOW
UNO.MAXIMIZE
UNO.ACTIVATE
RETURN
https://github.com/Petewg/harbour-core/wiki/Strings
hb_UAt( <cSubString>, <cString>, [<nFrom>], [<nTo>] ) ➜ nAt
Unicode counterpart of 'hb_At()'.
hb_UCode( <cText> ) ➜ nCode
return Unicode value of 1-st character (not byte) in given string. Similar to 'hb_UTF8Asc()'.
hb_ULen( <cText> ) ➜ nChars
returns the length of unicode string <cText>, in characters.
hb_ULeft( <cString>, <nCount> ) ➜ cSubstring
same as 'Left()' but applicable to UTF8 encoded text.
hb_UPadC(<exp>, <nLength>, [<cFillChar>]) ➜ cPaddedString
same as 'PadC()' but Unicode oriented.
hb_UPadL(<exp>, <nLength>, [<cFillChar>]) ➜ cPaddedString same as 'PadL()' but Unicode oriented.
hb_UPadR(<exp>, <nLength>, [<cFillChar>]) ➜ cPaddedString
same as 'PadR()' but Unicode oriented.
hb_UPeek( <cText>, <n> ) ➜ nCode
return unicode value of <n>-th character in given string
hb_UPoke( [@]<cText>, <n>, <nVal> ) ➜ cText
change <n>-th character in given string to unicode <nVal> one and return modified text.
hb_URight( <cString>, <nCount> ) ➜ cSubstring
hb_UStuff( <cString>, <nAt>, <nDel>, <cIns> ) ➜ cResult
Unicode counterpart of 'Staff()'.
hb_USubStr( <cString>, <nStart>, <nCount> ) ➜ cSubstring
Unicode counterpart of 'SubStr()'.
hb_utf8Asc( <cExp> ) ➜ nUTF8CharCode
same as 'Asc()' but applicable to UTF8 encoded text. Similar to 'hb_UCode()'.
hb_utf8At(<...>) ➜ nPos
same as hb_At() but applicable to UTF8 encoded text.
hb_utf8Chr( <n> ) ➜ cUTF8Char
same as 'Chr()' but applicable to UTF8 encoded text.
hb_utf8Left(...) ➜ cString
same as 'Left()' but applicable to UTF8 encoded text.
hb_utf8Len(`' ) ➜ nLen same as 'Len()' but applicable to UTF8 encoded text.
hb_utf8Peek( <cText>, <n> ) ➜ nCode
return UTF8 value of <n>-th character in given string.
hb_utf8Poke( [@]<cText>, <n>, <nVal> ) ➜ cText
replace <n>-th character in given string to UTF8 <nVal> one and return modified text.
hb_utf8RAt() ➜ nPos
same as 'hb_RAt()' but applicable to UTF8 encoded text.
hb_utf8Right() ➜ nPos
same as 'Right()' but applicable to UTF8 encoded text.
hb_utf8StrTran() ➜ cString
same as 'StrTran()' but applicable to UTF8 encoded text.
hb_utf8Stuff() ➜ cString
same as 'Stuff()' but applicable to UTF8 encoded text.
hb_utf8SubStr() ➜ cString
same as 'SubStr()' but applicable to UTF8 encoded text.
hb_utf8ToStr( <cUTF8Str> [, <cCPID>] ) ➜ cStr
it performs "translation" from UTF-8 to <cCPID> Harbour codepage id, f.e.: "EN", "ES", "ESWIN" etc.
<cUTF8Str> supposed to be a UTF-8 encoded string.
When <cCPID> is not given then the default HVM codepage (i.e. that set by hb_cdpSelect()) is used.