Author Topic: macros coming...  (Read 8434 times)

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Insane poster
  • *****
  • Posts: 1788
  • Country: 00
    • View Profile
Re: macros coming...
« Reply #15 on: November 15, 2007, 10:53:14 AM »
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}} }}

FRENCH MEMBER : Si vous comprenez la langue française,  n'hésitez pas à l'utiliser pour une meilleure aide de ma part

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: macros coming...
« Reply #16 on: November 15, 2007, 11:22:12 AM »
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
  • Insane poster
  • *****
  • Posts: 1788
  • Country: 00
    • View Profile
Re: macros coming...
« Reply #17 on: November 15, 2007, 12:06:50 PM »
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 ( \ / : * ? " < >)

FRENCH MEMBER : Si vous comprenez la langue française,  n'hésitez pas à l'utiliser pour une meilleure aide de ma part

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: macros coming...
« Reply #18 on: November 15, 2007, 12:13:26 PM »
mars, your suggestions don't solve the problem at all.
changing the character is not a solution.

Offline Mars

  • Operator
  • Insane poster
  • *****
  • Posts: 1788
  • Country: 00
    • View Profile
Re: macros coming...
« Reply #19 on: November 15, 2007, 12:43:48 PM »
rejetto change what you want, result must be same like (case of else end) in delphi code and syntax similar
FRENCH MEMBER : Si vous comprenez la langue française,  n'hésitez pas à l'utiliser pour une meilleure aide de ma part

Offline Giant Eagle

  • Insane poster
  • *****
  • Posts: 535
  • >=3 RAWR!
    • View Profile
    • RAWR-Designs.com
Re: macros coming...
« Reply #20 on: November 15, 2007, 01:11:51 PM »
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
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: macros coming...
« Reply #21 on: November 28, 2007, 03:48:04 PM »
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
  • Insane poster
  • *****
  • Posts: 1788
  • Country: 00
    • View Profile
Re: macros coming...
« Reply #22 on: November 28, 2007, 03:56:12 PM »
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, 04:20:57 PM by mars »
FRENCH MEMBER : Si vous comprenez la langue française,  n'hésitez pas à l'utiliser pour une meilleure aide de ma part

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: macros coming...
« Reply #23 on: November 28, 2007, 08:07:03 PM »
ok for trim, upper, lower, length, is substring