Results 1 to 3 of 3

Thread: about LETTERS$() and LETTER_SetMask$() Functions

Hybrid View

  1. #1

    about LETTERS$() and LETTER_SetMask$() Functions

    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
    
    Last edited by primo; 26-10-2017 at 15:31.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    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
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    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.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Similar Threads

  1. Letter$, Letter_SetMask$, Letter_GetMask$ problem
    By Petr Schreiber in forum Help Material
    Replies: 0
    Last Post: 28-10-2010, 18:04
  2. Inner Functions
    By Charles Pegge in forum O2h Compiler
    Replies: 3
    Last Post: 12-07-2009, 23:51
  3. B3D loading functions
    By Michael Hartlef in forum thinBasic vaporware
    Replies: 10
    Last Post: 10-02-2008, 21:18
  4. OS module: two new functions
    By RobertoBianchi in forum OS
    Replies: 4
    Last Post: 24-09-2007, 09:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •