rejetto forum

Macros

Mars · 231 · 128367

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
I think this won't happen often, and it will be max 2 nested quotings.
We'll see...


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
serious problem with macro order

un bien singulier template:

Quote
<head>
</head>
<body>
{{set |counter|hello}}
<p>
First: {{^counter}}
{{set |counter|Youpi}}
<p>
{{set|itemmax| -25}}
Macro After the list:  {{^itemmax}} ** {{after the list| {{^counter}}  ** {{^itemmax}} }}

    %list%
<p>
End of list: {{^counter}} ** {{^itemmax}}

</body>
</html>

[file=folder=link]
{{set|counter| {{count}} }}
{{set|itemmax| {{^counter}} }}
<p>item {{^counter}}

Html result
Quote
<head>
</head>
<body>
<p>
First: hello
<p>
Macro After the list:  -25 ** Youpi  ** -25
<p>item 0
<p>item 1
<p>item 2
<p>item 3
<p>item 4
<p>item 5
<p>item 6
<p>item 7
<p>item 8
<p>
End of list: Youpi ** -25
</body>
</html>

quelque part, l'ordre d'évaluation n'est pas respecté


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
does this work?

{{set|data|{{replace|$1|{{?title}}|{{\{{\{{set|Title|$1}}/}}/}}/replace}}}}
{{append|{{?name}}.txt|{{^data}}}}

no :(
It was a good idea but the text file was empty, is it possible that the replace macro is dropping the quoted text?

edit:The way you suggested rejetto gave me an idea to try using set with parameters instead of replace, and it worked even better then I was hoping by outputing the macro with any quotes at all.

{{set|data|{{\{{\{{set|Title|$1}}/}}/}}}}
{{append|{{?name}}.txt|{{^data|{{?title}}}}}}

returned

{{set|Title|food}}
« Last Edit: January 06, 2008, 02:10:42 AM by Foggy »


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
we have the append macro but to accompany it, is it possible to have a macro that could remove text from a file?

or have a macro to delete a file?

or one to overwrite the file, and then you could use replace to replace what you don't want with nothing.
« Last Edit: January 06, 2008, 12:44:49 PM by Foggy »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
serious problem with macro order

{{after the list}} needs macro quoting.

or one to overwrite the file, and then you could use replace to replace what you don't want with nothing.

ok, {{save}}


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
It was a good idea but the text file was empty, is it possible that the replace macro is dropping the quoted text?

to solve dramas such this, i created a log for the macros, so we'll be able to see how they are executed.
This option won't be saved. It is meant that you use it rarely and for a short time.


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
It was a good idea but the text file was empty, is it possible that the replace macro is dropping the quoted text?

to solve dramas such this, i created a log for the macros, so we'll be able to see how they are executed.
This option won't be saved. It is meant that you use it rarely and for a short time.

ok, that could be quite useful. The error message we get down the bottom of the main hfs window has also been very useful.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
i don't know if it is possible to rejetto to create a lot of macros 

{{length line|#line|source}} return the number of caracters (exept #10#13) of the line #line from source

{{count lines|source}} return number of begining of lines in source (NOT number of #10#13)  if source is empty this macro return 0, if the last line is 'abcde'  then it is a valid line.

{{trim lines|source}} works as {{trim|source}} but it remove empty lines at END and BEGIN of source

usage by example  {{trim lines| {{section|mysection}} }}

sometime I use empty line to separate sections in my template.

{{cut lines|begin_line|end_line|source}}

begin_line and end_line can be negativ values

usage by example {{cut line|1|{{sub|{{length line|source.txt}}|x}}|source.txt}}

missing to macro {{for|}} a macro named {{exit for}}

usage by example 
{{for|x|1|{{count lines|source}}|{{if|{{length line|{{^x}}|source}}>63|{{exit for}}|Line {{^x}} is <64 /if}} /for}}



modification to accept {{?urlvar|defaultvalue}}

application {{get|url|sort={{?sort|n}}|rev={{?rev|1}} }}
ceci n'est qu'un exemple non restrictif

Quote
<form name=frm>
Name <input id=login name=name value="{{?name|%user%}}">
<p>Text <input id=text name=text>
<p><input type=submit>
</form>
<script>document.frm.text.focus();</script>
<a href="{{get|url|text=}}">REFRESH</a>
« Last Edit: January 11, 2008, 01:16:16 AM by mars »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
{{append | path+file | texte }}

{{save | path+file | text }}

{{delete | path+file }}

{{rename | path+file | newname }}

can you create the two last macros, rejetto?
« Last Edit: January 11, 2008, 03:42:14 PM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
Ok for delete and rename.

i don't know if it is possible to rejetto to create a lot of macros 

don't ask if it is possible.
ask if it is convenient/suitable.

Quote
{{length line|#line|source}} return the number of caracters (exept #10#13) of the line #line from source

what you will use it for?

Quote
{{count lines|source}} return number of begining of lines in source (NOT number of #10#13)  if source is empty this macro return 0, if the last line is 'abcde'  then it is a valid line.

in standard text files the number of lines IS the number of #13#10. I remember having read it on wikipedia.
indeed my Pspad editor does this way.
Microsoft Notepad does not ::)

Consider we shouldn't make macros for EVERY need. For some specific purposes you can use javascript. It works. Macros are meant for making common things with no javascript.

Quote
{{trim lines|source}} works as {{trim|source}} but it remove empty lines at END and BEGIN of source

trim already do remove empty lines. try before asking ;)

Quote
missing to macro {{for|}} a macro named {{exit for}}

at the moment it can't be done, because {{for}} was implemented as a sort of {{repeat}}.

Quote
modification to accept {{?urlvar|defaultvalue}}
application {{get|url|sort={{?sort|n}}|rev={{?rev|1}} }}
ceci n'est qu'un exemple non restrictif

use {{or|{{?sort}}|n}}


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
If we want to make a thing in the style

{{for|A|2|10|2|{{for|B|1|5|2|{{^A}}+{{^B}}={{ADD|{{^A}}|{{^B}} }}<p> /for}} /for}}<p>{{^A}}+{{^B}}

The result is not the one that we can hope
0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
10+5


You must correct it by insert some {{\ and /}} as

{{for|A|2|10|2|{{\ {{for|B|1|5|2|{{\{{^A}}+{{^B}}={{ADD|{{^A}}|{{^B}} }}<p>/}} /for}} /}} /for}}<p>{{^A}}+{{^B}}

and all will be correct after
2+1=3
2+3=5
2+5=7
4+1=5
4+3=7
4+5=9
6+1=7
6+3=9
6+5=11
8+1=9
8+3=11
8+5=13
10+1=11
10+3=13
10+5=15
10+5


« Last Edit: January 13, 2008, 11:13:31 PM by mars »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
{{length line|#line|source}}

{{count lines|source}}

{{cut lines|begin_line|end_line|source}}


Do not forget that source can be the contents of an external file

Quote
Consider we shouldn't make macros for EVERY need. For some specific purposes you can use javascript. It works. Macros are meant for making common things with no javascript.

I am not completely the same opinion, the macro are there to be executed at the level of the server, and so that certain actions which are possible with javascript, they are not seen by the user.

We can mask certain items in mode page as I made it, but by showing the code all the information is present.
With javascript I can simulate  restrict account on directories but it is simpler when HFS makes it, and in more the quantity of information transfer is lesser.



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
{{length line|#line|source}}
{{count lines|source}}
{{cut lines|begin_line|end_line|source}}
Do not forget that source can be the contents of an external file

yes, i guessed so. Can you tell me what's your purpose with such macros?

Quote
I am not completely the same opinion,

i'm sorry, but i won't spend years building a complete language. It makes NO sense. I already said it before. When HFS will support CGI, people interested in a full language will install PHP, Perl, anything.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
When HFS will support CGI, people interested in a full language will install PHP, Perl, anything.

 ;D I know, but it is not before 2010, and by waiting , what can we do?? To colour in our templates.... ;D ;D ;D
« Last Edit: January 14, 2008, 01:02:22 AM by mars »


ebola

  • Guest
Hi

What about a macro that makes hfs execute an executable/bat?

I'm thinking of:
1. Upload ok => call external program generating and save MD5/SHA256 to file => get the MD5 from there and add it to file-comment to verify
2. Upload ok => call AntiVius and check file => if AV return = 0 => Add file to UL-folder if not inform User it's infected


Cheers,
ebola