rejetto forum

macros coming...

rejetto · 24 · 14152

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
do you like having a macro like

{{ CASE | {{macrotest}} | {{ident1}},{{ident2}}:{{result1}} | {{ident3}},..,{{identN}}:{{result12}} |........| ELSE:{{ElseResult}} }}

all {{ident}} are type of strings
{{macrotest}} is type of string
all {{result}} are what you want

the use of this? it is by example

{{CASE | %lang% | en , us :{{section|english}} | fr , be: :{{section|french}} |...| ru : :{{section|russian}} |ELSE :{{section|english}} }}



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
ok for 'case'
but you are using commas as separator.
commas may be part of ident1.
we need a smarter solution.
making the second parameter specify the separator would solve, it's just a bit ugly.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
To avoid the problem here is a new syntax with
 'en'||'us' 
 'en';'us'   
 'en'&'us'         
 'en'!'us'
  [en][us] 
'en'='us'


{{CASE | '%lang%' | 'en' & ..& 'us' :{{section|english}} | 'fr' & 'be': :{{section|french}} |...| 'ru' :{{section|russian}} |/ELSE :{{section|english}} |/CASE}}

or

{{CASE | '%lang%' | 'en' / ../ 'us' :{{section|english}} | 'fr' / 'be': :{{section|french}} |...| 'ru' :{{section|russian}} |/ELSE :{{section|english}} |/CASE}}

I put / before ELSE to not to confuse with %test%=ELSE
if you don't want comma, you can use another separator a none dos name character in ( \ / : * ? " < >)



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
mars, your suggestions don't solve the problem at all.
changing the character is not a solution.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
rejetto change what you want, result must be same like (case of else end) in delphi code and syntax similar


Offline Giant Eagle

  • Tireless poster
  • ****
    • Posts: 535
  • >=3 RAWR!
    • View Profile
    • RAWR-Designs.com
Quote from: rejetto
hey templaters, you shall look at the way i'm changing the tpl for build #144
you'll be surprised of what macros can do :)

OMGWTFBBQ  :o imagine the possibilities!! [/quote]

really! this is amazing.


Who needs php now!?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
Since i didn't found a better solution for the switch statement, i adopted the one i cited above.
{{switch}} is coming in #147 and is already documented.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
And what think of of this:

Quote
if pars.Count < 1 then exit; // from here, only macros with parameters

if name = 'length' then                               
  try result:=Length(result) except end;         

if name = 'uppercase' then                                   
  try result:= AnsiUpperCase(result) except end;

if name = 'lowercase' then
  try result:= AnsiLowerCase(result) except end;

if name = 'trim' then
  try result:= Trim(result) except end;

if name = 'trimleft' then
  try result:= TrimLeft(result) except end;

if name = 'trimright' then
  try result:= TrimRight(result) except end;

if name = 'contains' then
  try result:=AnsiContainsStr(result) except end;

if pars.count < 2 then exit; // from here, only macros with at least 2 parameters



That can serve in certain cases  ......  the others are for the study. ;D

to be followed...
« Last Edit: November 28, 2007, 10:20:57 PM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
ok for trim, upper, lower, length, is substring