rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: 80063r on May 22, 2009, 03:44:19 PM

Title: Does {.inc|A|B.} have an optional parameter B?
Post by: 80063r on May 22, 2009, 03:44:19 PM
Does {.inc|A|B.} have an optional parameter B?

Would {.inc|A.} work also?

The wiki does not say that B is optional.
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: bacter on May 22, 2009, 05:33:48 PM
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.

Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: 80063r on May 22, 2009, 10:37:26 PM
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.
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: bacter on May 22, 2009, 11:34:42 PM
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 !
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: 80063r on May 23, 2009, 01:17:03 AM
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.
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: rejetto on May 23, 2009, 01:54:11 AM
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 :)
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: 80063r on May 23, 2009, 02:04:58 AM
has anyone noticed Menu > debug > run script ?

Aha!  rejetto does it again.
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: 80063r on May 23, 2009, 02:13:21 AM
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?
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: rejetto on May 23, 2009, 11:07:23 AM
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
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: 80063r on May 24, 2009, 04:14:38 PM
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.
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: rejetto on May 24, 2009, 06:00:23 PM
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.
Title: Re: Does {.inc|A|B.} have an optional parameter B?
Post by: 80063r on May 24, 2009, 08:46:44 PM
Thanks, that would be really cool.