rejetto forum

Showing the Age value in a different way.

TSG · 21 · 7806

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 1987
    • View Profile
This is a simple personal opinion:

It is sometimes preferable to have several macro which allow to make a very precise action (but not necessarily unique) that to have the macro only one who can make a multitude of things, with a not unimportant number of parameters which most of the time are not useful. What has for consequence often to lengthen the template.

As in the example below:

{.substring|begin|end|it is the begin before the end of text.}     -->> ' before the '


{.substring||end|it is the begin before the end of text.}     -->> 'it is the begin before the '
{.chop begin|end|it is the begin before the end of text.}


{.substring|begin||it is the begin before the end of text.}     -->> ' before the end of text'
{.chop end|begin|it is the begin before the end of text.}

More of macro but fewer parameters every time.

Otherwise, rejetto, I propose you a compromise:
A section [macro] or we could define our personal macro without crossing every time by the macro SET and not use the ^ at every time

[macros]
chop begin=substring||$1|$2     
chop end=substring|$1||$2


[my section]
{.if|{.chop begin|end|it is the begin before the end of text.}|{:one action:}|{:other action:}/if.}

The example is not of the most simplistic, but it is to give an idea of the possibilities.
I am going to try to find of the delphi code to go to this direction


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13292
    • View Profile
i like this "compromise".
just changed the name in [special:alias].
implemented. next build.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 1987
    • View Profile
With this contribution of [special:alias], it will not be necessary to redo all the templates to replace the old macros:

[special:alias]
trunc=substring||.|$1


and other when found.. :D

Rejetto will thus have to watch to add indeed all the macro, which he kills as one goes along, in this new section of the default.tpl ;)

It is obvious that quite macro before being executed, must be looked for for its equivalence in the section alias.

Quote
    p:=par(0); // a handy shortcut for the first parameter

Code: [Select]
    repeat
       if not (p in [special:alias] ) then break;
        replace (p, new macro)
    until false
    // comment it's for comments, or if you just don't want the output a macro to be sent to the browser.
    // the content of comment (the parameter) is executed as anything else, it's not like macro quoting.
    if name = 'comment' then
      begin
      result:='';
      exit;
      end;


« Last Edit: February 19, 2009, 03:56:40 PM by mars »


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1934
    • View Profile
    • RAWR-Designs
mars isn't 'chop' the same as 'slice' in most programming languages?

{.slice|begin|end|it is the begin before the end of text.} etc...

I think that's what you are trying to achieve with this? the ability to 'slice' a string, that's the term that immediately came to my mind...

http://www.w3schools.com/jsref/jsref_obj_array.asp


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 1987
    • View Profile
Quote
mars isn't 'chop' the same as 'slice' in most programming languages?

I make reference only to what rejetto in the sources(springs) of hfs use, it is to him that it is necessary to ask for explanations  ;) :D

Quote
hslib.pas
{ split S in position where SS is found, the first part is returned
  the second part following SS is left in S }
function chop(ss:string; var s:string):string; overload;
// same as before, but separator is I
function chop(i:integer; var s:string):string; overload;
// same as before, but specifying separator length
function chop(i, l:integer; var s:string):string; overload;
// same as chop(lineterminator, s)
function chopLine(var s:string):string; overload;


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13292
    • View Profile
i think i borrowed that term from when i was using perl (90s), and just stayed there
:)