String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands >

String Operations

GFS. - Get-Filtered-String

Previous Top Next


MiniRobotLanguage (MRL)

 

GFS. Command

Get Filtered String

 

 

Intention

 

This command implements a string-filter. A string-filter is a thing that filters a string in a way that only allowed chars are left in that string.

While some uses of this command are simple, the command itself implements a complex string processor that can be customized to filter your strings in many ways.

 

IMPORTANT: You need to additionally specify the "z" or "x" or "y" or "o","p"  Prototype to get the filtered result calculated.

Please specify these in the right order, as they are processed one after the other from left to right.

 

Example:

 

  ' Will work

GFS.tz|$$TXT

 

  ' Will NOT work, because z is used before t is processed

GFS.zt|$$TXT

 

 

Mode 1: the Keep Chars-Filter

 

Let's see an example. We use two prototypes here:

t -  select filter chars for "time string"

z - keep only filter-chars

 

graphic

Note that the sequence of the prototypes is important here. The string processor evaluates the prototypes from left to right. We have first to select the "filter chars" then we can use them in a filter-set.

 

Thats why you can not write::

 

GFS.zt|$$SRC

 

If you do so,.the result will be an empty string.

 

Lets see another example.

 

Mode 2: the Remove Chars-Filter

 

graphic

 

In the RCF-Mode, the selected chars will be removed from the string. In this example we select the i-prototype which is "E.,()<>+-/\*^" (see below). Now all chars that are inside that filter-char-set will be removed from the source string. You can see the result in the messagebox in the picture above.

 

Mode 3: the Combined Mode-Filter

 

This mode is just a combination of the two modes above. You can combine as many filters as you want in a single GFS.-Instruction. In this example we give a third parameter $$REM that is automatically added to the filter-chars at the start. The following example implements two filters.

 

graphic

 

When the filter starts, it takes the $$REM and adds it to the filter-char. It does this because its the third parameter.

Next it comes to the "y"-prototype and executes an "Remove all filter-chars"-Filter  (RCF).

Then it comes to the "u"-prototype that will clear the filter-chars-list. We do this just for this example, it would not really be necessary here.

The next prototype is the "b", it adds all uppercase english letters to the filter-chars.

And finally we execute the "z"-prototype that is a "KCF"- "Keep Only Filter-Chars". It will remove all chars that are NOT in the filter-char list. As a result we get the string USA, as you can see in the picture.

 

Mode 4: The two special filters

 

There are two special filters included which are not influenced by the filter-char list and the other commands. These two prototypes will just work on the given string and immediately process it. These are the "o" and the "p"-prototype. They serve a special purpose.

The "o" - prototype will remove all ASCII-Chars below 32 from your given input string.

To understand the next prototype you will need to know that the normal "Space"-Character has the ASCII of 32. But there is another one which look equal and has an ASCII of 160. This one can make processing of strings for you difficult because you may think "Its an Space" but in reality its an ASCII 160 that is in fact not an Space.

To overcome that problem, the filter option "p" will replace any ASCII 160 to an ASCII of 32.

 

Mode 5: Use a custom filter string from stack

 

We have already shown how to give a custom filter-char-set, using a third parameter. You can add a value from stack, using the "c" prototype. See the example in the next picture.

 

You can push the current filter-char-set at any time to the stack, using the "q" prototype. You can also put the current input-string onto the stack, using the "r"-prototype.

 

graphic

 

 

Important note:

As this commands implements a "string processor" the sequence of the prototypes is important, unlike in most other commands. The prototype are processed in the order they are provided.

 

 

 

Syntax

 

GFS.P1[|P2][|P3]

 

 

Parameter Explanation

 

P1   - Prototypes.

 

Options:

a - force binary compatible resolution for string parameter*

 

Filter-Char prototypes:

b - "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

c - Add "custom" TOS to Filter-chars

d - add "0123456789"

 

' add Chars that are allowend in an e-mailadress before the @

e - "!#$%&'*+-/=?^_`.{|}~"

 

f - add "0123456789."

 

' add german Umlauts

g - "äöüßÄÜÖß"          

         

' add hex-numbers

h - "aAbBcCdDeEfF0123456789"        

 

' add mathematical symbols

i - "E.,()<>+-/\*^"            

   

' add grammatic text symbols

j - "!?.,;-()"

 

' "k" - add english letter-set

k - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

 

l- add german letter set "abcdefghijklmnopqrstuvwxyzäöüABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜß"

 

m - add valid Filename-chars excluding the \ and : "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZüöäÜÖÄß[]{}@.1234567890_-;:+#§%&()=! "

 

n - Add ":\"  

 

'  add "small letters"

s - "abcdefghijklmnopqrstuvwxyz"

 

' add time-symbols

t - ":0123456789"                    

 

Special filters (Immediately executed)

 

o - Remove ASC 0 - 31 from input-string (immediately)

p - Replace ASC 160 with ASCII 32 (immediately)

 

r - current filter-charset -> TOS

q - current input-string on TOS

u - empty/clear filter-char set

v - valid Pathnames; contains all chars that are valid

   in a pathname.

 

w - valid filenames

x - Remove exact match of filter-char-st from input-string

y - Remove any letter in filter-char-st from Input-string

z - Keep any letter that is in filter-char set

   and remove all other letters.

 

P2 - (optional) Variable with input-String that is

    going to be filtered. If given, result will be in

    same variable.

    If omitted, string is taken from TOS. In this case,

    filtered string is also put n TOS.

 

P3 - (optional) Filter-Char-String. If given, will be added

     to Filter-Char-Set at start of operation.

 

* binary compatible variable resolution:

Only the given variable name is resolved. Special-variables or variable names inside the variable are not resolved.

 

 

Example

 

'***********************************

' GFS.-Test

'***********************************

: $$SRC=(U*24)+(P*5)-(X*2)*(8*S)+(A/9)+9z

: $$REM=PX

PUV.$$REM

STS.DUMP

GFS.cyubz|$$SRC|$$PX

MBX.$$SRC

ENR.

 

 

 

Remarks

-

 

 

Limitations:

 

-

 

 

See also:

 

    1.5.2 Working with Text-Strings

    VAR. - Variable Set Value/Clear

    IVS. / NVS. - If-Variable-String

    ! STR. - String Command

    GSS. - GetSplitString

    GES. - Get-Extracted-String

    SBD. - String between Delimiter

    SBM. - String between Delimiter-Multiple

    FEM. - For Each Member

    LEN. - Length-of-String

    RPL. - RePLace in String