PDA

View Full Version : about LETTERS$() and LETTER_SetMask$() Functions



primo
26-10-2017, 10:44
Letters$() function is an interesting function, it is like the magnet over the Garbage to attract magnetic metals (iron, nickel etc). but Letters$() can attract also plastic, aluminum and any object you plan to attract and that depends on its own control Unit.
by default LETTER$(string) attract only capital and small letters a..z, A..Z , or you can say it allows only letters a..z, A..Z to pass from the door, and if you do PrintL LETTER_GetMask$ you will get ABC..XYZ, abc..xyz
but you can set your own Mask such as:
mask = "234??>\abcAZ"
LETTER_SetMask$(mask)
now LETTERS$(any big string) will return only those characters which is in the mask string and will not allow other chars to pass
it is not necceassery to use LETTERS$() for big strings only, you can use it to clean the pulses of Chaotic characters emanates from a UFO, one pulse every one minute, this is better than
if pulse = "a" or pulse = "b" or or or ....too much typing... then
and better than select case ...
it is clean, easy, speedy and short


'---Load Console Module
Uses "Console"

Dim Chaos As String
Dim i As Long
Chaos = "3+5@-6^99?A3-.$67345b$b**B\'d67c3^1^_70a-6%@42b\c?e+B$B9^@_fc-+f@cc%a7%d$3^%68Ae+Bef#b1e2a^1340*_BAb_4b5b8Ae3-_23d1@e?B#b#5ee@b-9@#f"

PrintL "the built in mask:" In %CCOLOR_FYELLOW
PrintL LETTER_GetMask$ 'the built in mask is A to Z, a to z
PrintL
PrintL "the Aliens UFO code:" In %CCOLOR_FYELLOW
PrintL Chaos
PrintL
String mask = LETTER_GetMask$ + ".\?@"
LETTER_SetMask$(mask)

PrintL "the new mask we set:" In %CCOLOR_FLIGHTRED
PrintL mask In %CCOLOR_FLIGHTGREEN
PrintL
Dim tmp As String
tmp = LETTER$(Chaos)
PrintL "after applying the new mask we extract only these characters:" In %CCOLOR_FYELLOW
PrintL tmp In %CCOLOR_FINTENSEWHITE
PrintL
PrintL "Press a key to end program" In %CCOLOR_FLIGHTRED

'---Wait for a key press
WaitKey


if you have a big string and the console can't display it you can print the result to a file (test.txt) with FILE_Save("test.txt", string)

'---Load Console Module
Uses "Console", "File"

Dim Chaos0, Chaos As String
Dim i As Long
Chaos0 = "3+5@-6^99?A3-.$67345b$b**B\'d67c3^1^_70a-6%@42b\c?e+B$B9^@_fc-+f@cc%a7%d$3^%68Ae+Bef#b1e2a^1340*_BAb_4b5b8Ae3-_23d1@e?B#b#5ee@b-9@#f"
For i=1 To 2000
Chaos = Chaos + Chaos0 ' make big string
Next

PrintL "the built in mask:" In %CCOLOR_FYELLOW
PrintL LETTER_GetMask$ 'the built in mask is A to Z, a to z
PrintL
PrintL "the Aliens UFO code:" In %CCOLOR_FYELLOW
'PrintL Chaos
PrintL
String mask = LETTER_GetMask$ + ".\?@"
LETTER_SetMask$(mask)

PrintL "the new mask we set:" In %CCOLOR_FYELLOW
PrintL mask
PrintL
Dim tmp As String
tmp = LETTER$(Chaos)
PrintL "after applying the new mask we extract only these characters:" In %CCOLOR_FYELLOW
PrintL "it is printed to the file test.txt" In %CCOLOR_FYELLOW
'PrintL tmp In %CCOLOR_FINTENSEWHITE
FILE_Save("test.txt", tmp)
PrintL
PrintL "Press a key to end program" In %CCOLOR_FLIGHTRED

'---Wait for a key press
WaitKey


EDIT: How to add quotation marks to a string ??
by experiments i have found that "" insert one quotation mark to the string.
example:


'---Load Console Module
Uses "Console"

'---Print the magic words
PrintL "Hello ""World"" from ThinBASIC!" In %CCOLOR_FLIGHTGREEN
PrintL
PrintL "Press a key to end program"

'---Wait for a key press
WaitKey

ErosOlmi
26-10-2017, 20:59
:D:D you made my day primo.

Thanks so much to discover those "strange" thinBasic functionalities and experimenting them to the public with great ironic comments.
If thinBasic would be a commercial product I would offer you Marketing Manager position.

Great, thanks again
Eros

ErosOlmi
26-10-2017, 21:20
We developed also:

DIGIT$
DIGIT_SetMask$
DIGIT_GetMask$


Do the same things as

LETTER$
LETTER_SetMask$
LETTER_GetMask$

but can be used when referring to numbers masking so source code can be more readable.