Author Topic: Showing the Age value in a different way.  (Read 5459 times)

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Insane poster
  • *****
  • Posts: 1776
    • View Profile
Re: Showing the Age value in a different way.
« Reply #15 on: February 19, 2009, 02:55:42 AM »
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
  • Insane programmer
  • *
  • Posts: 12814
  • Country: it
    • View Profile
Re: Showing the Age value in a different way.
« Reply #16 on: February 19, 2009, 06:14:55 AM »
i like this "compromise".
just changed the name in [special:alias].
implemented. next build.

Offline Mars

  • Operator
  • Insane poster
  • *****
  • Posts: 1776
    • View Profile
Re: Showing the Age value in a different way.
« Reply #17 on: February 19, 2009, 08:44:29 AM »
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, 09:56:40 AM by mars »

Offline TSG

  • Operator
  • Insane poster
  • *****
  • Posts: 1934
  • Country: au
    • View Profile
    • RAWR-Designs
Re: Showing the Age value in a different way.
« Reply #18 on: February 20, 2009, 12:00:00 AM »
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
  • Insane poster
  • *****
  • Posts: 1776
    • View Profile
Re: Showing the Age value in a different way.
« Reply #19 on: February 20, 2009, 03:52:38 AM »
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
  • Insane programmer
  • *
  • Posts: 12814
  • Country: it
    • View Profile
Re: Showing the Age value in a different way.
« Reply #20 on: February 20, 2009, 06:48:25 AM »
i think i borrowed that term from when i was using perl (90s), and just stayed there
:)