Page 1 of 1

xtranslate

Posted: Sat Sep 14, 2019 7:12 am
by Otto
Dear Antonio,
is there a way that we could xTranslate {{ }} inside BLOCK that we could use xBase code inside Block like this:
{{Date()}} mHb_date()

Thank you in advance
Otto

#xtranslate

function Main()
? "Seconds {%Seconds()%} before compilation<br><br>"
BLOCKS

Current date is {{Date()}}
Current date is mhb_date()

ENDTEXT

return nil

Re: xtranslate

Posted: Sat Sep 14, 2019 7:57 am
by Otto
Otto, you may use this:
09:32 Uhr
#xcommand BLOCKS [ PARAMS [<v1>] [,<vn>] ] => ;
#pragma __cstream | AP_RPuts( ReplaceBlocks( MyTranslate( %s ), "{{", "}}" [,<(v1)>][+","+<(vn)>] [, @<v1>][, @<vn>] ) )

function Main()

BLOCKS
mhb_date()
<br>
mhb_time()
ENDTEXT

return nil

function MyTranslate( cText )

cText = StrTran( cText, "mhb_date()", "{{Date()}}" )
cText = StrTran( cText, "mhb_time()", "{{Time()}}" )

return cText
09:32 Uhr
Tested from IIS mod_harbour