aa_macro syntax 
 aa_macro source 
 HTML source 
 HTML render 
Key

§ 4.64 - [translate] Built-In

Mnemonic aid: translate for TRANSLATE characters

See also:  [aisort] ,  [append] ,  [asort] ,  [clearl] ,  [cmap] ,  [dlist] ,  [e] ,  [hmap] ,  [isort] ,  [lcc] ,  [lcopy] ,  [lhsort] ,  [list] ,  [ljoin] ,  [llen] ,  [lpop] ,  [lset] ,  [lslice] ,  [lsplit] ,  [lsub]  and  [ltol] 

This built-in allows you to translate a character string into any arbitrary code that is in a 256-entry list. The example shows  [hmap]  being used to generate a 256-entry list of hexadecimal values, and then that list being used with  [translate]  to create a string of hexadecimal constants.

Tip:

One of the things about aa_macro's syntax is that because commas are used to separate parameters, and because processing resolves all internal aa_macro language from the inside out, is that you can't really embed actual commas in text.

This demonstrates a way to get around this using the  [fref]  command and the hex=1 option of the  [resolve]  command. Because  [resolve]  does its replacements the very last thing in text processing, and because the hex=1 option allows you to specity any character string, you can go back and replace anything you need to. In this example, it is used to place a comma everywhere one is needed.


[translate (pre=PRE,)(post=POST,)(inter=INTER,)listName,content]

[hmap list1]
[translate pre=0x,inter=[fref co],list1,my text string]
[resolve hex=1,co,2c]

0x6d,0x79,0x20,0x74,0x65,0x78,0x74,0x20,0x73,0x74,0x72,0x69,0x6e,0x67
0x6d,0x79,0x20,0x74,0x65,0x78,0x74,0x20,0x73,0x74,0x72,0x69,0x6e,0x67

Other built-ins used here:  [fref] ,  [hmap]  and  [resolve] 

Keyboard Navigation
, Previous Page . Next Page t TOC i Index

Valid HTML 4.01 Loose
 

This manual was generated with wtfm
wtfm uses aa_macro and SqLite
aa_macro uses Python 2.7