Sorry the syntax is a bit obtuse. Open to suggestions for improving it:

First, I think you need two spaces between the ? and the :. The
separator between the pattern and the actions is " ? " and the
separator between the true and false actions are " : ". So if you want
to only have a negative action you need "_ ? _ _ : _" (spaces of
course).

Second, I should warn you the forms markup are not perfect. When you
have a ] in the parameter you will have problems--as BW thinks the
input is closing. There is an escape you can use =] that will come in
handy in your testing here. I'm sure you will need it.

With those 2 caveats I got this to work as expected:

name: abc
[form]
[text name]
[submit]
[session validate_name "/[a-z=]+/ ?  : warn='wrong input!'"]   //
notice the escape
[session warn]
[session info "field=name value='{=name}'"]
[form]

Of course in your example, you have an exclude pat rather than an
accept pat, as my example. You could do it either way.

> I also do not understand why info has such complicated syntax
> and not just understands
> [session info name {=name}] or [session info "name {=name}"]
> or just simply [session info name]

First of all, you can only pass a field/value pair currently to the
engine. Not three or more parameters. This could conceivably change if
we go with DrunkenMonk's suggestion of making all session inputs
commands and html inputs simple non-executing fields. Which I am drawn
to. Just dread the problems. It would mean you could have much more
complex input parameters with commands. But right now, it is only
field:value pairs.

Second, info is first and foremost a function [(info ...)]. In
BoltWire you can easily have commands tap into functions using a
special BOLTcomm2func system function, where the value of the form
command is passed to the markup function as a single string. If you
look at BOLTXinfo you will see that's all it consists of. Just a call
to that function. I do this frequently in plugins to get 2 for the
price of one. So if we did have some other syntax like this we'd still
have to reassemble it into a string anyway to pass it over to the
function.

Third, the info var is itself very powerful, and extensible.  For
example [(info field=name)] retrieves the value of the field, so it is
different from the [(info field=name value=whatever)] which resets the
value. There are also info extensions possible like [(info count ...)]
or [(info report ...)] which have various properties. If you didn't
specify it was a field, you could conceivably trigger an info
extension. Like you did with the source command!  :)

These things kind of evolve over time. If we were doing it over again
I might set pos1 to field and pos2 to value automatically and use some
trigger like extend=count or extend=report to trigger extensions. But
we didn't. And this versatile function is widely used and changing it
now would be problematic at best.

Cheers,
Dan

P.S. I was also thinking. BoltWire has a built in extensible "filter"
system with several common patterns. I wonder if we couldn't tap into
this in the validate command by simply adding a line which says if
$BOLTfilter[$BOLTcond] exists $BOLTcond = $BOLTfilter[$BOLTcond].  We
have a filter command already but it works differently, allowing you
to transform one value into something else, using both string and
pattern replacements. Perhaps that could be renamed into something
like transform or replace (to be consistent with the replace table
functionality).  If we did that we could reharness the filter command
for tapping directly into $BOLTfilter... Another, perhaps easier
approach to form validation. Perhaps have it automatically abort,
rather than doing that programmatically. I'm just thinking out loud.
Here's the default filters.  We could add more. Or have a plugin page
with lot's of additional useful filters: email, url, text, certain
markups... etc. Could be very useful.

$BOLTfilter['letters'] = 'a-z';
$BOLTfilter['numbers'] = '0-9';
$BOLTfilter['page'] = '-_a-zA-Z0-9.#?=%*';
$BOLTfilter['csv'] = '-_a-zA-Z0-9+.,*:|!#% ';
$BOLTfilter['parameter'] = '-_a-zA-Z0-9.,\'"%:!/ ';
$BOLTfilter['math'] = '-*+/% ()0-9.';

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"BoltWire" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/boltwire?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to