rejetto forum

Does {.inc|A|B.} have an optional parameter B?

80063r · 12 · 2597

0 Members and 1 Guest are viewing this topic.

Offline 80063r

  • Occasional poster
  • *
    • Posts: 40
    • View Profile
Does {.inc|A|B.} have an optional parameter B?

Would {.inc|A.} work also?

The wiki does not say that B is optional.


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
inc and dec macros:

{.inc | A | B .}
{.dec | A | B .}

the value of B is the increment (decrement) value to apply. If not present, a default value of 1 is used.

If you have often doubts about the way a macro works, I suggest you to include somewhere in your template (on top or better at the bottom) a line like the following:

Code: [Select]
{.if|{.or|{.match address|127.0.0.1|%ip%.}|{.match address|192.168.1.2|%ip%.}.}|{:{.load|test.tpl.}:}.}
this will load a file test.tpl in your HFS-folder (if present) only on the local computer (not to people from lan or wan).

Then editing the file test.tpl you can write some short tests to see what a macro does. In the case of your question, this could be:

Code: [Select]
{.set|tt|3.}{.^tt.}<br />
{.inc|tt.}{.^tt.}<br />
{.inc|tt|4.}{.^tt.}<br />

the result shows:
3
4
8

In the case you have a bigger problem with complex macros, you may activate in menu -> debug -> Enable macros.log. This creates a macros.log file where ALL macro execution is shown step by step.

« Last Edit: May 22, 2009, 05:37:45 PM by bacter »
your computer has no brain - use your own !


Offline 80063r

  • Occasional poster
  • *
    • Posts: 40
    • View Profile
If you have often doubts about the way a macro works, I suggest you to include somewhere in your template ...

I was in the process of doing a skimpy hfs.diff.tpl in a test folder when the template began no longer being applied to that folder.  The other folder with hfs.diff.tpl still works but I can't seem to get the test folder working again.  It just uses the default template.

Thanks for your code though.  I can really use that idea.

Code: [Select]
{.if|{.or|{.match address|127.0.0.1|%ip%.}|{.match address|192.168.1.2|%ip%.}.}|{:{.load|test.tpl.}:}.}
I'll have to use 192.168.1.1 though.


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
if your template does not working.. look in the settings of the folder whats displayed.

You must substitute 192.168.1.2 with the local ip of your PC. But normally by default in most routers, 192.168.1.1 is the address of the gateway and DNS. Verify !
your computer has no brain - use your own !


Offline 80063r

  • Occasional poster
  • *
    • Posts: 40
    • View Profile
When I use a DNS name, like http://example.com/test_page, HFS sees my router IP because, I guess, that's where it gets looped back.  Anyway, I got that part under control for the most part except some interference from some privacy add-ons I just installed like Tor Button and Tor, Vidalia, Privoxy, and the BetterPrivacy, RefControl, and SafeCache Add-Ons for firefox.  But that's another whole issue.

Anyway, look at this macros.log output (truncated)

Code: [Select]
> %ip%
< 127.0.0.1

> %ip%
< 127.0.0.1

> %url%
< /temporary_test_pages/inc_test/

> match address|127.0.0.1|127.0.0.1
< 1

> match address|192.168.1.1|127.0.0.1
<

> or|1|
< 1

> count substring|temporary_test_pages|/temporary_test_pages/inc_test/
< 1

> and|1|1
< 1

> if|1|{:{.load|test.tpl.}:}
< {.load|test.tpl.}

> load|test.tpl
< <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title></title>
  </head>
  <body>

  </body>
</html>

It looks as if the template is getting loaded, but the page still displays the default template.  I didn't change anything in the folder properties.  I just added a local real folder to the VFS.

It seems as though I broke the template feature, except for the one folder which I added first.  It's hfs.diff.tpl is showing properly.

Oh, and by the way, I added this to hfs.tpl

Code: [Select]
[special:begin]
{.if|{.and|{.or|{.match address|127.0.0.1|%ip%.}|{.match address|192.168.1.1|%ip%.}.}|{.count substring|temporary_test_pages|%url%.}.}|{:{.load|test.tpl.}:}.}

I bet you hate to see that "Oh, and by the way" stuff.  Sorry.

Oh, and by the way, I tested this i IE7 and the macros.log says it loaded the test.tpl but the page is still showing the default template.
« Last Edit: May 23, 2009, 01:24:45 AM by 80063r »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13307
    • View Profile
i improved {.inc.} description.
thank you for reporting.

has anyone noticed Menu > debug > run script ?
that's what i use for macro testings, no need for your tricks :)


Offline 80063r

  • Occasional poster
  • *
    • Posts: 40
    • View Profile

Offline 80063r

  • Occasional poster
  • *
    • Posts: 40
    • View Profile
What do you think about having a "check box" on the "run script" dialog to choose to automatically focus the output window when the file is saved/run?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13307
    • View Profile
mmmmm
scripting is actually for expert users.
it's amiss to expect such users to reduce the editor window so that they can see the output window? ^^'
this doesn't mean i won't make this option, i'm just debating


Offline 80063r

  • Occasional poster
  • *
    • Posts: 40
    • View Profile
That was meant to be taken somewhat jokingly.  The fact that you already made a "run script" dialog is great already.  There's no need to be bogged-down by simple things like an extra "check box".

On the serious note, you already did the work of detecting that the file was changed, so focusing the window would be a simple thing to do.
« Last Edit: May 24, 2009, 04:18:24 PM by 80063r »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13307
    • View Profile
i can make a {.focus.} so that you put this command in your script and every time it is run HFS is focused :)
this will let you eventually decide to focus HFS on other events, that may be useful.